Security scan #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Security scan | |
on: | |
schedule: | |
- cron: '0 10 * * *' | |
jobs: | |
scan: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
# Latest branches | |
- { branch: main, channel: latest/edge } | |
# Stable branches | |
# Add branches to test here | |
steps: | |
- name: Checking out repo | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{matrix.branch}} | |
- name: Setup Trivy vulnerability scanner | |
run: | | |
mkdir -p sarifs | |
VER=$(curl --silent -qI https://github.com/aquasecurity/trivy/releases/latest | awk -F '/' '/^location/ {print substr($NF, 1, length($NF)-1)}'); | |
wget https://github.com/aquasecurity/trivy/releases/download/${VER}/trivy_${VER#v}_Linux-64bit.tar.gz | |
tar -zxvf ./trivy_${VER#v}_Linux-64bit.tar.gz | |
- name: Run Trivy vulnerability scanner in repo mode | |
uses: aquasecurity/trivy-action@master | |
with: | |
scan-type: "fs" | |
ignore-unfixed: true | |
format: "sarif" | |
output: "trivy-k8s-repo-scan--results.sarif" | |
severity: "MEDIUM,HIGH,CRITICAL" | |
- name: Gather Trivy repo scan results | |
run: | | |
cp trivy-k8s-repo-scan--results.sarif ./sarifs/ | |
- name: Run Trivy vulnerability scanner on the snap | |
run: | | |
snap download k8s --channel ${{ matrix.channel }} | |
mv ./k8s*.snap ./k8s.snap | |
unsquashfs k8s.snap | |
./trivy rootfs ./squashfs-root/ --format sarif > sarifs/snap.sarif | |
- name: Get HEAD sha | |
run: | | |
SHA="$(git rev-parse HEAD)" | |
echo "head_sha=$SHA" >> "$GITHUB_ENV" | |
- name: Upload Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: "sarifs" | |
sha: ${{ env.head_sha }} | |
ref: refs/heads/${{matrix.branch}} |