Skip to content

Vulnerability Scan #154

Vulnerability Scan

Vulnerability Scan #154

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Vulnerability Scan
on:
workflow_dispatch:
release:
schedule:
- cron: '00 9 * * 1'
permissions:
contents: read
security-events: write
jobs:
version:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.version.outputs.tag }}
steps:
- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
with:
fetch-depth: 0
- name: Latest Tag
id: version
shell: bash
run: |
TAG=$(cat TAG)
echo "TAG: ${TAG}"
echo "::set-output name=tag::${TAG}"
scan:
runs-on: ubuntu-latest
needs: version
steps:
- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- shell: bash
id: test
run: echo "Scanning registry.k8s.io/ingress-nginx/controller@${{ needs.version.outputs.tag }}"
- name: Scan image with AquaSec/Trivy
id: scan
uses: aquasecurity/trivy-action@41f05d9ecffa2ed3f1580af306000f734b733e54 #v0.5.1
with:
image-ref: docker.io/wallarm/ingress-controller:${{ needs.version.outputs.tag }}
format: 'sarif'
output: trivy-results-${{ needs.version.outputs.tag }}.sarif
exit-code: 0
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN'
- name: Output Sarif File
shell: bash
run: cat ${{ github.workspace }}/trivy-results-${{ needs.version.outputs.tag }}.sarif
# This step checks out a copy of your repository.
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@cdcdbb579706841c47f7063dda365e292e5cad7a
with:
token: ${{ github.token }}
# Path to SARIF file relative to the root of the repository
sarif_file: ${{ github.workspace }}/trivy-results-${{ needs.version.outputs.tag }}.sarif
- name: Vulz Count
shell: bash
run: |
TRIVY_COUNT=$(cat ${{ github.workspace }}/trivy-results-${{ needs.version.outputs.tag }}.sarif | jq '.runs[0].results | length')
echo "TRIVY_COUNT: $TRIVY_COUNT"
echo "Image Vulnerability scan output" >> $GITHUB_STEP_SUMMARY
echo "Image ID: registry.k8s.io/ingress-nginx/controller@${{ needs.version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Trivy Count: $TRIVY_COUNT" >> $GITHUB_STEP_SUMMARY