|
| 1 | +# This workflow uses actions that are not certified by GitHub. |
| 2 | +# They are provided by a third-party and are governed by |
| 3 | +# separate terms of service, privacy policy, and support |
| 4 | +# documentation. |
| 5 | + |
| 6 | +name: Trivy vulnerability scanner |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - '*' |
| 12 | + pull_request: |
| 13 | + branches: |
| 14 | + - '*' |
| 15 | + #schedule: |
| 16 | + # - cron: '39 17 * * 3' |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: write |
| 20 | + pull-requests: write # allows SonarQube to decorate PRs with analysis results |
| 21 | + |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + permissions: |
| 25 | + contents: read # for actions/checkout to fetch code |
| 26 | + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results |
| 27 | + actions: write # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status |
| 28 | + name: Build |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - name: Checkout code |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + #- name: Build an image from Dockerfile |
| 35 | + # run: | |
| 36 | + # docker build -t docker.io/my-organization/my-app:${{ github.sha }} . |
| 37 | + |
| 38 | + - name: Run Trivy vulnerability scanner in fs mode |
| 39 | + uses: aquasecurity/trivy-action@master |
| 40 | + with: |
| 41 | + # image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}' |
| 42 | + scan-type: 'fs' |
| 43 | + scan-ref: '.' |
| 44 | + #exit-code: '0' |
| 45 | + #ignore-unfixed: true |
| 46 | + format: 'sarif' |
| 47 | + #vuln-type: 'os,library' |
| 48 | + severity: 'CRITICAL,HIGH,MEDIUM' |
| 49 | + #template: '/sarif.tpl' |
| 50 | + output: 'trivy-results.sarif' |
| 51 | + #skip-dirs: "ignored-dir" |
| 52 | + #trivy-config: trivy.yaml |
| 53 | + |
| 54 | + - name: Upload Trivy scan results as artifact |
| 55 | + uses: actions/upload-artifact@v2 |
| 56 | + with: |
| 57 | + name: trivy-results |
| 58 | + path: ~/.hale/trivy-results.sarif |
| 59 | + |
| 60 | + #- name: Upload Trivy scan results to GitHub Security tab |
| 61 | + #uses: github/codeql-action/upload-sarif@v2 |
| 62 | + #with: |
| 63 | + #sarif_file: 'trivy-results.sarif' |
| 64 | + |
| 65 | + #- name: DEBUG Upload Trivy scan results to GitHub Security tab |
| 66 | + # uses: github/codeql-action/upload-sarif@v3 |
| 67 | + # with: |
| 68 | + # sarif_file: 'debug-trivy-results.sarif' |
| 69 | + |
| 70 | + #- name: Create Pull Request |
| 71 | + # uses: peter-evans/create-pull-request@v5 |
| 72 | + # with: |
| 73 | + # commit-message: update vulnerability list |
| 74 | + # title: Update vulnerability list |
| 75 | + # body: Update the vulnerability list |
| 76 | + # branch: update-vulnerabilities |
0 commit comments