forked from halestudio/hale
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trivy vulnerability check is added the GitHub Actions workflows. ING-4183
- Loading branch information
1 parent
2a6b7cd
commit 295058e
Showing
3 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: trivy | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- '*' | ||
schedule: | ||
- cron: '39 17 * * 3' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
permissions: | ||
contents: read # for actions/checkout to fetch code | ||
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results | ||
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
#- name: Build an image from Dockerfile | ||
# run: | | ||
# docker build -t docker.io/my-organization/my-app:${{ github.sha }} . | ||
|
||
- name: Run Trivy vulnerability scanner | ||
uses: aquasecurity/trivy-action@7b7aa264d83dc58691451798b4d117d53d21edfe | ||
with: | ||
# image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}' | ||
scan-type: 'fs' | ||
scan-ref: '.' | ||
template: '/sarif.tpl' | ||
output: 'trivy-scan-results.sarif' | ||
severity: 'CRITICAL,HIGH' | ||
|
||
- name: Upload Trivy scan results to GitHub Security tab | ||
uses: github/codeql-action/upload-sarif@v2 | ||
with: | ||
name: trivy-results | ||
path: trivy-scan-results.sarif | ||
sarif_file: 'trivy-scan-results.sarif' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json", | ||
"version": "2.1.0", | ||
"runs": [ | ||
{ | ||
"tool": { | ||
"driver": { | ||
"name": "Trivy", | ||
"version": "0.12.0" | ||
} | ||
}, | ||
"results": [ | ||
{ | ||
"ruleId": "Vulnerability", | ||
"level": "error", | ||
"message": { | ||
"text": "Critical vulnerability found in the Docker image." | ||
}, | ||
"locations": [ | ||
{ | ||
"physicalLocation": { | ||
"artifactLocation": { | ||
"uri": "https://example.com/repo/docker-image.tar.gz" | ||
} | ||
} | ||
} | ||
], | ||
"properties": { | ||
"severity": "Critical", | ||
"vulnerabilityId": "CVE-2021-12345", | ||
"description": "Description of the vulnerability." | ||
} | ||
}, | ||
{ | ||
"ruleId": "Vulnerability", | ||
"level": "warning", | ||
"message": { | ||
"text": "Medium severity vulnerability found in the Docker image." | ||
}, | ||
"locations": [ | ||
{ | ||
"physicalLocation": { | ||
"artifactLocation": { | ||
"uri": "https://example.com/repo/docker-image.tar.gz" | ||
} | ||
} | ||
} | ||
], | ||
"properties": { | ||
"severity": "Medium", | ||
"vulnerabilityId": "CVE-2021-67890", | ||
"description": "Description of the vulnerability." | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json", | ||
"version": "2.1.0", | ||
"runs": [ | ||
{ | ||
"tool": { | ||
"driver": { | ||
"name": "Trivy", | ||
"version": "0.12.0", | ||
"informationUri": "https://github.com/aquasecurity/trivy", | ||
"rules": [ | ||
{ | ||
"id": "TRIVY_SCAN_RESULT", | ||
"name": "Trivy Vulnerability Scan Result", | ||
"shortDescription": { | ||
"text": "Trivy scan result for vulnerabilities" | ||
}, | ||
"fullDescription": { | ||
"text": "Trivy scan result for vulnerabilities found in the scanned image." | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"results": [ | ||
{ | ||
"ruleId": "TRIVY_SCAN_RESULT", | ||
"level": "error", | ||
"message": { | ||
"text": "High severity vulnerability found in package XYZ" | ||
}, | ||
"locations": [ | ||
{ | ||
"physicalLocation": { | ||
"artifactLocation": { | ||
"uri": "file:///path/to/scanned/image" | ||
} | ||
} | ||
} | ||
], | ||
"properties": { | ||
"CVE": "CVE-2021-1234", | ||
"package": "XYZ", | ||
"version": "1.2.3", | ||
"severity": "High" | ||
} | ||
}, | ||
{ | ||
"ruleId": "TRIVY_SCAN_RESULT", | ||
"level": "warning", | ||
"message": { | ||
"text": "Medium severity vulnerability found in package ABC" | ||
}, | ||
"locations": [ | ||
{ | ||
"physicalLocation": { | ||
"artifactLocation": { | ||
"uri": "file:///path/to/scanned/image" | ||
} | ||
} | ||
} | ||
], | ||
"properties": { | ||
"CVE": "CVE-2021-5678", | ||
"package": "ABC", | ||
"version": "4.5.6", | ||
"severity": "Medium" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |