|
1 | | -name: Semgrep SAST |
| 1 | +# This repository is public and cannot call reusable workflows from a private |
| 2 | +# repository (regulaforensics/reusable-workflows). The logic below is a local |
| 3 | +# copy that mirrors the reusable workflow exactly. SHA pins are kept up-to-date |
| 4 | +# by Renovate (see renovate.json). |
| 5 | +name: SAST |
2 | 6 |
|
3 | 7 | on: |
4 | 8 | pull_request: |
|
10 | 14 | - main |
11 | 15 | - master |
12 | 16 |
|
13 | | -env: |
14 | | - # Fail workflow or not if vulnerabilities found |
15 | | - FAIL_ON_VULNERABILITIES: true |
16 | | - # List of paths (space separated) to ignore |
17 | | - # Supports PATTERNS |
18 | | - # EXCLUDE_PATHS: 'foo bar/baz file.txt dir/*.yml' |
19 | | - EXCLUDE_PATHS: 'generator-templates regula/documentreader/webclient/gen .github' |
20 | | - # List of rules (space separated) to ignore |
21 | | - # EXCLUDE_RULES: 'generic.secrets.security.detected-aws-account-id.detected-aws-account-id' |
22 | | - # See https://github.com/semgrep/semgrep-rules for rules registry |
23 | | - EXCLUDE_RULES: '' |
24 | | - |
25 | 17 | jobs: |
26 | 18 | semgrep: |
27 | 19 | name: semgrep-oss/scan |
28 | 20 | runs-on: ubuntu-latest |
29 | 21 | container: |
30 | | - image: semgrep/semgrep |
| 22 | + image: semgrep/semgrep@sha256:65dcd4408adda7c183a6b4550cb1e9b19f7f627a6fbb7e0559bd466bedc44d7b |
31 | 23 | steps: |
32 | | - - uses: actions/checkout@v4 |
| 24 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
33 | 25 | - name: Scan |
34 | 26 | shell: bash |
| 27 | + env: |
| 28 | + EXCLUDE_PATHS: 'generator-templates regula/documentreader/webclient/gen .github' |
| 29 | + EXCLUDE_RULES: '' |
35 | 30 | run: | |
36 | 31 | EXCLUDED_PATHS=() |
37 | | - if [[ ! -z $EXCLUDE_PATHS ]]; then |
| 32 | + if [[ -n "$EXCLUDE_PATHS" ]]; then |
38 | 33 | for path in $EXCLUDE_PATHS; do |
39 | | - EXCLUDED_PATHS+=("--exclude $path") |
| 34 | + EXCLUDED_PATHS+=("--exclude" "$path") |
40 | 35 | done |
41 | 36 | fi |
42 | 37 |
|
43 | 38 | EXCLUDED_RULES=() |
44 | | - if [[ ! -z $EXCLUDE_RULES ]]; then |
| 39 | + if [[ -n "$EXCLUDE_RULES" ]]; then |
45 | 40 | for rule in $EXCLUDE_RULES; do |
46 | | - EXCLUDED_RULES+=("--exclude-rule $rule") |
| 41 | + EXCLUDED_RULES+=("--exclude-rule" "$rule") |
47 | 42 | done |
48 | 43 | fi |
49 | 44 |
|
50 | | - if [[ $FAIL_ON_VULNERABILITIES == "true" ]]; then |
51 | | - semgrep scan --config auto ${EXCLUDED_PATHS[@]} ${EXCLUDED_RULES[@]} --error --verbose |
52 | | - elif [[ $FAIL_ON_VULNERABILITIES == "false" ]]; then |
53 | | - semgrep scan --config auto ${EXCLUDED_PATHS[@]} ${EXCLUDED_RULES[@]} --error --verbose || true |
54 | | - else |
55 | | - echo "Bad FAIL_ON_VULNERABILITIES env var value" |
56 | | - exit 1 |
57 | | - fi |
58 | | -
|
| 45 | + semgrep scan --config auto "${EXCLUDED_PATHS[@]}" "${EXCLUDED_RULES[@]}" --error --verbose |
0 commit comments