Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add security scan with trivy #985

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/security-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Security scan
on:
push:
branches:
- main
- dev
pull_request:
schedule:
- cron: '0 9 * * *' # Same time as CI Cron
bduranleau-nr marked this conversation as resolved.
Show resolved Hide resolved

jobs:
trivy-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout newrelic-php-agent code
uses: actions/checkout@v4
with:
path: php-agent
- name: Run Trivy in table mode
# Table output is only useful when running on a pull request or push.
if: contains(fromJSON('["push", "pull_request"]'), github.event_name)
uses: aquasecurity/[email protected]
with:
scan-type: fs
scan-ref: ./php-agent
trivy-config: ./php-agent/trivy.yaml
trivyignores: ./php-agent/.trivyignore
format: table
exit-code: 1

- name: Run Trivy in report mode
# Only generate sarif when running nightly on the dev branch.
if: ${{ github.event_name == 'schedule' }}
uses: aquasecurity/[email protected]
with:
scan-type: fs
scan-ref: ./php-agent
trivy-config: ./php-agent/trivy.yaml
trivyignores: ./php-agent/.trivyignore
format: sarif
output: trivy-results.sarif

- name: Upload Trivy scan results to GitHub Security tab
# Only upload sarif when running nightly on the dev branch.
if: ${{ github.event_name == 'schedule' }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: trivy-results.sarif
2 changes: 2 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore missing HEALTHCHECK in Dockerfile - devenv service from files/Dockerfile doesn't need it:
AVD-DS-0026
18 changes: 18 additions & 0 deletions trivy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
db:
repository:
- mirror.gcr.io/aquasec/trivy-db:2

scan:
scanners:
- vuln
- misconfig
skip-dirs: vendor

severities:
- CRITICAL
- HIGH
- MEDIUM
- LOW

vulnerability:
ignore-unfixed: true
Loading