Skip to content

Commit 1344046

Browse files
committed
feat: add npm audit and trivy CI checks on PRs
Ticket: WP-6506
1 parent 9723ab9 commit 1344046

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.github/workflows/build-and-test.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,71 @@ jobs:
9999
- name: Lint
100100
run: npm run lint
101101

102+
npm-audit:
103+
name: Security - NPM Audit
104+
runs-on: ubuntu-latest
105+
steps:
106+
- name: Checkout
107+
uses: actions/checkout@v4
108+
109+
- name: Setup Node.js
110+
uses: actions/setup-node@v4
111+
with:
112+
node-version: ${{ inputs.node-version }}
113+
cache: 'npm'
114+
115+
- name: Cache dependencies
116+
uses: actions/cache@v3
117+
id: node-modules-cache
118+
with:
119+
path: '**/node_modules'
120+
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
121+
restore-keys: |
122+
${{ runner.os }}-modules-
123+
124+
- name: Install dependencies
125+
if: steps.node-modules-cache.outputs.cache-hit != 'true'
126+
run: npm ci
127+
128+
- name: Run npm audit
129+
run: npm audit --audit-level=moderate
130+
131+
trivy-scan:
132+
name: Security - Trivy Scan
133+
runs-on: ubuntu-latest
134+
steps:
135+
- name: Checkout
136+
uses: actions/checkout@v4
137+
138+
- name: Setup Node.js
139+
uses: actions/setup-node@v4
140+
with:
141+
node-version: ${{ inputs.node-version }}
142+
cache: 'npm'
143+
144+
- name: Cache dependencies
145+
uses: actions/cache@v3
146+
id: node-modules-cache
147+
with:
148+
path: '**/node_modules'
149+
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
150+
restore-keys: |
151+
${{ runner.os }}-modules-
152+
153+
- name: Install dependencies
154+
if: steps.node-modules-cache.outputs.cache-hit != 'true'
155+
run: npm ci
156+
157+
- name: Run Trivy vulnerability scanner
158+
uses: aquasecurity/trivy-action@master
159+
with:
160+
scan-type: 'fs'
161+
scan-ref: '.'
162+
format: 'table'
163+
severity: 'CRITICAL,HIGH'
164+
exit-code: '1'
165+
ignore-unfixed: true
166+
102167
test:
103168
name: Test
104169
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)