Repository navigation
64 lines (59 loc) · 2.31 KB
/
Copy pathsecurity.yml
File metadata and controls
64 lines (59 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Security
# The daily schedule is the important part: advisories get published against
# dependencies that are already pinned, so a push-only workflow would never
# notice them. RUSTSEC-2026-0220 (ruint, EVM integer shift bugs) sat in the tree
# undetected precisely because nothing ran on a timer.
on:
push:
branches: [main]
pull_request:
schedule:
- cron: '17 6 * * *'
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
cargo-deny:
name: cargo-deny (${{ matrix.checks }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Split so an advisory failure is distinguishable at a glance from a
# license or sourcing failure.
checks:
- advisories
- bans licenses sources
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check ${{ matrix.checks }}
lockfile:
name: Lockfile is current and complete
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
# --locked fails if Cargo.lock would need to change to build. This catches
# a manifest edit that was committed without the corresponding lockfile
# update, which would otherwise let CI resolve fresh (unreviewed) versions.
- name: Verify Cargo.lock matches the manifests
run: cargo metadata --locked --format-version 1 > /dev/null
# Every dependency must carry a checksum. A source without one is not
# content-verified, and is how a non-crates.io dependency would sneak in.
- name: Verify every dependency is checksummed
run: |
pkgs=$(grep -c '^\[\[package\]\]' Cargo.lock)
sums=$(grep -c '^checksum = ' Cargo.lock)
members=$(cargo metadata --locked --no-deps --format-version 1 \
| grep -o '"name":"rustock-[a-z-]*"' | sort -u | wc -l)
echo "packages=$pkgs checksummed=$sums workspace_members=$members"
if [ "$((pkgs - sums))" -ne "$members" ]; then
echo "::error::Unchecksummed dependencies found outside the workspace."
awk '/^\[\[package\]\]/{n="";s=""} /^name = /{n=$0} /^checksum = /{s=1} \
/^$/{if(n!="" && s=="") print n}' Cargo.lock
exit 1
fi