-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (53 loc) · 1.77 KB
/
snyk-sast.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen".
name: snyk-sast
on:
workflow_call: {}
workflow_dispatch: {}
jobs:
sast-scan:
name: Run SAST Scan with Snyk
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Setup node 20
id: setup-node20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Get npm global installation root folder
id: get-npm-root
run: |-
NPM_ROOT_LIBS=$(npm root -g)
NPM_ROOT=$(echo $NPM_ROOT_LIBS | sed 's/\/lib\/node_modules//')
echo "npm-root-global-libs=$NPM_ROOT_LIBS"
echo "path=$NPM_ROOT"
echo path=$NPM_ROOT >> $GITHUB_OUTPUT
- name: Cache global npm folder
id: cache-npmg
uses: actions/cache@v4
with:
path: ${{ steps.get-npm-root.outputs.path }}
key: ${{ runner.os }}-npm-global-snyk-${{ hashFiles('.projenrc.ts') }}
- name: Install snyk and snyk-delta
id: install-snyk
if: steps.cache-npmg.outputs.cache-hit != 'true'
run: npm i -g [email protected] [email protected]
- name: Checkout HEAD
id: checkout
uses: actions/checkout@v4
- name: Authenticate Snyk
id: snyk-auth
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
run: |-
snyk auth $SNYK_TOKEN
snyk config set org=vianho
- name: Run snyk code on HEAD
id: snyk-sast
run: |-
SHA=$(git log -1 '--format=format:%H')
RESULT_PATH="${{ github.workspace }}/snyk_code_result_$SHA.json"
snyk code test --severity-threshold=high --json > $RESULT_PATH
echo "result-path=$RESULT_PATH" >> $GITHUB_OUTPUT
continue-on-error: false