Skip to content

Commit

Permalink
github: Add Trivy snap scanning
Browse files Browse the repository at this point in the history
Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Sep 23, 2024
1 parent 6cdcf23 commit 4442aa5
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,44 @@ jobs:
sarif_file: "trivy-lxd-repo-scan-results.sarif"
sha: ${{ env.GITHUB_SHA }}
ref: refs/heads/main

trivy-snap:
name: Trivy vulnerability scanner - Snap
runs-on: ubuntu-22.04
strategy:
matrix:
version:
- latest
- "5.21"
- "5.0"
- "4.0"
risk:
- stable
permissions:
security-events: write # for uploading SARIF results to the security tab
if: ${{ ( github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main # All snap scanner results are placed on the main 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 on the snap
run: |
snap download lxd --channel=${{ matrix.version }}/${{ matrix.risk }}
unsquashfs ./lxd*.snap
./trivy rootfs ./squashfs-root/ --format sarif > ${{ matrix.version }}-${{ matrix.risk }}.sarif
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "${{ matrix.version }}-${{ matrix.risk }}.sarif"
sha: ${{ env.GITHUB_SHA }}
ref: refs/heads/main

0 comments on commit 4442aa5

Please sign in to comment.