|
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. |
3 | 5 | name: semgrep |
4 | 6 |
|
5 | 7 | on: |
|
10 | 12 | schedule: |
11 | 13 | - cron: "13 7 * * 1" # weekly full sweep (Mon 07:13 UTC) — offset from gitleaks (06:27) |
12 | 14 |
|
| 15 | +# Least privilege. security-events:write publishes SARIF to the Code Scanning tab (free on |
| 16 | +# public repos). Semgrep itself needs no write scope. |
13 | 17 | permissions: |
14 | 18 | contents: read |
15 | 19 | security-events: write |
16 | 20 |
|
17 | 21 | jobs: |
18 | 22 | sast: |
19 | 23 | 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