|  | 
|  | 1 | +# Uses Trivy to scan every pull request, rejecting those with severe, fixable vulnerabilities. | 
|  | 2 | +# Scans on PR to master and weekly with same behavior. | 
|  | 3 | +name: Trivy | 
|  | 4 | + | 
|  | 5 | +on: | 
|  | 6 | + pull_request: | 
|  | 7 | + branches: | 
|  | 8 | + - master | 
|  | 9 | + push: | 
|  | 10 | + branches: | 
|  | 11 | + - master | 
|  | 12 | + # Scan schedule is same as codeql-analysis job. | 
|  | 13 | + # TODO(ben): change cron -- we're setting this to be active to check the notification setting | 
|  | 14 | + schedule: | 
|  | 15 | + - cron: '0,30 22,23 * * *' | 
|  | 16 | + | 
|  | 17 | +jobs: | 
|  | 18 | + scan: | 
|  | 19 | + if: ${{ github.repository == 'CrunchyData/postgres-operator' }} | 
|  | 20 | + | 
|  | 21 | + permissions: | 
|  | 22 | + # for github/codeql-action/upload-sarif to upload SARIF results | 
|  | 23 | + security-events: write  | 
|  | 24 | + | 
|  | 25 | + runs-on: ubuntu-latest | 
|  | 26 | + | 
|  | 27 | + steps: | 
|  | 28 | + - uses: actions/checkout@v3 | 
|  | 29 | + | 
|  | 30 | + # Run trivy and log detected and fixed vulnerabilities | 
|  | 31 | + # This report should match the uploaded code scan report below | 
|  | 32 | + # and is a convenience/redundant effort for those who prefer to | 
|  | 33 | + # read logs and/or if anything goes wrong with the upload. | 
|  | 34 | + - name: Log all detected vulnerabilities | 
|  | 35 | + uses: aquasecurity/trivy-action@master | 
|  | 36 | + with: | 
|  | 37 | + scan-type: fs | 
|  | 38 | + hide-progress: true | 
|  | 39 | + ignore-unfixed: true | 
|  | 40 | +  | 
|  | 41 | + # Upload actionable results to the GitHub Security tab. | 
|  | 42 | + # Pull request checks fail according to repository settings. | 
|  | 43 | + # - https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github | 
|  | 44 | + # - https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning | 
|  | 45 | + - name: Report actionable vulnerabilities | 
|  | 46 | + uses: aquasecurity/trivy-action@master | 
|  | 47 | + with: | 
|  | 48 | + scan-type: fs | 
|  | 49 | + ignore-unfixed: true | 
|  | 50 | + format: 'sarif' | 
|  | 51 | + output: 'trivy-results.sarif' | 
|  | 52 | + | 
|  | 53 | + - name: Upload Trivy scan results to GitHub Security tab | 
|  | 54 | + uses: github/codeql-action/upload-sarif@v2 | 
|  | 55 | + with: | 
|  | 56 | + sarif_file: 'trivy-results.sarif' | 
0 commit comments