3434 - name : Install Rust
3535 uses : dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
3636 with :
37- toolchain : stable
37+ toolchain : 1.89
3838
3939 - name : Cache cargo registry
4040 uses : Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
4444 - name : Install cargo-audit
4545 uses : taiki-e/install-action@v2
4646 with :
47- tool : cargo-audit@0.20.5
47+ tool : cargo-audit@0.21.2
4848
4949 - name : Run security audit
5050 run : cargo audit --deny warnings
51-
52- - name : Run audit and generate SARIF
53- run : cargo audit --json | python3 -c "
54- import sys, json
55- sarif = {
56- ' version ' : ' 2.1.0' ,
57- ' runs ' : [{
58- ' tool ' : {'driver': {'name': 'cargo-audit', 'informationUri': 'https://rustsec.org/'}},
59- ' results ' : []
60- }]
61- }
62- try :
63- data = json.load(sys.stdin)
64- for vuln in data.get('vulnerabilities', {}).get('list', []) :
65- sarif['runs'][0]['results'].append({
66- ' ruleId ' : vuln['advisory']['id'],
67- ' level ' : ' error' if vuln['advisory'].get('cvss') and float(vuln['advisory']['cvss'].split('/')[0].split(':')[-1]) >= 7 else 'warning',
68- ' message ' : {'text': vuln['advisory']['title']},
69- ' locations ' : [{'physicalLocation': {'artifactLocation': {'uri': 'Cargo.lock'}}}]
70- })
71- except : pass
72- print(json.dumps(sarif))
73- " > audit.sarif || echo '{" version":"2.1.0","runs":[{"tool":{"driver":{"name":"cargo-audit"}},"results":[]}]}' > audit.sarif
74-
75- - name : Upload audit results to GitHub Security
76- if : always()
77- uses : github/codeql-action/upload-sarif@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f2 # v3.27.4
78- with :
79- sarif_file : audit.sarif
80- category : dependency-audit
81-
82- cargo-deny :
83- name : Dependency Check
84- runs-on : ubuntu-latest
85- steps :
86- - name : Checkout code
87- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
88-
89- - name : Run cargo-deny
90- uses : EmbarkStudios/cargo-deny-action@8371184bd11e21dcf8ac82ebf8c9c9f74ebf7268 # v2.0.3
91- with :
92- command : check
93- arguments : --all-features
9451
95- dependency-review :
96- name : Dependency Review
97- runs-on : ubuntu-latest
98- if : github.event_name == 'pull_request'
99- steps :
100- - name : Checkout code
101- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
102-
103- - name : Dependency Review
104- uses : actions/dependency-review-action@a6993e2c61fd5dc440b409aa1d6904921c5e1894 # v5.0.0
105- with :
106- fail-on-severity : high
107- deny-licenses : GPL-3.0, AGPL-3.0
0 commit comments