Skip to content

Vulnerability scan - Operator #3

Vulnerability scan - Operator

Vulnerability scan - Operator #3

name: Vulnerability scan - Operator
on:
workflow_dispatch:
schedule:
- cron: '00 4 * * 1-5'
jobs:
scan:
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[0].url")
echo "url: $url"
echo url=$url >> $GITHUB_OUTPUT
env:
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 Operator CVE alert: ${{ steps.job-url.outputs.url }}'
- name: Check result
shell: bash
if: steps.fo.outcome == 'failure'
run: |
echo "Operator has vulnerabilities"
exit 1