Snyk scheduled Docker base image scan #48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Snyk scheduled Docker base image scan | |
| on: | |
| schedule: | |
| - cron: '0 3 * * 1' | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| REPOSITORY: ${{ github.repository }} | |
| IMAGES: >- | |
| [{ | |
| 'name': 'kafka-connect-fitbit-source', | |
| 'build_file': 'kafka-connect-fitbit-source/Dockerfile', | |
| 'authors': 'Pim van Nierop <[email protected]>, Pauline Conde <[email protected]>', | |
| 'description': 'RADAR-base Fitbit connector application' | |
| },{ | |
| 'name': 'kafka-connect-oura-source', | |
| 'build_file': 'kafka-connect-oura-source/Dockerfile', | |
| 'authors': 'Pim van Nierop <[email protected]>, Pauline Conde <[email protected]>', | |
| 'description': 'RADAR-base Oura connector application' | |
| }] | |
| jobs: | |
| prepare-matrix: | |
| name: Prepare Matrix Output | |
| permissions: {} | |
| runs-on: ubuntu-latest | |
| outputs: | |
| images: ${{ steps.step1.outputs.matrix }} | |
| steps: | |
| - name: Create Matrix Variable | |
| id: step1 | |
| run: echo "matrix=${{ env.IMAGES }}" >> $GITHUB_OUTPUT | |
| security: | |
| needs: prepare-matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| image: ${{ fromJson(needs.prepare-matrix.outputs.images ) }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Lowercase image name | |
| run: | | |
| echo "DOCKER_IMAGE=${REGISTRY}/${REPOSITORY,,}/${{ matrix.image.name }}" >>${GITHUB_ENV} | |
| - name: Run Snyk to check for vulnerabilities | |
| continue-on-error: true # To make sure that SARIF upload gets called | |
| uses: snyk/actions/docker@master | |
| env: | |
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
| with: | |
| image: ${{ env.DOCKER_IMAGE }} | |
| args: >- | |
| --file=${{ matrix.image.build_file }} | |
| --fail-on=upgradable | |
| --severity-threshold=high | |
| --policy-path=.snyk | |
| --exclude-app-vulns | |
| --org=radar-base | |
| --sarif-file-output=snyk.sarif | |
| # Detected vulnerabilities will appear on Github in Security->Code_scanning_alerts tab | |
| - name: Upload result to GitHub Code Scanning | |
| uses: github/codeql-action/upload-sarif@v3 | |
| with: | |
| sarif_file: snyk.sarif | |
| category: ${{ matrix.image.name }} | |