Skip to content

Commit 8af1885

Browse files
committed
chore(ci): Use cargo-deny
1 parent 006acf7 commit 8af1885

File tree

2 files changed

+189
-0
lines changed

2 files changed

+189
-0
lines changed

.github/workflows/audit.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Security audit
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
pull_request:
8+
paths:
9+
- '**/Cargo.toml'
10+
- '**/Cargo.lock'
11+
push:
12+
branches:
13+
- master
14+
15+
env:
16+
RUST_BACKTRACE: 1
17+
CARGO_TERM_COLOR: always
18+
CLICOLOR: 1
19+
20+
jobs:
21+
security_audit:
22+
permissions:
23+
issues: write # to create issues (actions-rs/audit-check)
24+
checks: write # to create check (actions-rs/audit-check)
25+
runs-on: ubuntu-latest
26+
# Prevent sudden announcement of a new advisory from failing ci:
27+
continue-on-error: true
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
- uses: actions-rs/audit-check@v1
32+
with:
33+
token: ${{ secrets.GITHUB_TOKEN }}
34+
35+
cargo_deny:
36+
permissions:
37+
issues: write # to create issues (actions-rs/audit-check)
38+
checks: write # to create check (actions-rs/audit-check)
39+
runs-on: ubuntu-latest
40+
strategy:
41+
matrix:
42+
checks:
43+
- bans licenses sources
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: EmbarkStudios/cargo-deny-action@v1
47+
with:
48+
command: check ${{ matrix.checks }}
49+
rust-version: stable

deny.toml

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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+
# This section is considered when running `cargo deny check advisories`
8+
# More documentation for the advisories section can be found here:
9+
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
10+
[advisories]
11+
# The lint level for security vulnerabilities
12+
vulnerability = "deny"
13+
# The lint level for unmaintained crates
14+
unmaintained = "warn"
15+
# The lint level for crates that have been yanked from their source registry
16+
yanked = "warn"
17+
# The lint level for crates with security notices. Note that as of
18+
# 2019-12-17 there are no security notice advisories in
19+
# https://github.com/rustsec/advisory-db
20+
notice = "warn"
21+
# A list of advisory IDs to ignore. Note that ignored advisories will still
22+
# output a note when they are encountered.
23+
#
24+
# e.g. "RUSTSEC-0000-0000",
25+
ignore = [
26+
]
27+
28+
# This section is considered when running `cargo deny check licenses`
29+
# More documentation for the licenses section can be found here:
30+
# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html
31+
[licenses]
32+
unlicensed = "deny"
33+
# List of explicitly allowed licenses
34+
# See https://spdx.org/licenses/ for list of possible licenses
35+
# [possible values: any SPDX 3.11 short identifier (+ optional exception)].
36+
allow = [
37+
"MIT",
38+
"MIT-0",
39+
"Apache-2.0",
40+
"BSD-3-Clause",
41+
"MPL-2.0",
42+
"Unicode-DFS-2016",
43+
"CC0-1.0",
44+
"ISC",
45+
]
46+
# List of explicitly disallowed licenses
47+
# See https://spdx.org/licenses/ for list of possible licenses
48+
# [possible values: any SPDX 3.11 short identifier (+ optional exception)].
49+
deny = [
50+
]
51+
# Lint level for licenses considered copyleft
52+
copyleft = "deny"
53+
# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses
54+
# * both - The license will be approved if it is both OSI-approved *AND* FSF
55+
# * either - The license will be approved if it is either OSI-approved *OR* FSF
56+
# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF
57+
# * fsf-only - The license will be approved if is FSF *AND NOT* OSI-approved
58+
# * neither - This predicate is ignored and the default lint level is used
59+
allow-osi-fsf-free = "neither"
60+
# Lint level used when no other predicates are matched
61+
# 1. License isn't in the allow or deny lists
62+
# 2. License isn't copyleft
63+
# 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither"
64+
default = "deny"
65+
# The confidence threshold for detecting a license from license text.
66+
# The higher the value, the more closely the license text must be to the
67+
# canonical license text of a valid SPDX license file.
68+
# [possible values: any between 0.0 and 1.0].
69+
confidence-threshold = 0.8
70+
# Allow 1 or more licenses on a per-crate basis, so that particular licenses
71+
# aren't accepted for every possible crate as with the normal allow list
72+
exceptions = [
73+
# Each entry is the crate and version constraint, and its specific allow
74+
# list
75+
#{ allow = ["Zlib"], name = "adler32", version = "*" },
76+
]
77+
78+
[licenses.private]
79+
# If true, ignores workspace crates that aren't published, or are only
80+
# published to private registries.
81+
# To see how to mark a crate as unpublished (to the official registry),
82+
# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field.
83+
ignore = true
84+
85+
# This section is considered when running `cargo deny check bans`.
86+
# More documentation about the 'bans' section can be found here:
87+
# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
88+
[bans]
89+
# Lint level for when multiple versions of the same crate are detected
90+
multiple-versions = "warn"
91+
# Lint level for when a crate version requirement is `*`
92+
wildcards = "warn"
93+
# The graph highlighting used when creating dotgraphs for crates
94+
# with multiple versions
95+
# * lowest-version - The path to the lowest versioned duplicate is highlighted
96+
# * simplest-path - The path to the version with the fewest edges is highlighted
97+
# * all - Both lowest-version and simplest-path are used
98+
highlight = "all"
99+
# The default lint level for `default` features for crates that are members of
100+
# the workspace that is being checked. This can be overridden by allowing/denying
101+
# `default` on a crate-by-crate basis if desired.
102+
workspace-default-features = "allow"
103+
# The default lint level for `default` features for external crates that are not
104+
# members of the workspace. This can be overridden by allowing/denying `default`
105+
# on a crate-by-crate basis if desired.
106+
external-default-features = "allow"
107+
# List of crates that are allowed. Use with care!
108+
allow = [
109+
#{ name = "ansi_term", version = "=0.11.0" },
110+
]
111+
# List of crates to deny
112+
deny = [
113+
# Each entry the name of a crate and a version range. If version is
114+
# not specified, all versions will be matched.
115+
#{ name = "ansi_term", version = "=0.11.0" },
116+
#
117+
# Wrapper crates can optionally be specified to allow the crate when it
118+
# is a direct dependency of the otherwise banned crate
119+
#{ name = "ansi_term", version = "=0.11.0", wrappers = [] },
120+
]
121+
122+
# This section is considered when running `cargo deny check sources`.
123+
# More documentation about the 'sources' section can be found here:
124+
# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html
125+
[sources]
126+
# Lint level for what to happen when a crate from a crate registry that is not
127+
# in the allow list is encountered
128+
unknown-registry = "deny"
129+
# Lint level for what to happen when a crate from a git repository that is not
130+
# in the allow list is encountered
131+
unknown-git = "deny"
132+
# List of URLs for allowed crate registries. Defaults to the crates.io index
133+
# if not specified. If it is specified but empty, no registries are allowed.
134+
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
135+
# List of URLs for allowed Git repositories
136+
allow-git = []
137+
138+
[sources.allow-org]
139+
# 1 or more github.com organizations to allow git sources for
140+
github = []

0 commit comments

Comments
 (0)