Skip to content

Commit 4f55feb

Browse files
committed
add trivy, anchore and cargo-audit scans
- Fix naming and use sha hashes for packages - minor fixes - use hash instead of tags
1 parent ca78fee commit 4f55feb

File tree

3 files changed

+90
-1
lines changed

3 files changed

+90
-1
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
##
2+
# This GitHub Action is using cargo-audit to perform an audit for crates with security vulnerabilities.
3+
# https://github.com/rustsec/audit-check
4+
##
5+
6+
name: Rustsec Cargo Audit
7+
on:
8+
workflow_dispatch:
9+
push:
10+
paths:
11+
- "**/Cargo.toml"
12+
- "**/Cargo.lock"
13+
schedule:
14+
- cron: "40 13 * * 0"
15+
jobs:
16+
security_audit:
17+
runs-on: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || '"ubuntu-22.04"') }}
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: rustsec/audit-check@dd51754d4e59da7395a4cd9b593f0ff2d61a9b95 #v1.4.1
21+
with:
22+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/snapshot-build.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ jobs:
8080
SUBSTRATE_CLI_GIT_COMMIT_HASH=${{ github.sha }}
8181
RUSTFLAGS=${{ matrix.platform.rustflags }}
8282
83+
- name: Trigger trivy-security-scan Workflow
84+
uses: peter-evans/repository-dispatch@a4a90276d01e3a2ae44fa10a0247287f045afd59 # @v2.1.2
85+
with:
86+
token: ${{ secrets.GITHUB_TOKEN }}
87+
event-type: trivy-scan-dispatch
88+
client-payload: '{"sha": "${{ github.sha }}"}'
89+
8390
executables:
8491
strategy:
8592
matrix:
@@ -176,7 +183,7 @@ jobs:
176183
gcc-aarch64-linux-gnu \
177184
libc6-dev-arm64-cross \
178185
zlib1g-dev:arm64
179-
186+
180187
echo "PKG_CONFIG_ALLOW_CROSS=true" >> $GITHUB_ENV
181188
if: matrix.build.target == 'aarch64-unknown-linux-gnu'
182189

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
##
2+
# This action runs trivy container and repository vulnerability
3+
# scanner for docker images and cargo packages.
4+
##
5+
6+
name: trivy-security-scan
7+
8+
on:
9+
repository_dispatch:
10+
types: [trivy-scan-dispatch]
11+
12+
jobs:
13+
trivy_scan_image:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
image:
18+
- farmer
19+
- node
20+
- bootstrap-node
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # @v3.1.0
25+
26+
- name: Run Trivy vulnerability scanner on image
27+
uses: aquasecurity/trivy-action@d43c1f16c00cfd3978dde6c07f4bbcf9eb6993ca # @v0.16.1
28+
with:
29+
image-ref: ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}:${{ github.event.client_payload.sha }}
30+
format: "sarif"
31+
output: "trivy-results.sarif"
32+
exit-code: "1"
33+
ignore-unfixed: true
34+
vuln-type: "os,library"
35+
severity: "CRITICAL,HIGH"
36+
37+
- name: Upload Trivy scan results to GitHub Security tab
38+
uses: github/codeql-action/upload-sarif@4759df8df70c5ebe7042c3029bbace20eee13edd # @v2.23.1
39+
with:
40+
sarif_file: "trivy-results.sarif"
41+
42+
trivy_scan_repo:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Checkout code
46+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # @v3.1.0
47+
48+
- name: Run Trivy vulnerability scanner in repo mode
49+
uses: aquasecurity/trivy-action@d43c1f16c00cfd3978dde6c07f4bbcf9eb6993ca # @v0.16.1
50+
with:
51+
scan-type: fs
52+
ignore-unfixed: true
53+
format: sarif
54+
output: trivy-results.sarif
55+
severity: CRITICAL
56+
57+
- name: Upload Trivy scan results to GitHub Security tab
58+
uses: github/codeql-action/upload-sarif@4759df8df70c5ebe7042c3029bbace20eee13edd # @v2.23.1
59+
with:
60+
sarif_file: trivy-results.sarif

0 commit comments

Comments
 (0)