mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-12 02:46:56 +00:00
69 lines
2.2 KiB
YAML
69 lines
2.2 KiB
YAML
|
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
|