Skip to content

Add DevSecOps Concepts Guide to documentation for enhanced understand… #280

Add DevSecOps Concepts Guide to documentation for enhanced understand…

Add DevSecOps Concepts Guide to documentation for enhanced understand… #280

# https://github.com/anchore/grype
# https://github.com/anchore/scan-action
name: CIS - Anchore Grype Vulnerability Scan (Container Image Scanning)
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: 0 1 * * 0
env:
fail-build: false # Set to true to fail the build if vulnerabilities are found
imageName: "webapp01"
tag: ${{ github.sha }}
permissions:
contents: read # for actions/checkout to fetch code
id-token: write
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
jobs:
anchore-grype-scan:
name: Anchore Grype Vulnerability Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Build an image from Dockerfile
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
context: ./src/webapp01
file: ./src/webapp01/Dockerfile
tags: "${{ env.imageName }}:${{ env.tag }}"
push: false
load: true
- name: Run the Anchore Grype scan action
uses: anchore/scan-action@e1165082ffb1fe366ebaf02d8526e7c4989ea9d2 # v7.4.0
id: scan
with:
image: "${{ env.imageName }}:${{ env.tag }}"
fail-build: ${{ env.fail-build }}
severity-cutoff: critical
- name: Upload Anchore vulnerability report to GitHub Security tab
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
- name: Upload alerts file as a workflow artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: alerts
path: ${{ steps.scan.outputs.sarif }}