Repository navigation
feat: add OpenGrep static analysis before review - #9
Merged
Merged
Conversation
kacigaya
changed the base branch from
feat/review-controls-health-digest
to
main
November 3, 2026 09:28
- Scan changed files with OpenGrep in an offline sandbox job with no credentials. Load only the rule dirs for the changed languages plus the generic rules. - Pass results on added lines to the agent as untrusted hints. The agent confirms real issues and drops false positives. - Ignore .semgrepignore files and nosemgrep comments, so a PR cannot hide code. Never store matched code. - Bundle OpenGrep 1.33.1 and opengrep-rules f1d2b56, pinned by SHA-256. Unpack the onefile binary at build time, so scans keep the read-only, noexec sandbox. - Store results and status per review, guarded by the worker lease. Show them in a Static analysis tab. - Add CROCODE_SAST, CROCODE_SAST_TIMEOUT_SECS, CROCODE_SAST_RULES, and the sast repo setting.
kacigaya
force-pushed
the
feat/sast-triage
branch
from
November 3, 2026 09:30
c3ce7f3 to
35cd83e
Compare
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.
Summary
This PR adds OpenGrep static analysis (SAST) to CroCode reviews. The worker scans the changed files before the agent runs. The agent receives the results as hints. It confirms real problems and drops false positives.
This PR is stacked on #8. Merge #8 first. GitHub then retargets this PR to
main.How it works
--network noneand no credentials.A failed or timed-out scan does not fail the review. The agent then reviews without hints. A scan that finishes with errors has status
partial, and the agent still gets its results.Security
.semgrepignorefiles andnosemgrepcomments. I tested this live: without these flags anosemgrepcomment hid the result, and with them the result was found.--, so a file name cannot become a scan option.Image
f1d2b56, pinned by SHA-256. The binary hashes match GitHub's published asset digests./opt/opengrep-cache, so scans keep the read-only root and thenoexectemp directories.License: opengrep-rules uses LGPL-2.1 with the Commons Clause. The clause does not grant the right to sell a product or service whose value derives mainly from the rules.
docker/README.mdexplains the impact and the opt-outs:CROCODE_SAST=off, or another rule set throughCROCODE_SAST_RULES.Configuration
CROCODE_SASTonCROCODE_SAST_TIMEOUT_SECS300CROCODE_SAST_RULES/opt/opengrep-rules.crocode.ymlsasttrueMigration
0005_sast.sqladdsreviews.sast_statusand thesast_resultstable.Validation
cargo fmt --all --check,cargo clippy --all-targets -- -D warningscargo test --all -- --include-ignoredon Postgres 17: 20 core and 69 server tests passed. New tests cover rule selection, argument safety, result parsing and filtering, long matches, report errors, the offline network flag, the prompt section, the repo setting, storage, the lease guard, and the retry reset.web/: lint, typecheck,bun test, build, docs export, and the smoke test, which covers the Static analysis tab and path escaping.runsc, read-only root,--cap-drop=ALL, and no network: the worker's exact scan command found 3 known issues with 0 errors.Known limits
runcand about 90 s withrunsc. Most of the time goes to loading rules. The docs give the opt-outs.CROCODE_SANDBOX=none), the scan cannot be blocked from the network, andopengrepmust be onPATH.