Skip to content

Commit a41523d

Browse files
committed
ci: migrate dependency auditing from cargo-audit to cargo-deny
1 parent feffd26 commit a41523d

2 files changed

Lines changed: 99 additions & 0 deletions

File tree

‎.github/workflows/audit.yml‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Security Audit
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- '**/Cargo.toml'
9+
- '**/Cargo.lock'
10+
- 'deny.toml'
11+
- '.github/workflows/audit.yml'
12+
pull_request:
13+
paths:
14+
- '**/Cargo.toml'
15+
- '**/Cargo.lock'
16+
- 'deny.toml'
17+
- '.github/workflows/audit.yml'
18+
schedule:
19+
# 每周一 09:17 UTC(北京时间 17:17)
20+
- cron: '17 9 * * 1'
21+
workflow_dispatch: # 支持手动触发
22+
23+
concurrency:
24+
group: audit-${{ github.workflow }}-${{ github.ref }}
25+
cancel-in-progress: true
26+
27+
permissions:
28+
contents: read
29+
30+
jobs:
31+
rust-deny:
32+
name: Rust dependency check (cargo-deny)
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v6
36+
37+
- name: Install cargo-deny
38+
uses: taiki-e/install-action@v2
39+
with:
40+
tool: cargo-deny@0.22.0
41+
42+
- name: Run cargo deny
43+
run: cargo deny check

‎deny.toml‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# cargo-deny 配置:Rust 依赖审计统一入口(licenses + bans + advisories + sources)
2+
# 组织级统一;AsterDrive 同款基线(GPL 一律不放行)。
3+
4+
[graph]
5+
all-features = false
6+
no-default-features = false
7+
8+
[output]
9+
feature-depth = 1
10+
11+
[advisories]
12+
# 仅列当前依赖树真实命中的上游例外;包含无兼容修复的残留风险,
13+
# 不表示漏洞已经修复。上游发版后立即移除对应条目并刷新 Cargo.lock。
14+
ignore = []
15+
16+
[licenses]
17+
allow = [
18+
"MIT",
19+
"Apache-2.0",
20+
"BSD-1-Clause",
21+
"BSD-2-Clause",
22+
"BSD-3-Clause",
23+
"ISC",
24+
"Unicode-3.0",
25+
"Unlicense",
26+
"MIT-0",
27+
"Zlib",
28+
"BSL-1.0",
29+
"CC0-1.0",
30+
"0BSD",
31+
# option-ext;MPL-2.0 是文件级 copyleft,链接不受传染
32+
"MPL-2.0",
33+
]
34+
confidence-threshold = 0.8
35+
exceptions = [
36+
# Mozilla 根证书数据(Mozilla CA 证书库),仅数据非代码
37+
{ allow = ["CDLA-Permissive-2.0"], crate = "webpki-root-certs" },
38+
# 仅在 UEFI target 下被 getrandom 引用,实际分发目标(容器/服务器二进制)不编译
39+
{ allow = ["LGPL-2.1-or-later"], crate = "r-efi" },
40+
]
41+
42+
[licenses.private]
43+
ignore = false
44+
45+
[bans]
46+
multiple-versions = "warn"
47+
wildcards = "allow"
48+
49+
[sources]
50+
unknown-registry = "warn"
51+
unknown-git = "warn"
52+
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
53+
allow-git = []
54+
55+
[sources.allow-org]
56+
github = ["AsterCommunity"]

0 commit comments

Comments
 (0)