From 2675017b8177466e44c1fc63cf227e1f1d0ab81a Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Thu, 23 Nov 2023 14:01:34 +0000 Subject: [PATCH] fix(DockerFile): Fix trivy scan --- .github/workflows/trivy-test-images.yml | 55 +++++++++++++++++++++++++ .github/workflows/trivy.yml | 9 ++-- 2 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/trivy-test-images.yml diff --git a/.github/workflows/trivy-test-images.yml b/.github/workflows/trivy-test-images.yml new file mode 100644 index 00000000..a4f51875 --- /dev/null +++ b/.github/workflows/trivy-test-images.yml @@ -0,0 +1,55 @@ +name: Trivy Docker Image Analysis + +on: + push: + branches: + - main + # Trigger manually + workflow_dispatch: + +permissions: + security-events: write # To upload sarif files + +jobs: + build-and-scan: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Helm + uses: azure/setup-helm@v3 + with: + version: '3.6.3' + + - name: Set up python + uses: actions/setup-python@v4 + with: + python-version: '3.7' + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + file: ./Dockerfile + push: false + tags: backend:latest + load: true # Load the image into Docker's local image store + + + - name: Run Trivy Table + uses: aquasecurity/trivy-action@0.14.0 + with: + scan-type: 'image' + image-ref: 'backend:latest' + severity: 'MEDIUM,HIGH,CRITICAL' + format: 'table' + diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index c9f96dc9..70e73b2e 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -68,15 +68,16 @@ jobs: # For public images, no ENV vars must be set. - name: Run Trivy vulnerability scanner if: always() - uses: aquasecurity/trivy-action@master + uses: aquasecurity/trivy-action@0.14.0 with: # Path to Docker image image-ref: "ghcr.io/catenax-ng/tx-vas-country-risk-backend:latest" format: "sarif" output: "trivy-results3.sarif" - exit-code: "1" - severity: "CRITICAL,HIGH" - timeout: "60m" + # exit-code: "1" + # severity: "CRITICAL,HIGH" + # timeout: "60m" + vuln-type: "os,library" - name: Upload Trivy scan results to GitHub Security tab if: always()