Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.

Commit 52fcbe3

Browse files
author
Derek Lee
committed
github-actions: Add cargo-deny
Adds cargo-deny to scan for vulnerabilities and license issues regarding rust crates. Some modifications were required for the repo to pass the tests: Updates ttrpc to avoid using nix 0.16.0 https://rustsec.org/advisories/RUSTSEC-2021-0119 Updates slog-json to avoid MLP license (copyleft) Updates crossbeam-channel because 0.52.0 was a yanked package Ignores https://rustsec.org/advisories/RUSTSEC-2020-0071 because chrono is dependent on that version of time. chronotope/chrono#578 Allow multiple versions of the same package (package dependencies require this) Adds "oci" to src/libs workplace Adds Apache-2.0 license to workplace modules that did not have them because cargo-deny complains about them not having licenses. Notes GitHub Actions does not have an obvious way to loop over each of the Cargo.toml files. To avoid hardcoding it, I worked around the problem using a composite action that first generates the cargo-deny action by finding all Cargo.toml files before calling this new generated action in the master workflow. Fixes kata-containers#3359 Signed-off-by: Derek Lee <[email protected]>
1 parent 575b5eb commit 52fcbe3

File tree

17 files changed

+161
-140
lines changed

17 files changed

+161
-140
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
script_dir=$(dirname "$(readlink -f "$0")")
3+
parent_dir=$(realpath "${script_dir}/../..")
4+
cargo_tomls=$(find "${parent_dir}" -name Cargo.toml)
5+
6+
temp_checkout_dir="./cargo-deny-action-copy"
7+
8+
cargo_deny_file="${script_dir}/action.yaml"
9+
10+
cat cargo-deny-skeleton.yaml.in > "${cargo_deny_file}"
11+
12+
for path in $cargo_tomls
13+
do
14+
path=$(realpath --relative-to="${parent_dir}" "${path}")
15+
16+
cat >> "${cargo_deny_file}" << EOF
17+
18+
- name: ${path}
19+
uses: EmbarkStudios/cargo-deny-action@v1
20+
with:
21+
arguments: --manifest-path ${path}
22+
command: check \${{ inputs.command }}
23+
EOF
24+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: 'Cargo Crates Check'
2+
description: 'Checks every Cargo.toml file using cargo-deny'
3+
inputs:
4+
command:
5+
description: Either 'advisories' or 'bans licenses sources'
6+
required: true
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- uses: actions/checkout@v3
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Cargo Crates Check Runner
2+
on: [pull_request]
3+
jobs:
4+
cargo-deny-master:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
checks:
9+
- advisories
10+
- bans licenses sources
11+
12+
continue-on-error: ${{ matrix.checks == 'advisories' }}
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
- run: bash cargo-deny-generator.sh
17+
working-directory: ./.github/cargo-deny-composite-action/
18+
- uses: ./.github/cargo-deny-composite-action
19+
with:
20+
command: ${{ matrix.checks }}

deny.toml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
targets = [
2+
{ triple = "x86_64-unknown-linux-gnu" },
3+
{ triple = "x86_64-unknown-linux-musl" },
4+
{ triple = "x86_64-apple-darwin" },
5+
{ triple = "x86_64-pc-windows-msvc" },
6+
]
7+
8+
[advisories]
9+
vulnerability = "deny"
10+
unsound = "deny"
11+
unmaintained = "deny"
12+
ignore = ["RUSTSEC-2020-0071"]
13+
14+
[bans]
15+
multiple-versions = "allow"
16+
deny = [
17+
{ name = "openssl-sys" },
18+
{ name = "cmake" },
19+
]
20+
21+
[licenses]
22+
unlicensed = "deny"
23+
allow-osi-fsf-free = "neither"
24+
copyleft = "deny"
25+
# We want really high confidence when inferring licenses from text
26+
confidence-threshold = 0.93
27+
allow = ["Apache-2.0", "MIT", "BSD-3-Clause", "ISC"]
28+
private = { ignore = true}
29+
30+
exceptions = []

src/agent/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "kata-agent"
33
version = "0.1.0"
44
authors = ["The Kata Containers community <[email protected]>"]
55
edition = "2018"
6+
license = "Apache-2.0"
67

78
[dependencies]
89
oci = { path = "../libs/oci" }

src/agent/rustjail/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "rustjail"
33
version = "0.1.0"
44
authors = ["The Kata Containers community <[email protected]>"]
55
edition = "2018"
6+
license = "Apache-2.0"
67

78
[dependencies]
89
serde = "1.0.91"

src/agent/vsock-exporter/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "vsock-exporter"
33
version = "0.1.0"
44
authors = ["James O. D. Hunt <[email protected]>"]
55
edition = "2018"
6+
license = "Apache-2.0"
67

78
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
89

src/libs/Cargo.lock

+22-41
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/libs/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[workspace]
22
members = [
33
"logging",
4+
"oci",
45
"safe-path",
56
"protocols",
67
]

src/libs/logging/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "logging"
33
version = "0.1.0"
44
authors = ["The Kata Containers community <[email protected]>"]
55
edition = "2018"
6+
license = "Apache-2.0"
67

78
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
89

src/libs/oci/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "oci"
33
version = "0.1.0"
44
authors = ["The Kata Containers community <[email protected]>"]
55
edition = "2018"
6+
license = "Apache-2.0"
67

78
[dependencies]
89
serde = "1.0.131"

src/libs/protocols/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "protocols"
33
version = "0.1.0"
44
authors = ["The Kata Containers community <[email protected]>"]
55
edition = "2018"
6+
license = "Apache-2.0"
67

78
[features]
89
default = []

src/tools/agent-ctl/Cargo.lock

+15-37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools/agent-ctl/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ name = "kata-agent-ctl"
88
version = "0.0.1"
99
authors = ["The Kata Containers community <[email protected]>"]
1010
edition = "2018"
11+
license = "Apache-2.0"
1112

1213
[dependencies]
1314
protocols = { path = "../../libs/protocols", features = ["with-serde"] }

0 commit comments

Comments
 (0)