2022-10-10 09:10:16 -04:00
|
|
|
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
|
2022-11-21 08:21:09 -05:00
|
|
|
uses: aquasecurity/trivy-action@9ab158e8597f3b310480b9a69402b419bc03dbd5 # v0.8.0 (Trivy v0.34.0)
|
2022-10-10 09:10:16 -04:00
|
|
|
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"
|
2022-11-30 12:53:30 +01:00
|
|
|
echo "results=$(cat scan.json)" >> $GITHUB_OUTPUT
|
2022-10-10 09:10:16 -04:00
|
|
|
else
|
|
|
|
echo "No vulnerabilities found, halting"
|
2022-11-30 12:53:30 +01:00
|
|
|
echo "results=nothing" >> $GITHUB_OUTPUT
|
2022-10-10 09:10:16 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Upload vulnerability scan report
|
2022-12-02 10:19:44 +00:00
|
|
|
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
|
2022-10-10 09:10:16 -04:00
|
|
|
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:
|
2022-12-13 14:01:51 +00:00
|
|
|
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
|
2022-10-10 09:10:16 -04:00
|
|
|
|
|
|
|
- name: Download scan
|
2022-12-07 08:57:38 +00:00
|
|
|
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1
|
2022-10-10 09:10:16 -04:00
|
|
|
with:
|
|
|
|
name: scan.json
|
|
|
|
|
|
|
|
- name: Set scan output
|
|
|
|
id: set-scan-output
|
2022-11-30 12:53:30 +01:00
|
|
|
run: echo "results=$(cat scan.json)" >> $GITHUB_OUTPUT
|
2022-10-10 09:10:16 -04:00
|
|
|
|
2022-12-22 08:02:18 +00:00
|
|
|
- uses: JasonEtco/create-an-issue@4d7c131a30a822fb445196f0de8ed11991f9f8a7 # v2.9.0
|
2022-10-10 09:10:16 -04:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
RESULTS: ${{ steps.set-scan-output.outputs.results }}
|
|
|
|
with:
|
|
|
|
filename: .github/VULN_TEMPLATE.md
|