Skip to content

Commit c9e4cc3

Browse files
committed
ci: add security scan with trivy
Security scan with trivy will be run on push to main and dev, pull request, and daily. trivy will skip scanning vendor subdirectory because the agent is not using code from that directory.
1 parent bae6375 commit c9e4cc3

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Security scan
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- dev
7+
pull_request:
8+
schedule:
9+
- cron: '0 9 * * *' # Same time as CI Cron
10+
11+
jobs:
12+
trivy-scan:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout newrelic-php-agent code
16+
uses: actions/checkout@v4
17+
with:
18+
path: php-agent
19+
- name: Run Trivy in table mode
20+
# Table output is only useful when running on a pull request or push.
21+
if: contains(fromJSON('["push", "pull_request"]'), github.event_name)
22+
uses: aquasecurity/[email protected]
23+
with:
24+
scan-type: fs
25+
scan-ref: ./php-agent
26+
scanners: vuln,misconfig
27+
skip-dirs: vendor
28+
format: table
29+
exit-code: 1
30+
ignore-unfixed: true
31+
severity: CRITICAL,HIGH,MEDIUM,LOW
32+
33+
- name: Run Trivy in report mode
34+
# Only generate sarif when running nightly on the dev branch.
35+
if: ${{ github.event_name == 'schedule' }}
36+
uses: aquasecurity/[email protected]
37+
with:
38+
scan-type: fs
39+
skip-dirs: vendor
40+
format: sarif
41+
output: trivy-results.sarif
42+
ignore-unfixed: true
43+
severity: 'CRITICAL,HIGH,MEDIUM,LOW'
44+
45+
- name: Upload Trivy scan results to GitHub Security tab
46+
# Only upload sarif when running nightly on the dev branch.
47+
if: ${{ github.event_name == 'schedule' }}
48+
uses: github/codeql-action/upload-sarif@v3
49+
with:
50+
sarif_file: trivy-results.sarif

0 commit comments

Comments
 (0)