|
| 1 | +# Copyright 2010 New Relic, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +--- |
| 15 | +name: Trivy |
| 16 | + |
| 17 | +on: |
| 18 | + pull_request: |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: ${{ github.ref || github.run_id }}-${{ github.workflow }} |
| 22 | + cancel-in-progress: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + # Upload Trivy data |
| 26 | + trivy: |
| 27 | + if: success() || failure() # Does not run on cancelled workflows |
| 28 | + runs-on: ubuntu-20.04 |
| 29 | + steps: |
| 30 | + # Git Checkout |
| 31 | + - name: Checkout Code |
| 32 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1 |
| 33 | + with: |
| 34 | + token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: Run Trivy vulnerability scanner in repo mode |
| 38 | + if: ${{ github.event_name == 'pull_request' }} |
| 39 | + uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # v0.29.0 |
| 40 | + with: |
| 41 | + scan-type: "fs" |
| 42 | + ignore-unfixed: true |
| 43 | + format: table |
| 44 | + exit-code: 1 |
| 45 | + severity: "CRITICAL,HIGH,MEDIUM,LOW" |
| 46 | + |
| 47 | + - name: Run Trivy vulnerability scanner in repo mode |
| 48 | + if: ${{ github.event_name == 'schedule' }} |
| 49 | + uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # v0.29.0 |
| 50 | + with: |
| 51 | + scan-type: "fs" |
| 52 | + ignore-unfixed: true |
| 53 | + format: "sarif" |
| 54 | + output: "trivy-results.sarif" |
| 55 | + severity: "CRITICAL,HIGH,MEDIUM,LOW" |
| 56 | + |
| 57 | + - name: Upload Trivy scan results to GitHub Security tab |
| 58 | + if: ${{ github.event_name == 'schedule' }} |
| 59 | + uses: github/codeql-action/upload-sarif@v3 |
| 60 | + with: |
| 61 | + sarif_file: "trivy-results.sarif" |
0 commit comments