From aa8daae5b4b0d5736089580123b7509637eb8a77 Mon Sep 17 00:00:00 2001 From: yevh Date: Fri, 18 Oct 2024 12:49:27 +0200 Subject: [PATCH] Create trivy.yml Signed-off-by: yevh --- .github/workflows/trivy.yml | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/trivy.yml diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml new file mode 100644 index 000000000..27e009e5c --- /dev/null +++ b/.github/workflows/trivy.yml @@ -0,0 +1,43 @@ +name: Container Security + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: '29 19 * * 4' + +permissions: + contents: read + +jobs: + build: + permissions: + contents: read + security-events: write + actions: read + name: Build + runs-on: "ubuntu-20.04" + steps: + - name: Checkout code + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 #v4.2.1 + + - 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@5681af892cd0f4997658e2bacc62bd0a894cf564 #v0.27.0 + with: + image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}' + format: 'template' + template: '@/contrib/sarif.tpl' + output: 'trivy-results.sarif' + severity: 'CRITICAL,HIGH' + env: + TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db + + - name: Upload Trivy scan results to GitHub Security tab + uses: github/codeql-action/upload-sarif@cf5b0a9041d3c1d336516f1944c96d96598193cc #v2.19.1 + with: + sarif_file: 'trivy-results.sarif'