Skip to content

Commit 7ace596

Browse files
g0hl1neldruin
authored andcommitted
github workflows: add cargo-deny ci action
Use cargo-deny to add more linting power. Furthermore add exceptions for findings. Signed-off-by: Richard Leitner <[email protected]>
1 parent 192b932 commit 7ace596

File tree

2 files changed

+226
-0
lines changed

2 files changed

+226
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,26 @@ jobs:
5858
target: x86_64-unknown-linux-gnu
5959
toolchain: "1.56.1"
6060

61+
# --------------------------------------------------------------------------
62+
# cargo-deny
63+
64+
cargo-deny:
65+
runs-on: ubuntu-latest
66+
strategy:
67+
matrix:
68+
checks:
69+
- advisories
70+
- bans licenses sources
71+
72+
# Prevent sudden announcement of a new advisory from failing ci:
73+
continue-on-error: ${{ matrix.checks == 'advisories' }}
74+
75+
steps:
76+
- uses: actions/checkout@v3
77+
- uses: EmbarkStudios/cargo-deny-action@v1
78+
with:
79+
command: check ${{ matrix.checks }}
80+
6181
# --------------------------------------------------------------------------
6282
# BUILD
6383

deny.toml

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# Note that all fields that take a lint level have these possible values:
2+
# * deny - An error will be produced and the check will fail
3+
# * warn - A warning will be produced, but the check will not fail
4+
# * allow - No warning or error will be produced, though in some cases a note
5+
# will be
6+
7+
# If 1 or more target triples (and optionally, target_features) are specified,
8+
# only the specified targets will be checked when running `cargo deny check`.
9+
# This means, if a particular package is only ever used as a target specific
10+
# dependency, such as, for example, the `nix` crate only being used via the
11+
# `target_family = "unix"` configuration, that only having windows targets in
12+
# this list would mean the nix crate, as well as any of its exclusive
13+
# dependencies not shared by any other crates, would be ignored, as the target
14+
# list here is effectively saying which targets you are building for.
15+
targets = [
16+
{ triple = "aarch64-apple-darwin" },
17+
{ triple = "aarch64-apple-ios" },
18+
{ triple = "aarch64-unknown-linux-gnu" },
19+
{ triple = "aarch64-unknown-linux-musl" },
20+
{ triple = "arm-linux-androideabi" },
21+
{ triple = "armv7-linux-androideabi" },
22+
{ triple = "i686-pc-windows-gnu" },
23+
{ triple = "i686-pc-windows-msvc" },
24+
{ triple = "i686-unknwon-linux-gnu" },
25+
{ triple = "i686-unknown-linux-musl" },
26+
{ triple = "x86_64-apple-darwin" },
27+
{ triple = "x86_64-pc-windows-gnu" },
28+
{ triple = "x86_64-pc-windows-msvc" },
29+
{ triple = "x86_64-unknown-linux-gnu" },
30+
{ triple = "x86_64-unknown-linux-musl" },
31+
{ triple = "x86_64-unknown-netbsd" },
32+
]
33+
34+
# This section is considered when running `cargo deny check advisories`
35+
# More documentation for the advisories section can be found here:
36+
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
37+
[advisories]
38+
# The path where the advisory database is cloned/fetched into
39+
db-path = "~/.cargo/advisory-db"
40+
# The url(s) of the advisory databases to use
41+
db-urls = ["https://github.com/rustsec/advisory-db"]
42+
# The lint level for security vulnerabilities
43+
vulnerability = "deny"
44+
# The lint level for unmaintained crates
45+
unmaintained = "deny"
46+
# The lint level for crates that have been yanked from their source registry
47+
yanked = "deny"
48+
# The lint level for crates with security notices.
49+
notice = "deny"
50+
# A list of advisory IDs to ignore. Note that ignored advisories will still
51+
# output a note when they are encountered.
52+
ignore = [
53+
"RUSTSEC-2020-0168", # caused by unmaintained mach dependency of core-foundation-sys
54+
"RUSTSEC-2021-0145", # caused by unmaintained atty
55+
]
56+
# Threshold for security vulnerabilities, any vulnerability with a CVSS score
57+
# lower than the range specified will be ignored. Note that ignored advisories
58+
# will still output a note when they are encountered.
59+
# * None - CVSS Score 0.0
60+
# * Low - CVSS Score 0.1 - 3.9
61+
# * Medium - CVSS Score 4.0 - 6.9
62+
# * High - CVSS Score 7.0 - 8.9
63+
# * Critical - CVSS Score 9.0 - 10.0
64+
#severity-threshold =
65+
66+
# If this is true, then cargo deny will use the git executable to fetch advisory database.
67+
# If this is false, then it uses a built-in git library.
68+
# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support.
69+
# See Git Authentication for more information about setting up git authentication.
70+
#git-fetch-with-cli = true
71+
72+
# This section is considered when running `cargo deny check licenses`
73+
# More documentation for the licenses section can be found here:
74+
# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html
75+
[licenses]
76+
# The lint level for crates which do not have a detectable license
77+
unlicensed = "deny"
78+
# List of explicitly allowed licenses
79+
# See https://spdx.org/licenses/ for list of possible licenses
80+
# [possible values: any SPDX 3.11 short identifier (+ optional exception)].
81+
allow = [
82+
"MIT",
83+
"Apache-2.0",
84+
"Unicode-DFS-2016",
85+
"BSD-2-Clause",
86+
]
87+
# List of explicitly disallowed licenses
88+
# See https://spdx.org/licenses/ for list of possible licenses
89+
# [possible values: any SPDX 3.11 short identifier (+ optional exception)].
90+
deny = [
91+
#"Nokia",
92+
]
93+
# Lint level for licenses considered copyleft
94+
copyleft = "allow"
95+
# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses
96+
# * both - The license will be approved if it is both OSI-approved *AND* FSF
97+
# * either - The license will be approved if it is either OSI-approved *OR* FSF
98+
# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF
99+
# * fsf-only - The license will be approved if is FSF *AND NOT* OSI-approved
100+
# * neither - This predicate is ignored and the default lint level is used
101+
allow-osi-fsf-free = "neither"
102+
# Lint level used when no other predicates are matched
103+
# 1. License isn't in the allow or deny lists
104+
# 2. License isn't copyleft
105+
# 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither"
106+
default = "deny"
107+
# The confidence threshold for detecting a license from license text.
108+
# The higher the value, the more closely the license text must be to the
109+
# canonical license text of a valid SPDX license file.
110+
# [possible values: any between 0.0 and 1.0].
111+
confidence-threshold = 0.8
112+
# Allow 1 or more licenses on a per-crate basis, so that particular licenses
113+
# aren't accepted for every possible crate as with the normal allow list
114+
exceptions = [
115+
# Each entry is the crate and version constraint, and its specific allow
116+
# list
117+
#{ allow = ["Zlib"], name = "adler32", version = "*" },
118+
]
119+
120+
# Some crates don't have (easily) machine readable licensing information,
121+
# adding a clarification entry for it allows you to manually specify the
122+
# licensing information
123+
#[[licenses.clarify]]
124+
# The name of the crate the clarification applies to
125+
#name = "ring"
126+
# The optional version constraint for the crate
127+
#version = "*"
128+
# The SPDX expression for the license requirements of the crate
129+
#expression = "MIT AND ISC AND OpenSSL"
130+
# One or more files in the crate's source used as the "source of truth" for
131+
# the license expression. If the contents match, the clarification will be used
132+
# when running the license check, otherwise the clarification will be ignored
133+
# and the crate will be checked normally, which may produce warnings or errors
134+
# depending on the rest of your configuration
135+
#license-files = [
136+
# Each entry is a crate relative path, and the (opaque) hash of its contents
137+
#{ path = "LICENSE", hash = 0xbd0eed23 }
138+
#]
139+
140+
[licenses.private]
141+
# If true, ignores workspace crates that aren't published, or are only
142+
# published to private registries.
143+
# To see how to mark a crate as unpublished (to the official registry),
144+
# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field.
145+
ignore = false
146+
# One or more private registries that you might publish crates to, if a crate
147+
# is only published to private registries, and ignore is true, the crate will
148+
# not have its license(s) checked
149+
registries = [
150+
#"https://sekretz.com/registry
151+
]
152+
153+
# This section is considered when running `cargo deny check bans`.
154+
# More documentation about the 'bans' section can be found here:
155+
# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
156+
[bans]
157+
# Lint level for when multiple versions of the same crate are detected
158+
multiple-versions = "deny"
159+
# Lint level for when a crate version requirement is `*`
160+
wildcards = "deny"
161+
# The graph highlighting used when creating dotgraphs for crates
162+
# with multiple versions
163+
# * lowest-version - The path to the lowest versioned duplicate is highlighted
164+
# * simplest-path - The path to the version with the fewest edges is highlighted
165+
# * all - Both lowest-version and simplest-path are used
166+
highlight = "all"
167+
# List of crates that are allowed. Use with care!
168+
allow = [
169+
]
170+
# List of crates to deny
171+
deny = [
172+
]
173+
# Certain crates/versions that will be skipped when doing duplicate detection.
174+
skip = [
175+
]
176+
# Similarly to `skip` allows you to skip certain crates during duplicate
177+
# detection. Unlike skip, it also includes the entire tree of transitive
178+
# dependencies starting at the specified crate, up to a certain depth, which is
179+
# by default infinite
180+
skip-tree = [
181+
{ name = "clap", version = "~3.2" }, # https://github.com/serialport/serialport-rs/pull/76
182+
]
183+
184+
# This section is considered when running `cargo deny check sources`.
185+
# More documentation about the 'sources' section can be found here:
186+
# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html
187+
[sources]
188+
# Lint level for what to happen when a crate from a crate registry that is not
189+
# in the allow list is encountered
190+
unknown-registry = "deny"
191+
# Lint level for what to happen when a crate from a git repository that is not
192+
# in the allow list is encountered
193+
unknown-git = "deny"
194+
# List of URLs for allowed crate registries. Defaults to the crates.io index
195+
# if not specified. If it is specified but empty, no registries are allowed.
196+
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
197+
# List of URLs for allowed Git repositories
198+
allow-git = []
199+
200+
[sources.allow-org]
201+
# 1 or more github.com organizations to allow git sources for
202+
#github = [""]
203+
# 1 or more gitlab.com organizations to allow git sources for
204+
#gitlab = [""]
205+
# 1 or more bitbucket.org organizations to allow git sources for
206+
#bitbucket = [""]

0 commit comments

Comments
 (0)