Skip to content

Commit

Permalink
Set up Semgrep scan
Browse files Browse the repository at this point in the history
Add a CI Job to run a Semgrep scan on this codebase. The job is
configured to run only on the `main` branch because it requires access
to the `SEMGREP_APP_TOKEN` secret which may not be accessible on PRs
from external contributors. The job will upload the report as a SARIF
file to GitHub for ingestion without having to rely on the Semgrep web
application.

Signed-off-by: Eric Cornelissen <[email protected]>
  • Loading branch information
ericcornelissen committed Nov 28, 2024
1 parent 946dd34 commit 4058f9a
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# MIT No Attribution
#
# Copyright 2024 Eric Cornelissen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
# software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify,
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

name: Semgrep
on:
push:
branches:
- main

permissions: read-all

jobs:
semgrep:
name: Semgrep
runs-on: ubuntu-24.04
permissions:
security-events: write # To upload SARIF results
container:
image: semgrep/semgrep
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Perform Semgrep analysis
run: semgrep ci --sarif --output semgrep.sarif
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
- name: Upload Semgrep report to GitHub
uses: github/codeql-action/upload-sarif@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
if: ${{ failure() || success() }}
with:
sarif_file: semgrep.sarif

0 comments on commit 4058f9a

Please sign in to comment.