fix(cicd): scope semgrep filesystem-deletion rule to exclude src/hooks/#2143
Open
maxmilian wants to merge 1 commit into
Open
fix(cicd): scope semgrep filesystem-deletion rule to exclude src/hooks/#2143maxmilian wants to merge 1 commit into
maxmilian wants to merge 1 commit into
Conversation
The filesystem-deletion rule matches fs::remove_file/remove_dir_all with no paths scoping, so it flags src/hooks/ — yet its own message states deletion is "Expected in hooks/init cleanup". Since CI runs semgrep with --baseline-commit --error, every new agent-uninstall PR that adds a deletion to src/hooks/init.rs trips a false positive and fails the scan. Add paths.exclude: src/hooks/ so the rule reflects its stated intent — flag deletions in filter modules, not in hooks/init cleanup code. Fixes rtk-ai#1954
Author
|
Ran a fresh-context independent review (skeptical, diff + issue only). Verdict: approve, no blockers. Confirmed:
|
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
filesystem-deletionsemgrep rule has nopaths:scoping, so it flagssrc/hooks/even though its own message says deletion is "Expected in hooks/init cleanup". Fixes semgrep: filesystem-deletion rule lacks paths:exclude for src/hooks/ #1954.Root cause
.semgrep.ymlrulefilesystem-deletionmatchesfs::remove_file(...)/remove_dir_all(...)repo-wide. CI runssemgrep scan --config .semgrep.yml --baseline-commit <base> --error, so any PR adding a new deletion tosrc/hooks/init.rs(e.g. a new agent's uninstall path) produces a fresh finding and fails the scan — a guaranteed false positive for every future agent-uninstall PR (e.g. Pi support #1741). The existing ~10 deletions ininit.rsonly pass because they predate the baseline.Fix
Add
paths.exclude: src/hooks/to the rule, so it flags deletions in filter modules (the surprising case) but not in the hooks/init cleanup code (the expected case).Verification (semgrep before/after)
Ran
semgrep scan --config .semgrep.ymllocally:src/hooks/init.rssrc/hooks/src/core/tee.rs(filter module)The rule still catches deletions outside
src/hooks/, confirming the exclude isn't over-broad.Scope
Config-only, 3 lines. No Rust changes, so no unit test applies — the behavior is verified by the semgrep runs above. Does not touch any other rule.