Skip to content

Vulnerability scan #274

Vulnerability scan

Vulnerability scan #274

name: Vulnerability scan
on:
workflow_dispatch:
schedule:
- cron: '00 4 * * 1-5'
permissions:
contents: read
jobs:
scan:
strategy:
fail-fast: false
matrix:
variant:
- alpine
- distroless
permissions:
contents: read
uses: ./.github/workflows/scan-controllers.yaml
with:
check-scan-error: true
registry: ghcr.io/controlplaneio-fluxcd/${{ matrix.variant }}
secrets:
pull-token: ${{ secrets.GHCR_READONLY }}
scan-operator:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Latest release
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=$(gh release view --repo controlplaneio-fluxcd/flux-operator --json tagName -q .tagName)
echo version=${VERSION} >> $GITHUB_OUTPUT
- name: Export image
id: image
run: echo fo=${REGISTRY}:${VERSION} >> $GITHUB_OUTPUT
env:
REGISTRY: ghcr.io/controlplaneio-fluxcd/flux-operator
VERSION: ${{ steps.release.outputs.version }}
- name: Scan flux-operator
id: fo
continue-on-error: true
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # v0.29.0
with:
image-ref: ${{ steps.image.outputs.fo }}
format: table
exit-code: '1'
ignore-unfixed: true
vuln-type: os,library
severity: CRITICAL,HIGH,MEDIUM
- name: Scan result
env:
OUTCOME: ${{ steps.fo.outcome }}
IMAGE: ${{ steps.image.outputs.fo }}
run: |
echo "flux-operator: ${OUTCOME}"
echo "image: ${IMAGE}"
- name: Get Job URL
if: steps.fo.outcome == 'failure'
id: job-url
run: |
url=$(gh run view ${GITHUB_RUN_ID} --repo ${GITHUB_REPO} --json jobs --jq ".jobs[] | select(.name == \"${GITHUB_JOB}\") | .url")
echo "url: $url"
echo url=$url >> $GITHUB_OUTPUT
env:
GITHUB_JOB: ${{ github.job }}
GITHUB_RUN_ID: ${{ github.run_id }}
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2
if: steps.fo.outcome == 'failure'
with:
email: ${{ secrets.ZULIP_EMAIL }}
api-key: ${{ secrets.ZULIP_API_KEY }}
organization-url: ${{ secrets.ZULIP_ORGANIZATION_URL }}
type: stream
to: team-flux
topic: cve-alerts
content: 'Flux Enterprise ${{ github.job }} CVE alert: ${{ steps.job-url.outputs.url }}'
- name: Check result
shell: bash
if: steps.fo.outcome == 'failure'
run: |
echo "One or more controllers have vulnerabilities"
exit 1