Create sast.yml (#3) #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: SAST (Semgrep) | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| semgrep: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| security-events: write # needed to upload SARIF | |
| steps: | |
| - name: Harden runner | |
| uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 | |
| - name: Install pipx + Semgrep (pinned) | |
| run: | | |
| set -euxo pipefail | |
| sudo apt-get update | |
| sudo apt-get install -y pipx | |
| pipx ensurepath | |
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" | |
| pipx install semgrep==1.83.0 | |
| semgrep --version | |
| # Note: no --error flag; job will not fail on findings. | |
| - name: Run Semgrep and produce SARIF | |
| run: | | |
| semgrep scan \ | |
| --config=p/ci \ | |
| --config=p/security-audit \ | |
| --metrics=off \ | |
| --sarif -o semgrep.sarif | |
| - name: Upload SARIF to Code Scanning | |
| uses: github/codeql-action/upload-sarif@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8 | |
| with: | |
| sarif_file: semgrep.sarif | |
| wait-for-processing: true |