1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-28 10:28:36 +00:00

Add workflow to detect and report on image vulns (#4850)

* update version drop-down

Signed-off-by: Chip Zoller <chipzoller@gmail.com>

* Add workflow to detect and report on image vulnerabilities

Signed-off-by: Chip Zoller <chipzoller@gmail.com>

* pin deps

Signed-off-by: Chip Zoller <chipzoller@gmail.com>

Signed-off-by: Chip Zoller <chipzoller@gmail.com>
Co-authored-by: Vyankatesh Kudtarkar <vyankateshkd@gmail.com>
This commit is contained in:
Chip Zoller 2022-10-10 09:10:16 -04:00 committed by GitHub
parent c5f4fd2d01
commit 5346bce5ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 75 additions and 0 deletions

View file

@ -0,0 +1,7 @@
---
title: Vulnerabilities detected
labels: security
---
High or critical vulnerabilities detected. Scan results are below:
{{ env.RESULTS }}

View file

@ -0,0 +1,68 @@
name: report-on-vulnerabilities
on:
workflow_dispatch: {}
schedule:
- cron: '23 2 * * *' # Every day at 02:23
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
scan:
runs-on: ubuntu-20.04
permissions:
contents: read
outputs:
results: ${{ steps.parse-results.outputs.results }}
steps:
- name: Scan for vulnerabilities
uses: aquasecurity/trivy-action@d63413b0a4a4482237085319f7f4a1ce99a8f2ac # v0.7.1 (Trivy v0.31.2)
with:
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
format: json
ignore-unfixed: false
severity: HIGH,CRITICAL
output: scan.json
- name: Parse scan results
id: parse-results
continue-on-error: true
run: |
VULNS=$(cat scan.json | jq '.Results[] | has("Vulnerabilities")')
if echo $VULNS | grep -q 'true'; then
echo "Vulnerabilities found, creating issue"
echo ::set-output name=results::$(cat scan.json)
else
echo "No vulnerabilities found, halting"
echo ::set-output name=results::$(echo nothing)
fi
- name: Upload vulnerability scan report
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
if: contains(steps.parse-results.outputs.results, 'SchemaVersion')
with:
name: scan.json
path: scan.json
if-no-files-found: error
open-issue:
runs-on: ubuntu-latest
if: contains(needs.scan.outputs.results, 'SchemaVersion')
needs: scan
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
- name: Download scan
uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v3.0.0
with:
name: scan.json
- name: Set scan output
id: set-scan-output
run: echo ::set-output name=results::$(cat scan.json)
- uses: JasonEtco/create-an-issue@9e6213aec58987fa7d2f4deb8b256b99e63107a2 # v2.6.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RESULTS: ${{ steps.set-scan-output.outputs.results }}
with:
filename: .github/VULN_TEMPLATE.md