diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 00000000..109f3302 --- /dev/null +++ b/.github/workflows/audit.yml @@ -0,0 +1,40 @@ +# 依赖有没有安全公告(RustSec)。配置在仓库根目录的 deny.toml。 +# +# 插件跑在 Wasmtime 的沙箱里,沙箱的安全就是 Wasmtime 的安全,而它几乎每个 +# 大版本都有公告。别的依赖(rustls、hyper……)同理。 +# +# **两条触发,各管一件事。** +# - 改了依赖的 PR、推到 main:这次引入或升级的 crate 有没有公告。只在依赖 +# 文件变了的时候跑 —— 否则一条新公告发布出来,所有不相干的 PR 一起红, +# 而和自己的改动无关的红,看几次就没人看了。 +# - 每天定时:依赖没动,公告库却在长。新公告落在已有的依赖上,在这里红, +# 失败的通知照常发。 +name: Audit + +on: + pull_request: + paths: + - "**/Cargo.toml" + - "Cargo.lock" + - "deny.toml" + - ".github/workflows/audit.yml" + push: + branches: [main] + paths: + - "**/Cargo.toml" + - "Cargo.lock" + - "deny.toml" + - ".github/workflows/audit.yml" + schedule: + - cron: "0 2 * * *" + workflow_dispatch: + +jobs: + advisories: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # 只查公告。许可证、重复版本这几项是另一回事,不在这里 + - uses: EmbarkStudios/cargo-deny-action@v2 + with: + command: check advisories diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5f41ce55..3e93c0b8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,6 +67,12 @@ The toolchain is `stable`, so a newer stable than your local one can surface lints you cannot reproduce — `rustup update stable` before blaming CI. +A change to a `Cargo.toml` or to `Cargo.lock` also runs the Audit +workflow: `cargo deny check advisories`, configured in `deny.toml`, fails +on any RustSec advisory against a crate in the lock file. It runs daily +on `main` as well, so an advisory published against a dependency that is +already shipped turns up without anyone touching the dependencies. + `scripts/smoke.sh` runs the real binary against a real socket and a real data plane, talking to the control plane through `twcore call` (every control connection starts with a Noise handshake, so curl cannot). **It catches what unit tests structurally cannot** — file diff --git a/Cargo.lock b/Cargo.lock index 426e1d7b..3075352b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1980,9 +1980,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.44" +version = "0.23.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6725596c3f2c3a0aef021139e145d4eafe314a6623e4680ca83852b2c67ab2ba" +checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634" dependencies = [ "aws-lc-rs", "log", diff --git a/deny.toml b/deny.toml new file mode 100644 index 00000000..89ab0384 --- /dev/null +++ b/deny.toml @@ -0,0 +1,18 @@ +# 依赖的安全公告(RustSec)。只用 cargo-deny 的 advisories 一项: +# `.github/workflows/audit.yml` 跑 `cargo deny check advisories`。 +# +# 插件沙箱(Wasmtime)是这棵依赖树里最要紧的一环:沙箱的安全就是它的 +# 安全,而它几乎每个大版本都有安全公告。 + +[graph] +# 带上所有 feature:tw-api 的 `ts` 之类默认不开的依赖也要查到 +all-features = true + +[advisories] +version = 2 +# 漏洞类公告一律报错,不能整类关掉。确认不受影响的单条才写进这里, +# 写明理由和复查的时间 +ignore = [] +# 「无人维护」只看我们直接依赖的 crate。传递依赖里的那些我们换不掉, +# 每出一条就红一次只会让人学会忽略这一项 +unmaintained = "workspace"