Conversation
Runs the Opengrep (Semgrep-syntax) rules in rules/ against the repo. On pull requests only findings introduced since the merge base are reported. Findings become annotations and only ERROR rules fail the check. Optional: enable with enableChecks custom-rules. Includes a first rule for LaunchDarkly client construction aborting on init errors (Typeform/autonomous-coding-workflows#86).
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOJIRA-1
Adds an optional custom-rules check that runs our own code rules with Opengrep, the open-source fork of Semgrep. Rules live in rules/ in this repo, so new rules reach every repo with the next v1 release. Opengrep covers Go, TypeScript/JavaScript, Bash, Dockerfile, YAML/JSON and Terraform, and its taint mode lets rules check how a value is used, not only the shape of the code.
How it works: scripts/custom-rules/run.sh downloads a pinned, checksum-verified Opengrep binary (x86 or aarch64) and scans the repo. On pull requests it only reports findings introduced since the merge base. Findings show as annotations, and only rules with severity ERROR fail the check. Repos opt in with enableChecks: 'custom-rules'. It also runs on draft PRs.
First rule: launchdarkly-init-error-aborts flags Go code that aborts on any error from LaunchDarkly's MakeClient/MakeCustomClient instead of only on a nil client (the fix from Typeform/autonomous-coding-workflows#86). It starts as a warning.
Also: rule tests in CI (run.sh test), a .semgrepignore so this repo's own scan skips the rule test files, and a Custom rules section in the README.
Tested: the rule flags exactly the call sites found in the campaign (user-service, workspace-service, webhooks-api, typekit-kit, brownie, forms-api) and none on the two fixed PR branches. A PR touching a file with existing violations reports nothing; a PR adding one fails when the rule is an ERROR. yarn run all passes. In this repo's CI, the check ran on ubuntu-latest (x86); the aarch64 path hasn't run on our Graviton runners yet.