-
Notifications
You must be signed in to change notification settings - Fork 41
workflows: Add clippy, nancy, and binskim release checks #319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: msft-main
Are you sure you want to change the base?
Changes from all commits
5650c9b
a067b65
b0a632c
fa6b734
f467a04
9e73d0b
a2207a3
b4c814c
0cb2324
b5d68be
3d38906
823dcd2
6a47c86
c905577
bbc7b97
38ebfa9
11f78ae
0e79eef
7ea417b
cbb60ff
99f1e83
02f03b3
8df0459
304d016
5e0ec90
9b43ba8
597200d
dda2c28
915a8fc
9ce3226
949f8c8
a004ef0
af24293
82b870c
662c86e
5f2bb03
f08c115
6ca5489
4b2ede3
d056343
a8a038f
dde0102
ff4c1ec
a1c3b2c
57ab374
dde443c
6e5f3a0
b41e55e
2d32df1
980fb87
70d6bf6
12d4585
a4b4ca2
39ab779
9c9199e
f2f5d12
cd7c5fa
1590a72
cc23bdb
e7cb0d1
2f672a1
dd57910
e6e6d34
1276d40
16523e2
386cab0
51b2fd2
80f047c
78e4962
4c89a18
39e99dc
71db681
c323d8a
910bcd6
bee89de
8ad67ac
89a658a
32ac40e
f17f994
24423ed
dc2d4de
db1787f
f20dbb9
08333aa
d375a69
52a47b6
74cc478
7e00f3d
888127e
a53640c
75a11db
f801232
0635146
2866533
2c07620
d31f369
f0c9bb2
4af3cd0
d2b13a8
3a0ca4e
09833d8
2689def
11b4c67
f6e3225
31edf1f
c7698d7
6e8cc06
0d4524c
b6872b4
49a401d
224ee62
3e16849
7df996b
a22230b
bcf32a6
dd6342c
e3d3e04
4db5ba4
eeeea27
396e0d2
715cae1
52039cb
ebc5f5f
bc69b85
4037aaf
ea98d07
5092c13
f6359a7
65ddfde
56c5fa1
8fd0c5e
488604f
663a003
eef2029
f76a06a
c4ff507
33d2030
81f0963
cc96a4a
8cb5160
c180917
ff1fafe
dcf0c36
56fbf84
4a2b5c9
e9d2c45
0126498
d4eae11
b30ded8
5dd3198
efe9610
1f4360c
e8c73d9
9224163
7d087d0
7e24498
24cb087
3d6665c
3eea977
06ea445
eac886e
7ac0143
e536fdb
876c404
9451ebe
16e98ac
02842bc
4e09c54
c5c1d9f
224583b
b00768c
0188da0
e3cb8f6
79fc221
879fe80
c355600
a68453b
9d5c3b6
609a121
dae5080
f0b8fc8
79931de
c7b8ee9
32dde44
3f0be3b
3627201
35d4c62
45ef622
724d9bf
f703a57
1e1138b
89277cc
b372dae
8245ef2
81d6b29
2dad9b8
121bf84
3f03df0
5986f3a
4d36cde
4d3b496
a96690c
c2f84a6
6e3fd0a
aa4424f
1a0437e
c67ddaf
8e9238e
807a588
02add57
577b154
a3f20ba
6058c26
0abe848
ef42ccf
a3ca1b5
1ee72c4
ec6a5bd
4dbd897
863fc7d
2d356c9
2abbdc1
7514602
35747f4
430cdd0
e7c69f7
a392bc5
e490d16
5313640
0c24daf
6899c72
66b4b83
17606b9
2cf8e50
21b5ce3
c74beee
6b55a48
b785624
c57a2d1
08aceb8
3e83bc2
2e7d73e
7400d35
8d1ba49
3579436
be02780
5163038
37b10e4
4779365
e63c06c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # By default, all files require review by members of these teams | ||
| * @microsoft/kata-cc-devs @microsoft/kata-cc-admins | ||
|
|
||
| # Modifications to this file require admin approval | ||
| /.github/CODEOWNERS @microsoft/kata-cc-admins |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ###### Merge Checklist <!-- REQUIRED --> | ||
| - [ ] Followed patch format from upstream recommendation: https://github.com/kata-containers/community/blob/main/CONTRIBUTING.md#patch-format | ||
| - [ ] Included a single commit in a given PR - at least unless there are related commits and each makes sense as a change on its own. | ||
| - [ ] Aware about the PR to be merged using "create a merge commit" rather than "squash and merge" (or similar) | ||
| - [ ] The `upstream/missing` label (or `upstream/not-needed`) has been set on the PR. | ||
|
|
||
| ###### Summary <!-- REQUIRED --> | ||
| <!-- Quick explanation of WHAT changed and WHY. --> | ||
|
|
||
| ###### Test Methodology | ||
| <!-- How was this test validated? i.e. local build, pipeline build etc. --> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| name: Release Binary Hardening checks | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - msft-main | ||
|
|
||
| jobs: | ||
| binskim: | ||
| name: Run BinSkim on Compiled Binaries | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Dependencies | ||
| run: | | ||
| echo "Installing dependencies..." | ||
| sudo apt-get update | ||
| sudo apt-get install -y git golang rustc cargo build-essential protobuf-compiler libprotobuf-dev expect libssl-dev clang libseccomp-dev btrfs-progs libdevmapper-dev cmake libfuse-dev | ||
| sudo add-apt-repository ppa:dotnet/backports | ||
| sudo apt-get install -y dotnet-sdk-9.0 aspnetcore-runtime-9.0 dotnet-runtime-9.0 zlib1g | ||
|
|
||
| - name: Set up BinSkim | ||
| run: | | ||
| dotnet new console -n TempConsoleApp | ||
| cd TempConsoleApp | ||
| echo "Installing BinSkim version 1.9.5" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a pattern to install the latest stable version? |
||
| dotnet add package Microsoft.CodeAnalysis.BinSkim --version 1.9.5 | ||
| ls ~/.nuget/packages/microsoft.codeanalysis.binskim/ | ||
| sudo mv ~/.nuget/packages/microsoft.codeanalysis.binskim/ $GITHUB_WORKSPACE | ||
| sudo ln -sf "$GITHUB_WORKSPACE/microsoft.codeanalysis.binskim/1.9.5/tools/netcoreapp3.1/linux-x64/BinSkim" /usr/local/bin/binskim | ||
|
|
||
|
|
||
| - name: Build kata/kata-cc artifacts | ||
| run: | | ||
| echo "Building kata pod sandboxing binaries" | ||
| pushd tools/osbuilder/node-builder/azure-linux | ||
| # Adapt build script for ubuntu environment | ||
| sed -i 's|^OS_VERSION=.*|OS_VERSION="3.0"|' common.sh | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need this. If you code doesn't work for Ubuntu, we can pass OS_VERSION as a variable for make package |
||
| make package | ||
| popd | ||
|
|
||
| # Prepare go binaries for binskim | ||
| pushd src/runtime | ||
| strip --strip-unneeded containerd-shim-kata-v2 | ||
| popd | ||
|
|
||
| mkdir -p artifacts/vanilla artifacts/confpods | ||
| KATA_AGENT_PATH=$(find src/agent/ -type f -name "kata-agent" | head -n 1) | ||
| KATA_SHIM_PATH=$(find src/runtime/ -type f -name "containerd-shim-kata-v2" | head -n 1) | ||
|
|
||
| echo "agent: ${KATA_AGENT_PATH}" | ||
| echo "shim: ${KATA_SHIM_PATH}" | ||
|
|
||
| # Move kata pod sandboxing binaries to artifacts/vanilla | ||
| mv "${KATA_AGENT_PATH}" "${KATA_SHIM_PATH}" artifacts/vanilla/ | ||
|
|
||
| echo "Building kata confpod binaries" | ||
| pushd tools/osbuilder/node-builder/azure-linux | ||
| make clean | ||
| make package-confpods | ||
| popd | ||
|
|
||
| TARDEV_SNAPSHOTTER_PATH=$(find src/tardev-snapshotter/ -type f -name "tardev-snapshotter" | head -n 1) | ||
| OVERLAY_PATH=$(find src/overlay/ -type f -name "kata-overlay" | head -n 1) | ||
| echo "tardev: ${TARDEV_SNAPSHOTTER_PATH}" | ||
| echo "overlay: ${OVERLAY_PATH}" | ||
|
|
||
| # Prepare go binaries for binskim | ||
| pushd src/runtime | ||
| strip --strip-unneeded containerd-shim-kata-v2 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should stripping be something we should generally be doing when we build? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might remove information needed when debugging, no? |
||
| popd | ||
|
|
||
| # Move kata confpod binaries to artifacts/confpods | ||
| mv "${KATA_AGENT_PATH}" "${KATA_SHIM_PATH}" "${TARDEV_SNAPSHOTTER_PATH}" "${OVERLAY_PATH}" artifacts/confpods/ | ||
|
|
||
| - name: Run BinSkim on kata pod sandboxing binaries | ||
| run: | | ||
| for binary in artifacts/vanilla/*; do | ||
| echo "Running BinSkim on $binary" | ||
| binskim analyze "$binary" --level Error --kind "Pass;Fail" > "${binary}_binskim_result" | ||
| done | ||
|
|
||
| - name: Run BinSkim on kata confpod binaries | ||
| run: | | ||
| for binary in artifacts/confpods/*; do | ||
| echo "Running BinSkim on $binary" | ||
| binskim analyze "$binary" --level Error --kind "Pass;Fail" > "${binary}_binskim_result" | ||
| done | ||
|
|
||
| - name: Validate BinSkim results | ||
| run: | | ||
| # Validate pod sandboxing binaries | ||
| for result in artifacts/vanilla/*_binskim_result; do | ||
| if [ ! -f "$result" ]; then | ||
| echo "❌ Error: $result was not generated." | ||
| exit 1 | ||
| fi | ||
| echo "Validating: pod sandboxing ${result}" | ||
| cat "$result" | ||
|
|
||
| if grep -qi "fail" "$result"; then | ||
| echo "❌ Error: Failures detected in pod sandboxing binary: $result" | ||
| exit 1 | ||
| fi | ||
| echo "--------------------------- End-------------------------" | ||
| done | ||
| echo "✅ All pod sandboxing binaries passed BinSkim." | ||
|
|
||
| # Validate confpod binaries | ||
| for result in artifacts/confpods/*_binskim_result; do | ||
| if [ ! -f "$result" ]; then | ||
| echo "❌ Error: $result was not generated." | ||
| exit 1 | ||
| fi | ||
| echo "Validating: conf pod ${result}" | ||
| cat "$result" | ||
|
|
||
| if grep -qi "fail" "$result"; then | ||
| echo "❌ Error: Failures detected in Confidential Pod binary: $result" | ||
| exit 1 | ||
| fi | ||
| echo "--------------------------- End-------------------------" | ||
| done | ||
| echo "✅ All confpod binaries passed BinSkim." | ||
|
Comment on lines
+93
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should be independent steps so one binary failing doesn't block other results. We should probably rework this step using |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
|
|
||
| name: Check policy samples | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| check-policy-samples: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
|
|
||
| - name: Check out code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install yq | ||
| env: | ||
| INSTALL_IN_GOPATH: false | ||
| run: | | ||
| ./ci/install_yq.sh | ||
|
|
||
| - name: Install Rust | ||
| run: | | ||
| ./tests/install_rust.sh | ||
| echo "${HOME}/.cargo/bin" >> $GITHUB_PATH | ||
|
|
||
| - name: Install protobuf-compiler | ||
| run: | | ||
| sudo apt-get -y install protobuf-compiler | ||
|
|
||
| - name: Configure containerd | ||
| run: | | ||
| sudo containerd config default | sudo dd of=/etc/containerd/config.toml | ||
| sudo systemctl restart containerd | ||
| sudo systemctl is-active containerd | ||
|
|
||
| - name: Update policy samples | ||
| working-directory: ./src/tools/genpolicy | ||
| run: | | ||
| python3 update_policy_samples.py | ||
|
|
||
| - name: Show diff | ||
| run: | | ||
| git diff | ||
|
|
||
| - name: Check policy samples | ||
| run: | | ||
| git diff-files --exit-code |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| name: Release Static Checks | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - msft-main | ||
|
|
||
| jobs: | ||
| clippy: | ||
| name: Run Clippy on Rust Components | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The upstream static checks (static-checks.yaml) already run clippy - we should leverage those? |
||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libdevmapper-dev clang llvm | ||
|
|
||
| - name: Install Rust Toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| components: clippy | ||
|
Comment on lines
+22
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should install Rust the way that upstream does it (install_rust.sh). Regardless, we might not want to pick up Rust's latest version here, as it could break us. We should probably fetch the version from versions.yaml (and ensure the version that's there is the one we want). |
||
|
|
||
| - name: Run Clippy on agent | ||
| working-directory: src/agent | ||
| run: | | ||
| echo "Running Clippy on kata agent..." | ||
| if ! cargo clippy -- -D warnings; then | ||
| echo "❌ Clippy check failed for kata agent." | ||
| exit 1 | ||
| fi | ||
| echo "✅ Clippy check passed for kata agent." | ||
|
|
||
| - name: Run Clippy on overlay | ||
| working-directory: src/overlay | ||
| run: | | ||
| echo "Running Clippy on kata overlay..." | ||
| if ! cargo clippy -- -D warnings; then | ||
| echo "❌ Clippy check failed for kata overlay." | ||
| exit 1 | ||
| fi | ||
| echo "✅ Clippy check passed for kata overlay." | ||
|
|
||
| - name: Run Clippy on tardev-snapshotter | ||
| working-directory: src/tardev-snapshotter | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we wan to also scan utarfs? |
||
| run: | | ||
| echo "Running Clippy on tardev-snapshotter..." | ||
| if ! cargo clippy -- -D warnings; then | ||
| echo "❌ Clippy check failed for tardev-snapshotter." | ||
| exit 1 | ||
| fi | ||
| echo "✅ Clippy check passed for tardev-snapshotter." | ||
|
Comment on lines
+27
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These steps should be independent too. And no need for the output complexity, simply running |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,17 +86,6 @@ jobs: | |
| error: 'Body line too long (max 150)' | ||
| post_error: ${{ env.error_msg }} | ||
|
|
||
| - name: Check Fixes | ||
| if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') && ( success() || failure() ) }} | ||
| uses: tim-actions/[email protected] | ||
| with: | ||
| commits: ${{ steps.get-pr-commits.outputs.commits }} | ||
| pattern: '\s*Fixes\s*:?\s*(#\d+|github\.com\/kata-containers\/[a-z-.]*#\d+)|^\s*release\s*:' | ||
| flags: 'i' | ||
| error: 'No "Fixes" found' | ||
| post_error: ${{ env.error_msg }} | ||
| one_pass_all_pass: 'true' | ||
|
|
||
| - name: Check Subsystem | ||
| if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') && ( success() || failure() ) }} | ||
| uses: tim-actions/[email protected] | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,37 @@ | ||||||||||
| name: Release Static Checks | ||||||||||
|
|
||||||||||
| on: | ||||||||||
| pull_request: | ||||||||||
| branches: | ||||||||||
| - msft-main | ||||||||||
|
|
||||||||||
| jobs: | ||||||||||
| nancy: | ||||||||||
| name: Run Nancy on Go Dependencies | ||||||||||
| runs-on: ubuntu-latest | ||||||||||
|
|
||||||||||
| steps: | ||||||||||
| - name: Checkout Repository | ||||||||||
| uses: actions/checkout@v4 | ||||||||||
|
|
||||||||||
| - name: Set up Go | ||||||||||
| uses: actions/setup-go@v5 | ||||||||||
| with: | ||||||||||
| go-version: stable # Use latest stable Go version | ||||||||||
|
|
||||||||||
| - name: Install Nancy via Go | ||||||||||
| run: | | ||||||||||
| echo "Installing Nancy..." | ||||||||||
| go install github.com/sonatype-nexus-community/nancy@latest | ||||||||||
| echo "$HOME/go/bin" >> $GITHUB_PATH | ||||||||||
|
|
||||||||||
| - name: Verify Nancy Installation | ||||||||||
| run: | | ||||||||||
| echo "Checking Nancy installation..." | ||||||||||
| nancy --help || echo "Nancy installed successfully!" | ||||||||||
|
|
||||||||||
|
Comment on lines
+28
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant
Suggested change
|
||||||||||
| - name: Run Nancy on `src/runtime` | ||||||||||
| working-directory: src/runtime | ||||||||||
| run: | | ||||||||||
| echo "Running Nancy vulnerability scan on Go dependencies..." | ||||||||||
| go list -m all | nancy sleuth | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add a codeql file as well for the tarfs module, similar to https://github.com/kata-containers/kata-containers/pull/10930/files ?