diff --git a/.github/workflows/trivy_security_scans.yml b/.github/workflows/trivy_security_scans.yml new file mode 100644 index 0000000..eca3da0 --- /dev/null +++ b/.github/workflows/trivy_security_scans.yml @@ -0,0 +1,52 @@ +name: Trivy Security Scans + +on: + push: + branches: + - main + - development + pull_request: + branches: + - main + - development + schedule: + - cron: "0 8 * * 1" # Weekly scan on Mondays at 8 AM UTC + +jobs: + trivy-scan: + name: Trivy Filesystem & Docker Image Scan + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx (for consistent image builds) + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry (optional, if pushing images) + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Docker image + run: docker build -t adventurelog:latest . + + - name: Scan Docker image with Trivy + uses: aquasecurity/trivy-action@master + with: + image-ref: adventurelog:latest + format: table + exit-code: 1 + ignore-unfixed: true + + - name: Scan source code (Filesystem) with Trivy + uses: aquasecurity/trivy-action@master + with: + scan-type: fs + scan-ref: . + format: table + exit-code: 1 + ignore-unfixed: true