Skip to content

Commit caa9043

Browse files
authored
Merge pull request #6464 from Turbo87/cargo-deny
Integrate `cargo-deny`
2 parents e70ee03 + 4687c6c commit caa9043

File tree

2 files changed

+312
-0
lines changed

2 files changed

+312
-0
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
env:
16+
# renovate: datasource=crate depName=cargo-deny versioning=semver
17+
CARGO_DENY_VERSION: 0.13.9
1618
# renovate: datasource=crate depName=diesel_cli versioning=semver
1719
DIESEL_CLI_VERSION: 2.0.1
1820
# renovate: datasource=npm depName=pnpm
@@ -53,9 +55,15 @@ jobs:
5355
Cargo.toml
5456
rust-toolchain.toml
5557
58+
- uses: tj-actions/[email protected]
59+
id: changed-files-rust-lockfile
60+
with:
61+
files: Cargo.lock
62+
5663
outputs:
5764
non-js: ${{ steps.changed-files-non-js.outputs.any_modified }}
5865
non-rust: ${{ steps.changed-files-non-rust.outputs.any_modified }}
66+
rust-lockfile: ${{ steps.changed-files-rust-lockfile.outputs.any_modified }}
5967

6068
backend-lint:
6169
name: Backend / Lint
@@ -77,6 +85,23 @@ jobs:
7785
- run: cargo fmt --check
7886
- run: cargo clippy --all-targets --all-features --all
7987

88+
backend-cargo-deny:
89+
name: Backend / cargo-deny
90+
runs-on: ubuntu-22.04
91+
needs: changed-files
92+
if: needs.changed-files.outputs.rust-lockfile == 'true'
93+
94+
env:
95+
RUSTFLAGS: "-D warnings"
96+
97+
steps:
98+
- uses: actions/[email protected]
99+
100+
- uses: Swatinem/[email protected]
101+
102+
- run: cargo install cargo-deny --vers ${{ env.CARGO_DENY_VERSION }}
103+
- run: cargo deny check
104+
80105
backend-test:
81106
name: Backend / Test
82107
runs-on: ubuntu-22.04

deny.toml

Lines changed: 287 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,287 @@
1+
# This template contains all of the possible sections and their default values
2+
3+
# Note that all fields that take a lint level have these possible values:
4+
# * deny - An error will be produced and the check will fail
5+
# * warn - A warning will be produced, but the check will not fail
6+
# * allow - No warning or error will be produced, though in some cases a note
7+
# will be
8+
9+
# The values provided in this template are the default values that will be used
10+
# when any section or field is not specified in your own configuration
11+
12+
# Root options
13+
14+
# If 1 or more target triples (and optionally, target_features) are specified,
15+
# only the specified targets will be checked when running `cargo deny check`.
16+
# This means, if a particular package is only ever used as a target specific
17+
# dependency, such as, for example, the `nix` crate only being used via the
18+
# `target_family = "unix"` configuration, that only having windows targets in
19+
# this list would mean the nix crate, as well as any of its exclusive
20+
# dependencies not shared by any other crates, would be ignored, as the target
21+
# list here is effectively saying which targets you are building for.
22+
targets = [
23+
{ triple = "x86_64-unknown-linux-gnu" },
24+
25+
# The triple can be any string, but only the target triples built in to
26+
# rustc (as of 1.40) can be checked against actual config expressions
27+
#{ triple = "x86_64-unknown-linux-musl" },
28+
# You can also specify which target_features you promise are enabled for a
29+
# particular target. target_features are currently not validated against
30+
# the actual valid features supported by the target architecture.
31+
#{ triple = "wasm32-unknown-unknown", features = ["atomics"] },
32+
]
33+
# When creating the dependency graph used as the source of truth when checks are
34+
# executed, this field can be used to prune crates from the graph, removing them
35+
# from the view of cargo-deny. This is an extremely heavy hammer, as if a crate
36+
# is pruned from the graph, all of its dependencies will also be pruned unless
37+
# they are connected to another crate in the graph that hasn't been pruned,
38+
# so it should be used with care. The identifiers are [Package ID Specifications]
39+
# (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html)
40+
#exclude = []
41+
# If true, metadata will be collected with `--all-features`. Note that this can't
42+
# be toggled off if true, if you want to conditionally enable `--all-features` it
43+
# is recommended to pass `--all-features` on the cmd line instead
44+
all-features = false
45+
# If true, metadata will be collected with `--no-default-features`. The same
46+
# caveat with `all-features` applies
47+
no-default-features = false
48+
# If set, these feature will be enabled when collecting metadata. If `--features`
49+
# is specified on the cmd line they will take precedence over this option.
50+
#features = []
51+
# When outputting inclusion graphs in diagnostics that include features, this
52+
# option can be used to specify the depth at which feature edges will be added.
53+
# This option is included since the graphs can be quite large and the addition
54+
# of features from the crate(s) to all of the graph roots can be far too verbose.
55+
# This option can be overridden via `--feature-depth` on the cmd line
56+
feature-depth = 1
57+
58+
# This section is considered when running `cargo deny check advisories`
59+
# More documentation for the advisories section can be found here:
60+
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
61+
[advisories]
62+
# The path where the advisory database is cloned/fetched into
63+
db-path = "~/.cargo/advisory-db"
64+
# The url(s) of the advisory databases to use
65+
db-urls = ["https://github.com/rustsec/advisory-db"]
66+
# The lint level for security vulnerabilities
67+
vulnerability = "deny"
68+
# The lint level for unmaintained crates
69+
unmaintained = "warn"
70+
# The lint level for crates that have been yanked from their source registry
71+
yanked = "warn"
72+
# The lint level for crates with security notices. Note that as of
73+
# 2019-12-17 there are no security notice advisories in
74+
# https://github.com/rustsec/advisory-db
75+
notice = "warn"
76+
# A list of advisory IDs to ignore. Note that ignored advisories will still
77+
# output a note when they are encountered.
78+
ignore = [
79+
#"RUSTSEC-0000-0000",
80+
]
81+
# Threshold for security vulnerabilities, any vulnerability with a CVSS score
82+
# lower than the range specified will be ignored. Note that ignored advisories
83+
# will still output a note when they are encountered.
84+
# * None - CVSS Score 0.0
85+
# * Low - CVSS Score 0.1 - 3.9
86+
# * Medium - CVSS Score 4.0 - 6.9
87+
# * High - CVSS Score 7.0 - 8.9
88+
# * Critical - CVSS Score 9.0 - 10.0
89+
#severity-threshold =
90+
91+
# If this is true, then cargo deny will use the git executable to fetch advisory database.
92+
# If this is false, then it uses a built-in git library.
93+
# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support.
94+
# See Git Authentication for more information about setting up git authentication.
95+
#git-fetch-with-cli = true
96+
97+
# This section is considered when running `cargo deny check licenses`
98+
# More documentation for the licenses section can be found here:
99+
# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html
100+
[licenses]
101+
# The lint level for crates which do not have a detectable license
102+
unlicensed = "deny"
103+
# List of explicitly allowed licenses
104+
# See https://spdx.org/licenses/ for list of possible licenses
105+
# [possible values: any SPDX 3.11 short identifier (+ optional exception)].
106+
allow = [
107+
"0BSD",
108+
"Apache-2.0",
109+
#"Apache-2.0 WITH LLVM-exception",
110+
"BSD-2-Clause",
111+
"BSD-3-Clause",
112+
"ISC",
113+
"MIT",
114+
"OpenSSL",
115+
"Unicode-DFS-2016",
116+
]
117+
# List of explicitly disallowed licenses
118+
# See https://spdx.org/licenses/ for list of possible licenses
119+
# [possible values: any SPDX 3.11 short identifier (+ optional exception)].
120+
deny = [
121+
#"Nokia",
122+
]
123+
# Lint level for licenses considered copyleft
124+
copyleft = "warn"
125+
# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses
126+
# * both - The license will be approved if it is both OSI-approved *AND* FSF
127+
# * either - The license will be approved if it is either OSI-approved *OR* FSF
128+
# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF
129+
# * fsf-only - The license will be approved if is FSF *AND NOT* OSI-approved
130+
# * neither - This predicate is ignored and the default lint level is used
131+
allow-osi-fsf-free = "neither"
132+
# Lint level used when no other predicates are matched
133+
# 1. License isn't in the allow or deny lists
134+
# 2. License isn't copyleft
135+
# 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither"
136+
default = "deny"
137+
# The confidence threshold for detecting a license from license text.
138+
# The higher the value, the more closely the license text must be to the
139+
# canonical license text of a valid SPDX license file.
140+
# [possible values: any between 0.0 and 1.0].
141+
confidence-threshold = 0.8
142+
# Allow 1 or more licenses on a per-crate basis, so that particular licenses
143+
# aren't accepted for every possible crate as with the normal allow list
144+
exceptions = [
145+
# Each entry is the crate and version constraint, and its specific allow
146+
# list
147+
#{ allow = ["Zlib"], name = "adler32", version = "*" },
148+
149+
# `htmlescape` uses `Apache-2.0 OR MIT OR MPL-2.0` so we are explicitly
150+
# allowing `MPL-2.0` here to please `cargo-deny`.
151+
{ allow = ["MPL-2.0"], name = "htmlescape", version = "*" },
152+
]
153+
154+
# Some crates don't have (easily) machine readable licensing information,
155+
# adding a clarification entry for it allows you to manually specify the
156+
# licensing information
157+
#[[licenses.clarify]]
158+
# The name of the crate the clarification applies to
159+
#name = "ring"
160+
# The optional version constraint for the crate
161+
#version = "*"
162+
# The SPDX expression for the license requirements of the crate
163+
#expression = "MIT AND ISC AND OpenSSL"
164+
# One or more files in the crate's source used as the "source of truth" for
165+
# the license expression. If the contents match, the clarification will be used
166+
# when running the license check, otherwise the clarification will be ignored
167+
# and the crate will be checked normally, which may produce warnings or errors
168+
# depending on the rest of your configuration
169+
#license-files = [
170+
# Each entry is a crate relative path, and the (opaque) hash of its contents
171+
#{ path = "LICENSE", hash = 0xbd0eed23 }
172+
#]
173+
174+
[[licenses.clarify]]
175+
name = "ring"
176+
version = "*"
177+
expression = "MIT AND ISC AND OpenSSL"
178+
license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }]
179+
180+
[licenses.private]
181+
# If true, ignores workspace crates that aren't published, or are only
182+
# published to private registries.
183+
# To see how to mark a crate as unpublished (to the official registry),
184+
# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field.
185+
ignore = false
186+
# One or more private registries that you might publish crates to, if a crate
187+
# is only published to private registries, and ignore is true, the crate will
188+
# not have its license(s) checked
189+
registries = [
190+
#"https://sekretz.com/registry
191+
]
192+
193+
# This section is considered when running `cargo deny check bans`.
194+
# More documentation about the 'bans' section can be found here:
195+
# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
196+
[bans]
197+
# Lint level for when multiple versions of the same crate are detected
198+
multiple-versions = "allow"
199+
# Lint level for when a crate version requirement is `*`
200+
wildcards = "allow"
201+
# The graph highlighting used when creating dotgraphs for crates
202+
# with multiple versions
203+
# * lowest-version - The path to the lowest versioned duplicate is highlighted
204+
# * simplest-path - The path to the version with the fewest edges is highlighted
205+
# * all - Both lowest-version and simplest-path are used
206+
highlight = "all"
207+
# The default lint level for `default` features for crates that are members of
208+
# the workspace that is being checked. This can be overriden by allowing/denying
209+
# `default` on a crate-by-crate basis if desired.
210+
workspace-default-features = "allow"
211+
# The default lint level for `default` features for external crates that are not
212+
# members of the workspace. This can be overriden by allowing/denying `default`
213+
# on a crate-by-crate basis if desired.
214+
external-default-features = "allow"
215+
# List of crates that are allowed. Use with care!
216+
allow = [
217+
#{ name = "ansi_term", version = "=0.11.0" },
218+
]
219+
# List of crates to deny
220+
deny = [
221+
# Each entry the name of a crate and a version range. If version is
222+
# not specified, all versions will be matched.
223+
#{ name = "ansi_term", version = "=0.11.0" },
224+
#
225+
# Wrapper crates can optionally be specified to allow the crate when it
226+
# is a direct dependency of the otherwise banned crate
227+
#{ name = "ansi_term", version = "=0.11.0", wrappers = [] },
228+
]
229+
230+
# List of features to allow/deny
231+
# Each entry the name of a crate and a version range. If version is
232+
# not specified, all versions will be matched.
233+
#[[bans.features]]
234+
#name = "reqwest"
235+
# Features to not allow
236+
#deny = ["json"]
237+
# Features to allow
238+
#allow = [
239+
# "rustls",
240+
# "__rustls",
241+
# "__tls",
242+
# "hyper-rustls",
243+
# "rustls",
244+
# "rustls-pemfile",
245+
# "rustls-tls-webpki-roots",
246+
# "tokio-rustls",
247+
# "webpki-roots",
248+
#]
249+
# If true, the allowed features must exactly match the enabled feature set. If
250+
# this is set there is no point setting `deny`
251+
#exact = true
252+
253+
# Certain crates/versions that will be skipped when doing duplicate detection.
254+
skip = [
255+
#{ name = "ansi_term", version = "=0.11.0" },
256+
]
257+
# Similarly to `skip` allows you to skip certain crates during duplicate
258+
# detection. Unlike skip, it also includes the entire tree of transitive
259+
# dependencies starting at the specified crate, up to a certain depth, which is
260+
# by default infinite.
261+
skip-tree = [
262+
#{ name = "ansi_term", version = "=0.11.0", depth = 20 },
263+
]
264+
265+
# This section is considered when running `cargo deny check sources`.
266+
# More documentation about the 'sources' section can be found here:
267+
# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html
268+
[sources]
269+
# Lint level for what to happen when a crate from a crate registry that is not
270+
# in the allow list is encountered
271+
unknown-registry = "warn"
272+
# Lint level for what to happen when a crate from a git repository that is not
273+
# in the allow list is encountered
274+
unknown-git = "warn"
275+
# List of URLs for allowed crate registries. Defaults to the crates.io index
276+
# if not specified. If it is specified but empty, no registries are allowed.
277+
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
278+
# List of URLs for allowed Git repositories
279+
allow-git = []
280+
281+
[sources.allow-org]
282+
# 1 or more github.com organizations to allow git sources for
283+
#github = [""]
284+
# 1 or more gitlab.com organizations to allow git sources for
285+
#gitlab = [""]
286+
# 1 or more bitbucket.org organizations to allow git sources for
287+
#bitbucket = [""]

0 commit comments

Comments
 (0)