-
Notifications
You must be signed in to change notification settings - Fork 6
58 lines (52 loc) · 1.62 KB
/
sast.yaml
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
55
56
57
name: Semgrep SAST
on:
pull_request:
branches:
- develop
- staging
- production
- stable
- main
- master
env:
# Fail workflow or not if vulnerabilities found
FAIL_ON_VULNERABILITIES: true
# List of paths (space separated) to ignore
# Supports PATTERNS
# EXCLUDE_PATHS: 'foo bar/baz file.txt dir/*.yml'
EXCLUDE_PATHS: ''
# List of rules (space separated) to ignore
# EXCLUDE_RULES: 'generic.secrets.security.detected-aws-account-id.detected-aws-account-id'
# See https://github.com/semgrep/semgrep-rules for rules registry
EXCLUDE_RULES: ''
jobs:
semgrep:
name: semgrep-oss/scan
runs-on: ubuntu-latest
container:
image: semgrep/semgrep
steps:
- uses: actions/checkout@v4
- name: Scan
shell: bash
run: |
EXCLUDED_PATHS=()
if [[ ! -z $EXCLUDE_PATHS ]]; then
for path in $EXCLUDE_PATHS; do
EXCLUDED_PATHS+=("--exclude $path")
done
fi
EXCLUDED_RULES=()
if [[ ! -z $EXCLUDE_RULES ]]; then
for rule in $EXCLUDE_RULES; do
EXCLUDED_RULES+=("--exclude-rule $rule")
done
fi
if [[ $FAIL_ON_VULNERABILITIES == "true" ]]; then
semgrep scan --config auto ${EXCLUDED_PATHS[@]} ${EXCLUDED_RULES[@]} --error --verbose
elif [[ $FAIL_ON_VULNERABILITIES == "false" ]]; then
semgrep scan --config auto ${EXCLUDED_PATHS[@]} ${EXCLUDED_RULES[@]} --error --verbose || true
else
echo "Bad FAIL_ON_VULNERABILITIES env var value"
exit 1
fi