Skip to content

Commit e3250c2

Browse files
authored
Merge pull request #10 from securitybunker/fix-semgrep-inline
Fix Semgrep workflow startup failure (inline instead of private reusable workflow)
2 parents aa1a9d2 + ebf7a1c commit e3250c2

1 file changed

Lines changed: 47 additions & 5 deletions

File tree

.github/workflows/semgrep.yml

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# Caller: scans THIS repo using the shared reusable Semgrep workflow in databunker-devops.
2-
# Ruleset = Java language pack + the common security packs (see semgrep-reusable.yml).
1+
# Self-contained Semgrep SAST scan (Semgrep OSS engine + community rules — LGPL, no account needed).
2+
# Inlined rather than calling the shared reusable workflow in databunker-devops, because GitHub
3+
# blocks a PUBLIC repo from using a reusable workflow stored in a PRIVATE repo (org access does
4+
# not lift this). Keep the ruleset in sync with the other public SDK repos.
35
name: semgrep
46

57
on:
@@ -10,13 +12,53 @@ on:
1012
schedule:
1113
- cron: "13 7 * * 1" # weekly full sweep (Mon 07:13 UTC) — offset from gitleaks (06:27)
1214

15+
# Least privilege. security-events:write publishes SARIF to the Code Scanning tab (free on
16+
# public repos). Semgrep itself needs no write scope.
1317
permissions:
1418
contents: read
1519
security-events: write
1620

1721
jobs:
1822
sast:
1923
name: sast # display + required-check name
20-
uses: securitybunker/databunker-devops/.github/workflows/semgrep-reusable.yml@main
21-
with:
22-
config: "p/java p/secrets p/security-audit p/owasp-top-ten"
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
31+
with:
32+
python-version: "3.12"
33+
34+
- name: Install Semgrep (pinned)
35+
run: pip install semgrep==1.170.0 # bump deliberately (semgrep.dev/docs/release-notes)
36+
37+
- name: Run Semgrep
38+
env:
39+
SEMGREP_SEND_METRICS: "off" # no telemetry; community rules only
40+
run: |
41+
# --error: exit non-zero on any finding -> blocks merge when set as a required check.
42+
# SARIF is written before the non-zero exit, so the upload steps (if: always()) run.
43+
semgrep scan \
44+
--config p/java \
45+
--config p/secrets \
46+
--config p/security-audit \
47+
--config p/owasp-top-ten \
48+
--error \
49+
--sarif --output semgrep.sarif
50+
51+
- name: Upload SARIF to Code Scanning
52+
if: always() # publish findings even when the scan fails the check
53+
uses: github/codeql-action/upload-sarif@bb16b9baa2ec4010b29f5c606d57d01190139edd # v4.37.1
54+
with:
55+
sarif_file: semgrep.sarif
56+
category: semgrep
57+
58+
- name: Upload SARIF artifact (dated evidence, retained 180d)
59+
if: always() # keep the report for triage + audit evidence even on failure
60+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
61+
with:
62+
name: semgrep-report-${{ github.sha }}
63+
path: semgrep.sarif
64+
retention-days: 180

0 commit comments

Comments
 (0)