Skip to content

Commit 580a3c9

Browse files
PBM. Add fix for trivy (#1095)
1 parent 06640a7 commit 580a3c9

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

.github/workflows/trivy.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@ jobs:
1111
steps:
1212
- name: Checkout code
1313
uses: actions/checkout@v4
14-
15-
- name: Run Trivy vulnerability scanner in repo mode
16-
uses: aquasecurity/trivy-action@master
1714
with:
18-
scan-type: "fs"
19-
ignore-unfixed: true
20-
format: "sarif"
21-
output: "trivy-results.sarif"
22-
severity: "CRITICAL,HIGH"
15+
ref: ${{ github.event.pull_request.head.sha }}
2316

24-
- name: Upload Trivy scan results to GitHub Security tab
25-
uses: github/codeql-action/upload-sarif@v2
26-
with:
27-
sarif_file: "trivy-results.sarif"
17+
- name: Download latest trivy
18+
run: |
19+
mkdir -p ${{ github.workspace }}/trivy
20+
LATEST_TRIVY_VERSION=$(curl --retry 5 --retry-connrefused --retry-delay 5 --fail -s https://api.github.com/repos/aquasecurity/trivy/releases/latest | jq -r .tag_name)
21+
TRIVY_VERSION_STRIPPED=$(echo "$LATEST_TRIVY_VERSION" | sed 's/^v//')
22+
wget --tries=5 --retry-connrefused --waitretry=5 -O ${{ github.workspace }}/trivy/trivy.tar.gz \
23+
https://github.com/aquasecurity/trivy/releases/download/$LATEST_TRIVY_VERSION/trivy_${TRIVY_VERSION_STRIPPED}_Linux-64bit.tar.gz && break || sleep 5
24+
tar -xzf ${{ github.workspace }}/trivy/trivy.tar.gz -C ${{ github.workspace }}/trivy
25+
26+
- name: Generate SBOM
27+
run: ${{ github.workspace }}/trivy/trivy fs --format cyclonedx --output ${{ github.workspace }}/sbom.json ${{ github.workspace }}
28+
29+
- name: Run trivy scan on SBOM
30+
run: ${{ github.workspace }}/trivy/trivy sbom ${{ github.workspace }}/sbom.json --severity HIGH,CRITICAL --ignore-unfixed --exit-code=1

0 commit comments

Comments
 (0)