Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Semgrep to new container version #2140

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions code-scanning/semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,54 @@
name: Semgrep

on:
# Scan mainline branches and report all findings:
push:
branches: [ $default-branch, $protected-branches ]
# Scan changed files in PRs (diff-aware scanning):
# The branches below must be a subset of the branches above
pull_request:
# The branches below must be a subset of the branches above
branches: [ $default-branch ]
# Schedule the CI job (this method uses cron syntax):
schedule:
- cron: $cron-weekly
# Scan on-demand through GitHub Actions interface:
workflow_dispatch: {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
workflow_dispatch: {}
workflow_dispatch:


permissions:
contents: read

jobs:
semgrep:
# User definable name of this GitHub Actions job.
name: semgrep/ci
# If you are self-hosting, change the following `runs-on` value:
runs-on: ubuntu-latest
# Action permissions
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
name: Scan
runs-on: ubuntu-latest

container:
# A Docker image with Semgrep installed.
image: returntocorp/semgrep:7843a979bf88d9d16c476e9f7f547b573187f395532b1f74825fd58c6463c5b0

# Skip any PR created by dependabot to avoid permission issues:
if: (github.actor != 'dependabot[bot]')

steps:
# Checkout project source
# Fetch project source with GitHub Actions Checkout.
- uses: actions/checkout@v4

# Scan code using project's configuration on https://semgrep.dev/manage
- uses: returntocorp/semgrep-action@fcd5ab7459e8d91cb1777481980d1b18b4fc6735
with:
publishToken: ${{ secrets.SEMGREP_APP_TOKEN }}
publishDeployment: ${{ secrets.SEMGREP_DEPLOYMENT_ID }}
generateSarif: "1"
# Run the "semgrep" command on the command line of the docker image.
- run: semgrep . --sarif --output semgrep.sarif
env:
# Connect to Semgrep Cloud Platform through your SEMGREP_APP_TOKEN.
# Generate a token from Semgrep Cloud Platform > Settings
# and add it to your GitHub secrets.
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
# Add the rules that Semgrep uses by setting the SEMGREP_RULES environment variable.
# more at semgrep.dev/explore
SEMGREP_RULES: p/default
Comment on lines +59 to +61
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Add the rules that Semgrep uses by setting the SEMGREP_RULES environment variable.
# more at semgrep.dev/explore
SEMGREP_RULES: p/default

Noting that SEMGREP_RULES should not be set in the same job as SEMGREP_APP_TOKEN, per the latest docs: https://semgrep.dev/docs/semgrep-ci/ci-environment-variables/#semgrep_app_token

Screenshot 2024-03-25 at 3 42 55 PM


# Upload SARIF file generated in previous step
- name: Upload SARIF file
Expand Down
Loading