Skip to content

Commit 4b903a3

Browse files
author
Shiva Sankar
authored
Add semgrep scan
Add semgrep scan
1 parent f879f6c commit 4b903a3

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/semgrep.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Semgrep - SAST Scan
2+
3+
on:
4+
pull_request_target:
5+
types: [edited, opened, synchronize, ready_for_review]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
semgrep:
13+
permissions:
14+
contents: read # for actions/checkout to fetch code
15+
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
16+
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
17+
runs-on: ubuntu-latest
18+
container:
19+
image: semgrep/semgrep:1.104.0
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
ref: ${{ github.event.pull_request.head.ref }}
25+
repository: ${{ github.event.pull_request.head.repo.full_name }}
26+
27+
- name: Checkout semgrep-rules repo
28+
uses: actions/checkout@v4
29+
with:
30+
repository: sourcegraph/security-semgrep-rules
31+
token: ${{ secrets.GH_SEMGREP_SAST_TOKEN }}
32+
path: semgrep-rules
33+
34+
- name: Run Semgrep SAST Scan
35+
run: |
36+
mv semgrep-rules ../
37+
semgrep ci -f ../semgrep-rules/semgrep-rules/ --metrics=off --oss-only --suppress-errors --sarif -o results.sarif --exclude='semgrep-rules' --baseline-commit "$(git merge-base main HEAD)" || true
38+
- name: Upload SARIF file
39+
uses: github/codeql-action/upload-sarif@v3
40+
with:
41+
sarif_file: results.sarif

0 commit comments

Comments
 (0)