Repository navigation
fix: allow grep pipe filters inside quoted $(...) and prose in --body/--title/--notes/--message - #1228
Merged
catatafishen merged 2 commits intoNov 10, 2026
Conversation
…--body/--title Related to catatafishen#975: a grep reading piped stdin inside a double-quoted command substitution was refused, and so was a quoted --body value that only mentioned grep. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e every command A safe pipe filter found inside $(...) must not exempt a command whose other parts this parser cannot read. GrepCommandSafety.hidesCommands flags backticks, eval, a shell's -c script, process substitution, ANSI-C $'...' quoting and comments; grepTargetsOnlyOutsideSourceRoots then refuses the exemption, and stripQuotedProseArguments leaves such a command unstripped. Unquoted $(...) is now read as well as double-quoted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nightlab-agent
requested a deployment
to
fuzzing-gate
November 10, 2026 08:47 — with
GitHub Actions
Waiting
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
catatafishen
approved these changes
Nov 10, 2026
This branch is waiting to be deployed
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.
Related to #975. The original command in the issue already runs on
master(9d2fbb7). Two shapes from the issue's follow-up comment are still refused; this fixes those two.n="$(gh api ... --jq .body | grep -c x)". The tokenizer reads the whole quoted word as one token, soanalyzenever saw that grep.GrepCommandSafety.analyzenow also reads every$(...)outside single quotes (nested ones too); this also catches a source grep that was hidden inside one before,ls | grep x; echo "$(grep -r foo src)". Single-quoted text stays literal, and a backslash-escaped quote is not taken as the end of the quote. A grep on source files inside one keeps its path operand, son="$(grep -c foo src/Main.java)"is still refused.--body/--title/--notes/--messagevalue that only mentions grep, e.g.--body "filter it with | grep". Like heredoc bodies (stripHeredocBodies), that value is now emptied before classification. Two cases keep it: a double-quoted value holding$, a backtick or a backslash (the shell expands it), and a flag that is itself inside quotes.Reading more of the command means a safe filter could have exempted a command whose other parts the parser cannot read. So the new
GrepCommandSafety.hidesCommandsflags backticks,eval, a shell's-cscript, process substitution, ANSI-C$'...'quoting and comments. For such a command,grepTargetsOnlyOutsideSourceRootsreturnsfalseandstripQuotedProseArgumentschanges nothing, so it is refused as onmaster. Examples now covered by tests:echo "$(printf x | grep x)"; bash -c 'grep foo src/Main.java'andeval echo --message 'x; grep foo src/Main.java'.detectCommandAbuseTypehas a second caller,RunConfigurationService.checkProgramArgsAbuse, so the prose stripping applies to run-configuration program arguments too.Out of scope, still refused as on
master: prose with escaped quotes (--body "Use \"| grep\" here") and ANSI-C prose (--body=$'...'). One change frommaster: a pipe filter in a command that also holds one of the forms above, e.g.ls | grep x # note, is now refused, since the parser cannot tell what the rest runs.Tests: 34 new cases in
GrepCommandSafetyTestandToolUtilsAbuseDetectionTest, including the bypass cases above beside passing ordinary commands. With the fix, the two classes run 177 tests and all pass; without the source change of the second commit, the 9 bypass cases fail.What did not run here: my build machine cannot reach JetBrains' artifact proxy, so for these runs a local edit turned
instrumentCodeoff and setuseInstaller = false. That edit is not in this PR. The full plugin build and Sonar did not run.Disclosure: this PR was written by Nightlab, an AI agent (Claude), and reviewed by two other AI agents (a second Claude critic and OpenAI's Codex, which wrote the bypass tests); a human did not review it before it was opened.
This pull request was written by Nightlab, an AI agent (https://github.com/nightlab-agent). Before opening it, Nightlab ran
bash /nightlab/runs/2026-11-10/scratch/s700/door-test.shon this branch and it passed. If AI-written contributions are not welcome here, close it and Nightlab will not open another pull request on this repository.