Skip to content

Commit 959ebb7

Browse files
authored
RUST-690 Run cargo deny via evergreen (#643)
1 parent 39454c8 commit 959ebb7

File tree

5 files changed

+237
-1
lines changed

5 files changed

+237
-1
lines changed

.evergreen/check-all.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ EVERGREEN_DIR=".evergreen"
88
bash "${EVERGREEN_DIR}/check-clippy.sh"
99
bash "${EVERGREEN_DIR}/check-rustdoc.sh"
1010
bash "${EVERGREEN_DIR}/check-rustfmt.sh"
11+
bash "${EVERGREEN_DIR}/check-cargo-deny.sh"

.evergreen/check-cargo-deny.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
5+
. ~/.cargo/env
6+
7+
cargo install --locked cargo-deny
8+
cargo deny --all-features check

.evergreen/config.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,16 @@ functions:
541541
${PREPARE_SHELL}
542542
ASYNC_RUNTIME=${ASYNC_RUNTIME} RUST_VERSION=${RUST_VERSION} .evergreen/compile-only.sh
543543
544+
"check cargo deny":
545+
- command: shell.exec
546+
type: test
547+
params:
548+
shell: bash
549+
working_dir: "src"
550+
script: |
551+
${PREPARE_SHELL}
552+
.evergreen/check-cargo-deny.sh
553+
544554
"check rustfmt":
545555
- command: shell.exec
546556
type: test
@@ -1284,6 +1294,10 @@ tasks:
12841294
commands:
12851295
- func: "compile only"
12861296

1297+
- name: "check-cargo-deny"
1298+
commands:
1299+
- func: "check cargo deny"
1300+
12871301
- name: "check-rustfmt"
12881302
commands:
12891303
- func: "check rustfmt"
@@ -1697,4 +1711,5 @@ buildvariants:
16971711
- name: "check-rustfmt"
16981712
- name: "check-rustdoc"
16991713
- name: "check-manual"
1714+
- name: "check-cargo-deny"
17001715

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ features = ["v4"]
138138
[dev-dependencies]
139139
approx = "0.5.1"
140140
derive_more = "0.99.13"
141-
function_name = "0.2.0"
141+
function_name = "0.2.1"
142142
futures = "0.3"
143143
home = "0.5"
144144
pretty_assertions = "1.1.0"

deny.toml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
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+
# If 1 or more target triples (and optionally, target_features) are specified,
13+
# only the specified targets will be checked when running `cargo deny check`.
14+
# This means, if a particular package is only ever used as a target specific
15+
# dependency, such as, for example, the `nix` crate only being used via the
16+
# `target_family = "unix"` configuration, that only having windows targets in
17+
# this list would mean the nix crate, as well as any of its exclusive
18+
# dependencies not shared by any other crates, would be ignored, as the target
19+
# list here is effectively saying which targets you are building for.
20+
targets = [
21+
# The triple can be any string, but only the target triples built in to
22+
# rustc (as of 1.40) can be checked against actual config expressions
23+
#{ triple = "x86_64-unknown-linux-musl" },
24+
# You can also specify which target_features you promise are enabled for a
25+
# particular target. target_features are currently not validated against
26+
# the actual valid features supported by the target architecture.
27+
#{ triple = "wasm32-unknown-unknown", features = ["atomics"] },
28+
]
29+
30+
# This section is considered when running `cargo deny check advisories`
31+
# More documentation for the advisories section can be found here:
32+
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
33+
[advisories]
34+
# The path where the advisory database is cloned/fetched into
35+
# db-path = "~/.cargo/advisory-db"
36+
# The url(s) of the advisory databases to use
37+
db-urls = ["https://github.com/rustsec/advisory-db"]
38+
# The lint level for security vulnerabilities
39+
vulnerability = "deny"
40+
# The lint level for unmaintained crates
41+
unmaintained = "deny"
42+
# The lint level for crates that have been yanked from their source registry
43+
yanked = "deny"
44+
# The lint level for crates with security notices. Note that as of
45+
# 2019-12-17 there are no security notice advisories in
46+
# https://github.com/rustsec/advisory-db
47+
notice = "deny"
48+
# A list of advisory IDs to ignore. Note that ignored advisories will still
49+
# output a note when they are encountered.
50+
ignore = [
51+
# TODO RUST-1293
52+
"RUSTSEC-2020-0159",
53+
# TODO RUST-1293
54+
"RUSTSEC-2020-0071",
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+
# This section is considered when running `cargo deny check licenses`
67+
# More documentation for the licenses section can be found here:
68+
# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html
69+
[licenses]
70+
# The lint level for crates which do not have a detectable license
71+
unlicensed = "deny"
72+
# List of explicitly allowed licenses
73+
# See https://spdx.org/licenses/ for list of possible licenses
74+
# [possible values: any SPDX 3.11 short identifier (+ optional exception)].
75+
allow = [
76+
"MIT",
77+
"Apache-2.0",
78+
"Apache-2.0 WITH LLVM-exception",
79+
"ISC",
80+
"OpenSSL",
81+
"BSD-3-Clause",
82+
"MPL-2.0",
83+
]
84+
# List of explicitly disallowed licenses
85+
# See https://spdx.org/licenses/ for list of possible licenses
86+
# [possible values: any SPDX 3.11 short identifier (+ optional exception)].
87+
deny = [
88+
#"Nokia",
89+
]
90+
# Lint level for licenses considered copyleft
91+
copyleft = "deny"
92+
# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses
93+
# * both - The license will be approved if it is both OSI-approved *AND* FSF
94+
# * either - The license will be approved if it is either OSI-approved *OR* FSF
95+
# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF
96+
# * fsf-only - The license will be approved if is FSF *AND NOT* OSI-approved
97+
# * neither - This predicate is ignored and the default lint level is used
98+
allow-osi-fsf-free = "neither"
99+
# Lint level used when no other predicates are matched
100+
# 1. License isn't in the allow or deny lists
101+
# 2. License isn't copyleft
102+
# 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither"
103+
default = "deny"
104+
# The confidence threshold for detecting a license from license text.
105+
# The higher the value, the more closely the license text must be to the
106+
# canonical license text of a valid SPDX license file.
107+
# [possible values: any between 0.0 and 1.0].
108+
confidence-threshold = 0.8
109+
# Allow 1 or more licenses on a per-crate basis, so that particular licenses
110+
# aren't accepted for every possible crate as with the normal allow list
111+
exceptions = [
112+
# Each entry is the crate and version constraint, and its specific allow
113+
# list
114+
#{ allow = ["Zlib"], name = "adler32", version = "*" },
115+
]
116+
117+
# Some crates don't have (easily) machine readable licensing information,
118+
# adding a clarification entry for it allows you to manually specify the
119+
# licensing information
120+
[[licenses.clarify]]
121+
# The name of the crate the clarification applies to
122+
name = "ring"
123+
# The optional version constraint for the crate
124+
version = "*"
125+
# The SPDX expression for the license requirements of the crate
126+
expression = "MIT AND ISC AND OpenSSL"
127+
# One or more files in the crate's source used as the "source of truth" for
128+
# the license expression. If the contents match, the clarification will be used
129+
# when running the license check, otherwise the clarification will be ignored
130+
# and the crate will be checked normally, which may produce warnings or errors
131+
# depending on the rest of your configuration
132+
license-files = [
133+
# Each entry is a crate relative path, and the (opaque) hash of its contents
134+
{ path = "LICENSE", hash = 0xbd0eed23 }
135+
]
136+
137+
[licenses.private]
138+
# If true, ignores workspace crates that aren't published, or are only
139+
# published to private registries.
140+
# To see how to mark a crate as unpublished (to the official registry),
141+
# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field.
142+
ignore = false
143+
# One or more private registries that you might publish crates to, if a crate
144+
# is only published to private registries, and ignore is true, the crate will
145+
# not have its license(s) checked
146+
registries = [
147+
#"https://sekretz.com/registry
148+
]
149+
150+
# This section is considered when running `cargo deny check bans`.
151+
# More documentation about the 'bans' section can be found here:
152+
# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
153+
[bans]
154+
# Lint level for when multiple versions of the same crate are detected
155+
multiple-versions = "allow"
156+
# Lint level for when a crate version requirement is `*`
157+
wildcards = "allow"
158+
# The graph highlighting used when creating dotgraphs for crates
159+
# with multiple versions
160+
# * lowest-version - The path to the lowest versioned duplicate is highlighted
161+
# * simplest-path - The path to the version with the fewest edges is highlighted
162+
# * all - Both lowest-version and simplest-path are used
163+
highlight = "all"
164+
# List of crates that are allowed. Use with care!
165+
allow = [
166+
#{ name = "ansi_term", version = "=0.11.0" },
167+
]
168+
# List of crates to deny
169+
deny = [
170+
# Each entry the name of a crate and a version range. If version is
171+
# not specified, all versions will be matched.
172+
#{ name = "ansi_term", version = "=0.11.0" },
173+
#
174+
# Wrapper crates can optionally be specified to allow the crate when it
175+
# is a direct dependency of the otherwise banned crate
176+
#{ name = "ansi_term", version = "=0.11.0", wrappers = [] },
177+
]
178+
# Certain crates/versions that will be skipped when doing duplicate detection.
179+
skip = [
180+
#{ name = "ansi_term", version = "=0.11.0" },
181+
]
182+
# Similarly to `skip` allows you to skip certain crates during duplicate
183+
# detection. Unlike skip, it also includes the entire tree of transitive
184+
# dependencies starting at the specified crate, up to a certain depth, which is
185+
# by default infinite
186+
skip-tree = [
187+
#{ name = "ansi_term", version = "=0.11.0", depth = 20 },
188+
]
189+
190+
# This section is considered when running `cargo deny check sources`.
191+
# More documentation about the 'sources' section can be found here:
192+
# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html
193+
[sources]
194+
# Lint level for what to happen when a crate from a crate registry that is not
195+
# in the allow list is encountered
196+
unknown-registry = "deny"
197+
# Lint level for what to happen when a crate from a git repository that is not
198+
# in the allow list is encountered
199+
unknown-git = "deny"
200+
# List of URLs for allowed crate registries. Defaults to the crates.io index
201+
# if not specified. If it is specified but empty, no registries are allowed.
202+
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
203+
# List of URLs for allowed Git repositories
204+
allow-git = ["https://github.com/mongodb/bson-rust"]
205+
206+
[sources.allow-org]
207+
# 1 or more github.com organizations to allow git sources for
208+
# github = [""]
209+
# 1 or more gitlab.com organizations to allow git sources for
210+
# gitlab = [""]
211+
# 1 or more bitbucket.org organizations to allow git sources for
212+
# bitbucket = [""]

0 commit comments

Comments
 (0)