Repository navigation
88 lines (84 loc) · 2.53 KB
/
Copy pathtrivy.yml
File metadata and controls
88 lines (84 loc) · 2.53 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
name: Check vulnerabilities
on:
push:
paths-ignore:
- '**.md'
pull_request:
branches:
- full-refactor
paths-ignore:
- '!**.md'
release:
types:
- released
schedule:
- cron: '0 8 * * *' # runs daily at 8h UTC
workflow_dispatch:
permissions:
contents: write
jobs:
vulnerabilities:
runs-on: ubuntu-24.04
defaults:
run:
working-directory: .
steps:
- name: Checkout repository
uses: actions/checkout@master
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install
- name: Scan vulnerabilities with trivy
uses: aquasecurity/trivy-action@v0.36.0
with:
scan-type: fs
trivy-config: .github/trivy-config.yaml
exit-code: 1
ignore-unfixed: true
severity: CRITICAL,HIGH
scanners: vuln,misconfig,secret
scan-ref: .
- name: Generate SPDX SBOM with trivy
uses: aquasecurity/trivy-action@v0.36.0
with:
scan-type: fs
trivy-config: .github/trivy-config.yaml
scan-ref: .
format: spdx-json
output: sbom.spdx.json
- name: Generate SPDX SBOM (Markdown) with trivy
uses: aquasecurity/trivy-action@v0.36.0
with:
scan-type: fs
trivy-config: .github/trivy-config.yaml
scan-ref: .
format: template
template: '@.github/workflows/templates/sbom-md.tpl'
output: sbom.spdx.md
- name: Upload SBOM artifacts
uses: actions/upload-artifact@v4
with:
name: sbom
path: sbom.spdx.*
retention-days: 30
- name: Normalize SBOM timestamp
if: github.event_name == 'push' && github.ref == 'refs/heads/full-refactor'
run: |
# SPDX records a generation timestamp; pin it so consecutive runs
# produce byte-identical SBOMs and the commit below is idempotent.
sed -i -E 's/"created": "[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9:.Z-]+"/"created": "0000-00-00T00:00:00Z"/' sbom.spdx.json
- name: Commit SBOM to repository
if: github.event_name == 'push' && github.ref == 'refs/heads/full-refactor'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add sbom.spdx.json sbom.spdx.md
if git diff --cached --quiet; then
echo "SBOM unchanged, nothing to commit"
exit 0
fi
git commit -m "Update SPDX SBOM"
git push origin HEAD