Skip to content

Merge pull request #372 from opensensor/dependabot/npm_and_yarn/npm_a… #529

Merge pull request #372 from opensensor/dependabot/npm_and_yarn/npm_a…

Merge pull request #372 from opensensor/dependabot/npm_and_yarn/npm_a… #529

name: Container Security Scan
on:
push:
branches: [main]
tags:
- '*.*.*'
workflow_dispatch:
permissions:
contents: read
security-events: write
jobs:
trivy:
name: Trivy Container Scan
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v5
with:
submodules: recursive
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build Docker image for scanning
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64
push: false
load: true
tags: lightnvr:scan
- name: Install Trivy
run: |
sudo apt-get update
sudo apt-get install -y wget apt-transport-https gnupg
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | gpg --dearmor | sudo tee /usr/share/keyrings/trivy.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb generic main" | sudo tee /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install -y trivy
- name: Run Trivy vulnerability scanner (SARIF)
id: trivy-sarif
run: |
trivy image \
--format sarif \
--output trivy-results.sarif \
--severity CRITICAL,HIGH,MEDIUM \
--exit-code 0 \
lightnvr:scan
- name: Upload Trivy SARIF to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
if: always() && steps.trivy-sarif.outcome == 'success'
with:
sarif_file: 'trivy-results.sarif'
category: 'container-scanning'
- name: Run Trivy (table output for logs)
if: always() && steps.trivy-sarif.outcome == 'success'
run: |
trivy image \
--format table \
--severity CRITICAL,HIGH \
--exit-code 0 \
lightnvr:scan
- name: Upload Trivy report
uses: actions/upload-artifact@v6
if: always() && steps.trivy-sarif.outcome == 'success'
with:
name: trivy-scan-results
path: trivy-results.sarif
retention-days: 30