-
Notifications
You must be signed in to change notification settings - Fork 33
150 lines (129 loc) · 4.69 KB
/
Copy pathdependency-scan.yml
File metadata and controls
150 lines (129 loc) · 4.69 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Dependency Vulnerability Scan
on:
pull_request:
branches:
- main
push:
branches:
- main
schedule:
# Weekly scan so maintainers are notified of newly published advisories
- cron: "0 8 * * 1"
workflow_dispatch:
permissions:
contents: read
jobs:
frontend-dependency-scan:
name: Frontend Dependency Scan
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
# Pin to packageManager in frontend/package.json; pnpm 11+ needs Node ≥22
version: "10.26.1"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run pnpm audit and generate reports
id: frontend_audit
run: |
mkdir -p ../reports/dependency-scan
set +e
pnpm audit --json > ../reports/dependency-scan/frontend-pnpm-audit.json 2> ../reports/dependency-scan/frontend-pnpm-audit.stderr.txt
pnpm audit > ../reports/dependency-scan/frontend-pnpm-audit.txt 2>&1
AUDIT_EXIT=$?
set -e
{
echo "## Frontend dependency vulnerability scan"
echo ""
echo "- Scanner: \`pnpm audit\`"
echo "- Exit code: \`${AUDIT_EXIT}\`"
echo "- Reports: \`frontend-pnpm-audit.json\`, \`frontend-pnpm-audit.txt\`"
echo ""
if [ "${AUDIT_EXIT}" -ne 0 ]; then
echo "> Vulnerabilities were reported. Review the uploaded artifacts and Dependabot PRs."
else
echo "> No vulnerabilities reported by \`pnpm audit\`."
fi
echo ""
echo "### Summary (tail)"
echo ""
echo '```'
tail -n 40 ../reports/dependency-scan/frontend-pnpm-audit.txt || true
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
# Scanner must produce reports; advisory findings do not fail the job.
test -s ../reports/dependency-scan/frontend-pnpm-audit.txt
test -s ../reports/dependency-scan/frontend-pnpm-audit.json
- name: Upload frontend dependency scan reports
uses: actions/upload-artifact@v4
with:
name: frontend-dependency-scan-reports
path: reports/dependency-scan/frontend-*
if-no-files-found: error
retention-days: 30
contract-dependency-scan:
name: Contract Dependency Scan
runs-on: ubuntu-latest
defaults:
run:
working-directory: contract
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install cargo-audit
uses: taiki-e/install-action@v2
with:
tool: cargo-audit
- name: Run cargo audit and generate reports
id: contract_audit
run: |
mkdir -p ../reports/dependency-scan
set +e
cargo audit --json > ../reports/dependency-scan/contract-cargo-audit.json 2> ../reports/dependency-scan/contract-cargo-audit.stderr.txt
cargo audit > ../reports/dependency-scan/contract-cargo-audit.txt 2>&1
AUDIT_EXIT=$?
set -e
{
echo "## Contract dependency vulnerability scan"
echo ""
echo "- Scanner: \`cargo audit\`"
echo "- Exit code: \`${AUDIT_EXIT}\`"
echo "- Reports: \`contract-cargo-audit.json\`, \`contract-cargo-audit.txt\`"
echo ""
if [ "${AUDIT_EXIT}" -ne 0 ]; then
echo "> Vulnerabilities or warnings were reported. Review the uploaded artifacts and Dependabot PRs."
else
echo "> No vulnerabilities reported by \`cargo audit\`."
fi
echo ""
echo "### Summary"
echo ""
echo '```'
cat ../reports/dependency-scan/contract-cargo-audit.txt || true
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
# Scanner must produce reports; advisory findings do not fail the job.
test -s ../reports/dependency-scan/contract-cargo-audit.txt
test -s ../reports/dependency-scan/contract-cargo-audit.json
- name: Upload contract dependency scan reports
uses: actions/upload-artifact@v4
with:
name: contract-dependency-scan-reports
path: reports/dependency-scan/contract-*
if-no-files-found: error
retention-days: 30