1+ # Name of this GitHub Actions workflow.
2+ name : Semgrep
3+
4+ on :
5+ # Scan changed files in PRs (diff-aware scanning):
6+ # The branches below must be a subset of the branches above
7+ pull_request :
8+ branches : ["master", "main"]
9+ push :
10+ branches : ["master", "main"]
11+ schedule :
12+ - cron : ' 0 6 * * *'
13+
14+
15+ permissions :
16+ contents : read
17+ id-token : none # explicit deny — workflow does not request OIDC federation
18+
19+ jobs :
20+ semgrep :
21+ # User definable name of this GitHub Actions job.
22+ permissions :
23+ contents : read # for actions/checkout to fetch code
24+ security-events : write # for github/codeql-action/upload-sarif to upload SARIF results
25+ id-token : none # explicit deny — Semgrep job does not need OIDC federation
26+ name : semgrep/ci
27+ # If you are self-hosting, change the following `runs-on` value:
28+ runs-on : ubuntu-latest
29+
30+ container :
31+ # A Docker image with Semgrep installed. Do not change this.
32+ image : semgrep/semgrep:1.166.0
33+
34+ # Skip any PR created by dependabot to avoid permission issues:
35+ if : (github.actor != 'dependabot[bot]')
36+
37+ steps :
38+ # Fetch project source with GitHub Actions Checkout.
39+ - uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
40+ # Run the "semgrep ci" command on the command line of the docker image.
41+ - run : semgrep ci --sarif --output=semgrep.sarif
42+ env :
43+ # Add the rules that Semgrep uses by setting the SEMGREP_RULES environment variable.
44+ SEMGREP_RULES : p/default # more at semgrep.dev/explore
45+
46+ - name : Upload SARIF file for GitHub Advanced Security Dashboard
47+ uses : github/codeql-action/upload-sarif@6c089f53dd51dc3fc7e599c3cb5356453a52ca9e # v2.20.0
48+ with :
49+ sarif_file : semgrep.sarif
50+ if : always()
0 commit comments