Skip to content

Commit 6b19b75

Browse files
authored
ci: add-scans (#208)
1 parent 20c875f commit 6b19b75

File tree

2 files changed

+108
-8
lines changed

2 files changed

+108
-8
lines changed

.github/workflows/scans.yml

Lines changed: 102 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,58 @@ jobs:
3131
with:
3232
sarif_file: devskim-results.sarif
3333

34+
dustilock:
35+
permissions:
36+
contents: read
37+
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
41+
42+
- uses: checkmarx/dustilock@9a0cc4fe3da93f7efb38679896c074dc94d60ac6 # v1
43+
44+
gitleaks:
45+
permissions:
46+
contents: write
47+
pull-requests: write
48+
security-events: write
49+
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
53+
with:
54+
fetch-depth: (${{ github.event.pull_request.commits || 2 }} + 1)
55+
56+
- uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2
57+
env:
58+
GITHUB_TOKEN: ${{ github.token }}
59+
60+
- if: ${{ success() || failure() }}
61+
uses: github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3
62+
with:
63+
sarif_file: results.sarif
64+
65+
grype:
66+
permissions:
67+
contents: read
68+
security-events: write
69+
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
73+
74+
- id: grype
75+
uses: anchore/scan-action@7c05671ae9be166aeb155bad2d7df9121823df32 # v6
76+
with:
77+
path: .
78+
severity-cutoff: high
79+
only-fixed: true
80+
81+
- if: ${{ success() || failure() }}
82+
uses: github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3
83+
with:
84+
sarif_file: ${{ steps.grype.outputs.sarif }}
85+
3486
megalinter:
3587
permissions:
3688
contents: write
@@ -104,7 +156,7 @@ jobs:
104156
security-events: write
105157

106158
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
107-
uses: google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@6fc714450122bda9d00e4ad5d639ad6a39eedb1f # v1
159+
uses: google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@6fc714450122bda9d00e4ad5d639ad6a39eedb1f # v2
108160

109161
osv-scan-push:
110162
permissions:
@@ -113,29 +165,72 @@ jobs:
113165
security-events: write
114166

115167
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
116-
uses: google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@6fc714450122bda9d00e4ad5d639ad6a39eedb1f # v1
168+
uses: google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@6fc714450122bda9d00e4ad5d639ad6a39eedb1f # v2
169+
170+
syft:
171+
permissions:
172+
actions: read
173+
contents: write
174+
security-events: write
175+
176+
runs-on: ubuntu-latest
177+
steps:
178+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
179+
180+
- uses: anchore/sbom-action@f325610c9f50a54015d37c8d16cb3b0e2c8f4de0 # v0
181+
with:
182+
output-file: "${{ github.event.repository.name }}-sbom.spdx.json"
183+
dependency-snapshot: true
184+
185+
- id: grype
186+
uses: anchore/scan-action@7c05671ae9be166aeb155bad2d7df9121823df32 # v6
187+
with:
188+
sbom: "${{ github.event.repository.name }}-sbom.spdx.json"
189+
severity-cutoff: high
190+
only-fixed: true
191+
192+
- if: ${{ success() || failure() }}
193+
uses: github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3
194+
with:
195+
sarif_file: ${{ steps.grype.outputs.sarif }}
117196

118197
trivy:
119198
permissions:
120-
contents: read
199+
contents: write
121200
security-events: write
122201

123202
runs-on: ubuntu-latest
124203
steps:
125204
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
126205

127-
- uses: aquasecurity/trivy-action@6c175e9c4083a92bbca2f9724c8a5e33bc2d97a5 # 0.30.0
206+
- uses: aquasecurity/trivy-action@6c175e9c4083a92bbca2f9724c8a5e33bc2d97a5 # 0.30
207+
with:
208+
scan-type: fs
209+
format: github
210+
output: dependency-results.sbom.json
211+
github-pat: ${{ github.token }}
212+
ignore-unfixed: true
213+
severity: HIGH,CRITICAL
214+
215+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
216+
with:
217+
name: trivy-sbom-report
218+
path: "${{ github.workspace }}/dependency-results.sbom.json"
219+
220+
- uses: aquasecurity/trivy-action@6c175e9c4083a92bbca2f9724c8a5e33bc2d97a5 # 0.30
128221
with:
129222
scan-type: fs
130223
exit-code: 1
131224
ignore-unfixed: true
132225
severity: HIGH,CRITICAL
133226
format: sarif
134227
output: trivy-results.sarif
228+
skip-setup-trivy: true
135229

136-
- uses: github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3
230+
- if: ${{ success() || failure() }}
231+
uses: github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3
137232
with:
138-
sarif_file: "trivy-results.sarif"
233+
sarif_file: trivy-results.sarif
139234

140235
trufflehog:
141236
permissions:
@@ -145,7 +240,7 @@ jobs:
145240
steps:
146241
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
147242
with:
148-
fetch-depth: 3
243+
fetch-depth: (${{ github.event.pull_request.commits || 2 }} + 1)
149244

150245
- uses: trufflesecurity/trufflehog@ad258d848807ac956c978b391895800cb4237c1a # v3
151246
with:

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ repos:
6060
hooks:
6161
- id: gitleaks
6262

63+
- repo: https://github.com/trufflesecurity/trufflehog
64+
rev: v3.88.24
65+
hooks:
66+
- id: trufflehog
67+
6368
- repo: https://github.com/rhysd/actionlint
6469
rev: v1.7.7
6570
hooks:
@@ -121,4 +126,4 @@ repos:
121126

122127
ci:
123128
autoupdate_commit_msg: "ci: pre-commit autoupdate"
124-
skip: [hadolint-docker, shellcheck]
129+
skip: [trufflehog, hadolint-docker, shellcheck]

0 commit comments

Comments
 (0)