|
| 1 | +# Last applied at: Mon, 20 Jan 2025 03:13:44 GMT |
| 2 | +# DevOps Shield - The ultimate DevSecOps platform designed to secure your DevOps. |
| 3 | +# https://devopsshield.com |
| 4 | +############################################################## |
| 5 | +# This is a DevOps Shield - Application Security - Code Security Template. |
| 6 | + |
| 7 | +# This workflow template uses actions that are not certified by DevOps Shield. |
| 8 | +# They are provided by a third-party and are governed by separate terms of service, privacy policy, and support documentation. |
| 9 | + |
| 10 | +# Use this workflow template for integrating code security into your pipelines and workflows. |
| 11 | + |
| 12 | +# DevOps Shield Workflow Template Details: |
| 13 | +# ------------------------------------------------------------ |
| 14 | +# Code: GH_CIS_TRIVY |
| 15 | +# Name: Trivy Container Image Scanning |
| 16 | +# DevSecOpsControls: CIS |
| 17 | +# Provider: Aqua Security |
| 18 | +# Categories: Code Scanning, Dockerfile |
| 19 | +# Description: |
| 20 | +# Scan Docker container images for vulnerabilities in OS packages and language dependencies with Trivy from Aqua Security. |
| 21 | +# Trivy is a comprehensive and versatile security scanner. |
| 22 | +# Trivy has scanners that look for security issues, and targets where it can find those issues. |
| 23 | +# Find vulnerabilities, misconfigurations, secrets, SBOM in containers, Kubernetes, code repositories, clouds and more. |
| 24 | +# Read the official documentation to find out more. |
| 25 | +# For more information: |
| 26 | +# https://trivy.dev/latest/ |
| 27 | +# https://github.com/aquasecurity/trivy |
| 28 | +# ------------------------------------------------------------ |
| 29 | +# Source repository: https://github.com/aquasecurity/trivy-action |
| 30 | +############################################################## |
| 31 | + |
| 32 | +name: Trivy Container Image Scanning |
| 33 | + |
| 34 | +on: |
| 35 | + push: |
| 36 | + branches: [ main ] |
| 37 | + pull_request: |
| 38 | + branches: [ main ] |
| 39 | + schedule: |
| 40 | + - cron: 0 0 * * 0 |
| 41 | + |
| 42 | +jobs: |
| 43 | + trivy: |
| 44 | + name: Trivy vulnerability scanner |
| 45 | + |
| 46 | + runs-on: ubuntu-latest |
| 47 | + |
| 48 | + permissions: |
| 49 | + contents: read # for actions/checkout to fetch code |
| 50 | + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results |
| 51 | + actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Checkout code |
| 55 | + uses: actions/checkout@v4 |
| 56 | + |
| 57 | + - name: Build an image from Dockerfile |
| 58 | + run: | |
| 59 | + docker build -t docker.io/my-organization/my-app:${{ github.sha }} . |
| 60 | +
|
| 61 | + - name: Run Trivy vulnerability scanner |
| 62 | + uses: aquasecurity/trivy-action@v0.29.0 |
| 63 | + with: |
| 64 | + image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}' |
| 65 | + format: 'sarif' |
| 66 | + output: 'trivy-results.sarif' |
| 67 | + |
| 68 | + - name: Upload Trivy scan results to GitHub Security tab |
| 69 | + uses: github/codeql-action/upload-sarif@v3 |
| 70 | + with: |
| 71 | + sarif_file: 'trivy-results.sarif' |
0 commit comments