mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-15 17:51:20 +00:00
f911c9f304
Bumps [aquasecurity/trivy-action](https://github.com/aquasecurity/trivy-action) from 0.25.0 to 0.26.0.
- [Release notes](https://github.com/aquasecurity/trivy-action/releases)
- [Commits](f781cce5aa...a20de5420d
)
---
updated-dependencies:
- dependency-name: aquasecurity/trivy-action
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
117 lines
4.3 KiB
YAML
117 lines
4.3 KiB
YAML
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
|
|
|
|
name: report-on-vulnerabilities
|
|
|
|
permissions: {}
|
|
|
|
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-latest
|
|
outputs:
|
|
results: ${{ steps.parse-results.outputs.results }}
|
|
steps:
|
|
- name: Get Branches Name
|
|
id: get-branches
|
|
run: |
|
|
all_branches=$(curl -s 'https://api.github.com/repos/${{ env.IMAGE_NAME }}/branches?per_page=100' | jq -r '.[].name | select(startswith("release-"))' | sort -rV | head -n 2)
|
|
releasebranch1=$(echo "$all_branches" | sed -n 1p)
|
|
releasebranch2=$(echo "$all_branches" | sed -n 2p)
|
|
|
|
echo "releasebranch1=$releasebranch1" >> $GITHUB_OUTPUT
|
|
echo "releasebranch2=$releasebranch2" >> $GITHUB_OUTPUT
|
|
|
|
- name: Scan for vulnerabilities in latest image
|
|
uses: aquasecurity/trivy-action@a20de5420d57c4102486cdd9578b45609c99d7eb # v0.26.0
|
|
with:
|
|
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
format: json
|
|
ignore-unfixed: false
|
|
severity: HIGH,CRITICAL
|
|
output: scan1.json
|
|
env:
|
|
# Trivy is returning TOOMANYREQUESTS
|
|
# See: https://github.com/aquasecurity/trivy-action/issues/389#issuecomment-2385416577
|
|
TRIVY_DB_REPOSITORY: 'public.ecr.aws/aquasecurity/trivy-db:2'
|
|
- name: Scan for vulnerabilities in latest-1 image
|
|
uses: aquasecurity/trivy-action@a20de5420d57c4102486cdd9578b45609c99d7eb # v0.26.0
|
|
with:
|
|
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.get-branches.outputs.releasebranch1 }}
|
|
format: json
|
|
ignore-unfixed: false
|
|
severity: HIGH,CRITICAL
|
|
output: scan2.json
|
|
env:
|
|
# Trivy is returning TOOMANYREQUESTS
|
|
# See: https://github.com/aquasecurity/trivy-action/issues/389#issuecomment-2385416577
|
|
TRIVY_DB_REPOSITORY: 'public.ecr.aws/aquasecurity/trivy-db:2'
|
|
- name: Scan for vulnerabilities in latest-2 image
|
|
uses: aquasecurity/trivy-action@a20de5420d57c4102486cdd9578b45609c99d7eb # v0.26.0
|
|
with:
|
|
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.get-branches.outputs.releasebranch2 }}
|
|
format: json
|
|
ignore-unfixed: false
|
|
severity: HIGH,CRITICAL
|
|
output: scan3.json
|
|
env:
|
|
# Trivy is returning TOOMANYREQUESTS
|
|
# See: https://github.com/aquasecurity/trivy-action/issues/389#issuecomment-2385416577
|
|
TRIVY_DB_REPOSITORY: 'public.ecr.aws/aquasecurity/trivy-db:2'
|
|
- name: Merge scan results
|
|
id: merge-results
|
|
run: |
|
|
jq -s add scan1.json scan2.json scan3.json > scan.json
|
|
cat scan.json
|
|
|
|
- name: Parse scan results
|
|
id: parse-results
|
|
continue-on-error: true
|
|
run: |
|
|
VULNS=$(cat scan.json | jq '.Results[] | select(.Target=="ko-app/kyverno").Vulnerabilities | length')
|
|
if [[ $VULNS -eq 0 ]]
|
|
then
|
|
echo "No vulnerabilities found, halting"
|
|
echo "results=nothing" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "Vulnerabilities found, creating issue"
|
|
echo "results=found" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Upload vulnerability scan report
|
|
uses: actions/upload-artifact@84480863f228bb9747b473957fcc9e309aa96097 # v4.4.2
|
|
if: steps.parse-results.outputs.results == 'found'
|
|
with:
|
|
name: scan.json
|
|
path: scan.json
|
|
if-no-files-found: error
|
|
|
|
open-issue:
|
|
runs-on: ubuntu-latest
|
|
if: needs.scan.outputs.results == 'found'
|
|
needs: scan
|
|
permissions:
|
|
issues: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
|
- name: Download scan
|
|
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
|
with:
|
|
name: scan.json
|
|
- name: Set scan output
|
|
id: set-scan-output
|
|
run: echo "results=$(cat scan.json | jq -c)" >> $GITHUB_OUTPUT
|
|
- uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # v2.9.2
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
RESULTS: ${{ steps.set-scan-output.outputs.results }}
|
|
with:
|
|
filename: .github/ISSUE_TEMPLATE/VULN-TEMPLATE.md
|