Skip to content

Commit 3545d99

Browse files
committed
ci(github-actions): add semgrep scans
1 parent 1366d99 commit 3545d99

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

.github/workflows/semgrep.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
name: Semgrep
3+
4+
on:
5+
push:
6+
branches: ["main"]
7+
pull_request:
8+
branches: ["main"]
9+
schedule:
10+
- cron: "0 0 * * 0"
11+
workflow_dispatch:
12+
13+
permissions: {}
14+
15+
jobs:
16+
semgrep:
17+
permissions:
18+
# Required to read the repo
19+
contents: read
20+
# Required to upload the SARIF file to the security tab
21+
security-events: write
22+
runs-on: ubuntu-latest
23+
container:
24+
image: semgrep/semgrep
25+
steps:
26+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
27+
with:
28+
persist-credentials: false
29+
- name: Run Semgrep for PR
30+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.user.login != 'dependabot[bot]' }}
31+
shell: bash
32+
run: |
33+
set -euo pipefail
34+
IFS=$'\n\t'
35+
semgrep ci --baseline-commit --code --error \
36+
--config p/c \
37+
--config p/ci \
38+
--config p/docker \
39+
--config p/expressjs \
40+
--config p/flask \
41+
--config p/insecure-transport \
42+
--config p/jwt \
43+
--config p/python \
44+
--config p/r2c \
45+
--config p/react \
46+
--config p/ruby \
47+
--config p/secrets \
48+
--config p/security-audit
49+
- name: Run Semgrep for push
50+
if: ${{ github.event_name != 'pull_request' }}
51+
shell: bash
52+
run: |
53+
set -euo pipefail
54+
IFS=$'\n\t'
55+
semgrep scan --sarif --sarif-output=semgrep-results.sarif \
56+
--config p/c \
57+
--config p/ci \
58+
--config p/docker \
59+
--config p/expressjs \
60+
--config p/flask \
61+
--config p/insecure-transport \
62+
--config p/jwt \
63+
--config p/python \
64+
--config p/r2c \
65+
--config p/react \
66+
--config p/ruby \
67+
--config p/secrets \
68+
--config p/security-audit
69+
- name: Upload Semgrep scan results to GitHub Security tab
70+
if: ${{ github.event_name != 'pull_request' }}
71+
uses: github/codeql-action/upload-sarif@192325c86100d080feab897ff886c34abd4c83a3 # v3.29.5
72+
with:
73+
sarif_file: semgrep-results.sarif

0 commit comments

Comments
 (0)