-
Notifications
You must be signed in to change notification settings - Fork 0
chore: upgrade Semgrep to latest #11
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,26 @@ | ||
| name: Test Semgrep Rules | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| main: | ||
| runs-on: ubuntu-22.04 | ||
|
|
||
| # Note: the non-root flavor doesn't work on GHA (e.g., 1.56.0-nonroot). | ||
| container: returntocorp/semgrep@sha256:396f4ad7a655289e764ab2f92733e6195c166ff2f042e0d40505a5850432b9ac # 1.63.0 | ||
| runs-on: ubuntu-24.04 | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| # Checks for syntax errors and runs 'p/semgrep-rule-lints'. | ||
| - name: Validate Rules | ||
| shell: bash | ||
| run: | | ||
| config_args=() | ||
|
|
||
| # As of semgrep 1.58.0, hidden directories are no longer excluded | ||
| # when passing "--validate ./" thus we need to manually exclude hidden | ||
| # directories. | ||
| while IFS= read -r -d '' dir; do | ||
| config_args+=( "--config=$dir" ) | ||
| done < <(find . -maxdepth 1 -mindepth 1 -type d -not -path '*/\.*' -print0) | ||
|
|
||
| semgrep scan --validate "${config_args[@]}" | ||
| run: make validate | ||
|
|
||
| - name: Test Rules | ||
| run: semgrep --test ./ | ||
| run: make test | ||
|
|
||
| # This runs the rules from https://github.com/semgrep/semgrep-rules/tree/835867f89e4ba07f8bb4a6a1619507408e63e9b0/yaml/semgrep | ||
| # to ensure best practices are followed. The CI will only fail on error. | ||
| - name: Run Semgrep Rules Recommendation Checks | ||
| run: semgrep --config=r/yaml.semgrep --severity ERROR ./ | ||
| run: make checks | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| semgrep_image ?= returntocorp/semgrep:1.153.1@sha256:50b839b576d76426efd3e5cffda2db0d8c403f53aa76e91d42ccf51485ac336c | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplication (image tag) but I don't see a way to avoid that.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I don't think there is any way to not duplicate - unless we do a |
||
| semgrep_container = \ | ||
| docker run \ | ||
| --rm \ | ||
| -v "$(PWD)":/src:ro \ | ||
| -w /src \ | ||
| $(semgrep_image) \ | ||
| semgrep | ||
|
|
||
| # List of all rules in our project | ||
| configs = \ | ||
| --config=./yaml/ \ | ||
| --config=./typescript/ | ||
|
|
||
| all: validate test checks | ||
|
|
||
| # Check rules are valid | ||
| validate: | ||
| $(semgrep_container) \ | ||
| --validate \ | ||
| $(configs) | ||
|
|
||
| # Run test files | ||
| test: | ||
| $(semgrep_container) \ | ||
| --test \ | ||
| ./ | ||
|
|
||
| # Run official recommendation checks | ||
| checks: | ||
| $(semgrep_container) \ | ||
| --config=r/yaml.semgrep \ | ||
| --severity=ERROR \ | ||
| ./ | ||
Uh oh!
There was an error while loading. Please reload this page.