Skip to content

Commit 2fc84b5

Browse files
authored
chore: Add Semgrep CI integration (#296)
Add Semgrep CI integration
1 parent bdccda5 commit 2fc84b5

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/semgrep.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Semgrep
2+
3+
on:
4+
# Scan changed files in PRs (diff-aware scanning):
5+
pull_request: {}
6+
# Scan on-demand through GitHub Actions interface:
7+
workflow_dispatch: {}
8+
# Scan mainline branches and report all findings:
9+
push:
10+
branches: ["main"]
11+
# Schedule the CI job (this method uses cron syntax):
12+
schedule:
13+
- cron: '15 11 * * *' # Sets Semgrep to scan every day at 11:15 UTC.
14+
15+
jobs:
16+
semgrep:
17+
name: semgrep/ci
18+
runs-on: ubuntu-latest
19+
permissions:
20+
security-events: write
21+
contents: read
22+
actions: read
23+
24+
container:
25+
image: semgrep/semgrep@sha256:85f9de554201cc891c470774bb93a7f4faf41ea198ddccc34a855b53f7a51443 # v1.127.1
26+
27+
# Skip any PR created by dependabot to avoid permission issues:
28+
if: (github.actor != 'dependabot[bot]')
29+
30+
steps:
31+
- name: Harden Runner
32+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
33+
with:
34+
egress-policy: audit
35+
- name: Checkout code
36+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.5.4
37+
# Run the "semgrep ci" command on the command line of the docker image.
38+
- run: semgrep ci --sarif > semgrep.sarif
39+
env:
40+
# Connect to Semgrep AppSec Platform through your SEMGREP_APP_TOKEN.
41+
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
42+
43+
- name: Upload SARIF file for GitHub Advanced Security Dashboard
44+
uses: github/codeql-action/upload-sarif@fca7ace96b7d713c7035871441bd52efbe39e27e # v3.28.19
45+
with:
46+
sarif_file: semgrep.sarif
47+

0 commit comments

Comments
 (0)