From 3a7e4a131851d43887911c8b97fa5f55ae19dafb Mon Sep 17 00:00:00 2001 From: Ben Manes Date: Tue, 1 Oct 2024 08:27:48 -0700 Subject: [PATCH] workaround for trivy scanner rate limiting --- .github/workflows/trivy.yml | 52 ++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index 25d22e822f..7ba2ea9cf9 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -1,5 +1,5 @@ name: trivy -permissions: read-all +# permissions: read-all on: [ push, pull_request ] jobs: @@ -7,28 +7,50 @@ jobs: runs-on: ubuntu-20.04 permissions: checks: write - actions: read - contents: read + # actions: read + # contents: read security-events: write steps: - - name: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 - with: - disable-sudo: true - egress-policy: block - allowed-endpoints: > - api.github.com:443 - ghcr.io:443 - github.com:443 - pkg-containers.githubusercontent.com:443 + # - name: Harden Runner + # uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + # with: + # disable-sudo: true + # egress-policy: block + # allowed-endpoints: > + # api.github.com:443 + # ghcr.io:443 + # github.com:443 + # pkg-containers.githubusercontent.com:443 - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + - name: Trivy Cache + uses: yogeshlonkar/trivy-cache-action@v0 + with: + gh-token: ${{ secrets.GITHUB_TOKEN }} + - name: Download Trivy Java DB + if: ${{ steps.trivy-cache.outputs.cache-hit == '' || steps.trivy-cache.outputs.cache-hit == 'false' }} + uses: aquasecurity/trivy-action@master + env: + TRIVY_DOWNLOAD_JAVA_DB_ONLY: true + with: + scan-type: image + cache-dir: .trivy - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@6e7b7d1fd3e4fef0c5fa8cce1229c54b2c9bd0d8 # v0.24.0 + continue-on-error: true with: scan-type: fs format: sarif - output: trivy-results.sarif + exit-code: '1' + cache-dir: .trivy + ignore-unfixed: true + output: results.sarif + - name: Check file existence + id: check_files + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 + with: + files: results.sarif - name: Upload Trivy scan results to GitHub Security tab uses: github/codeql-action/upload-sarif@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9 + if: steps.check_files.outputs.files_exists == 'true' with: - sarif_file: trivy-results.sarif + sarif_file: results.sarif