diff --git a/.github/workflows/scan-docker-vulnerabilities.yml b/.github/workflows/scan-docker-vulnerabilities.yml new file mode 100644 index 000000000..1d75582df --- /dev/null +++ b/.github/workflows/scan-docker-vulnerabilities.yml @@ -0,0 +1,48 @@ +name: Scan Docker image vulnerabilities + +on: + workflow_dispatch: # allow manual execution + schedule: + # Run weekly + - cron: '0 0 * * 0' + push: + tags: + - "v*.*.*" + pull_request: + paths: + - 'Dockerfile' + - 'requirements*.txt' + - 'setup.cfg' + - '.github/workflows/scan-docker-vulnerabilities.yml' + +jobs: + scan-docker: + name: Inspect Docker image with ScanCode.io + runs-on: ubuntu-24.04 + permissions: + contents: read + + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Build Docker image locally + run: docker build -t vulnerablecode:scan . + + - name: Save Docker image archive for ScanCode.io + run: | + mkdir -p scancode-inputs + docker save vulnerablecode:scan -o scancode-inputs/vulnerablecode-image.tar + + - name: Scan Docker image for vulnerabilities + uses: aboutcode-org/scancode-action@e834673d293dfe30d5f1d37898d1ae4b9e52af1a # v1.0.0 + with: + pipelines: "analyze_docker_image,find_vulnerabilities" + check-compliance: true + compliance-fail-on-vulnerabilities: true + outputs-archive-name: "vulnerablecode-docker-scan" + env: + VULNERABLECODE_URL: https://public.vulnerablecode.io/ + VULNERABLECODE_API_KEY: ${{ secrets.VULNERABLECODE_API_KEY }} +