Skip to content

Commit 9997966

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

File tree

14 files changed

+73
-91
lines changed

14 files changed

+73
-91
lines changed

.github/actions/ubuntu16-build-action/Dockerfile

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/actions/ubuntu16-build-action/action.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/actions/ubuntu16-build-action/build.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/actions/ubuntu18-build-action/Dockerfile

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/actions/ubuntu18-build-action/action.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/actions/ubuntu18-build-action/build.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/actions/ubuntu20-build-action/Dockerfile

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/actions/ubuntu20-build-action/action.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/actions/ubuntu20-build-action/build.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Security scan
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- dev
7+
pull_request:
8+
schedule:
9+
- cron: '0 0 * * 0' # Every Sunday at 12:00 AM
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+
trivy-config: ./php-agent/trivy.yaml
27+
trivyignores: ./php-agent/.trivyignore
28+
format: table
29+
exit-code: 1
30+
31+
- name: Run Trivy in report mode
32+
# Only generate sarif when running nightly on the dev branch.
33+
if: ${{ github.event_name == 'schedule' }}
34+
uses: aquasecurity/[email protected]
35+
with:
36+
scan-type: fs
37+
scan-ref: ./php-agent
38+
trivy-config: ./php-agent/trivy.yaml
39+
trivyignores: ./php-agent/.trivyignore
40+
format: sarif
41+
output: trivy-results.sarif
42+
43+
- name: Upload Trivy scan results to GitHub Security tab
44+
# Only upload sarif when running nightly on the dev branch.
45+
if: ${{ github.event_name == 'schedule' }}
46+
uses: github/codeql-action/upload-sarif@v3
47+
with:
48+
sarif_file: trivy-results.sarif

0 commit comments

Comments
 (0)