name: SAST

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

permissions:
  contents: read

concurrency:
  group: sast-${{ github.ref }}
  cancel-in-progress: true

# Static Application Security Testing via Semgrep. Scans first-party
# source against TypeScript, JavaScript, React, and OWASP top-ten
# rulesets. Findings fail the build — silence false positives with
# `.semgrepignore` (path-level) or inline `// nosemgrep: <rule-id>` with
# a justification.

jobs:
  semgrep:
    name: Semgrep
    runs-on: ubuntu-latest
    timeout-minutes: 10
    if: github.actor != 'dependabot[bot]'
    container:
      image: semgrep/semgrep:1.168.0@sha256:59fbed6127ea7c5dde3ba6a85142733bb20ea9aaa36120c953904f1539aaf66e
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          persist-credentials: false
      - name: Run Semgrep
        run: |
          semgrep scan \
            --config=p/typescript \
            --config=p/javascript \
            --config=p/react \
            --config=p/owasp-top-ten \
            --error \
            --metrics=off
