Java: Improve saneString and exclude tests in java/concatenated-command-line#10
Closed
kiro-agent[bot] wants to merge 1 commit into
Closed
Java: Improve saneString and exclude tests in java/concatenated-command-line#10kiro-agent[bot] wants to merge 1 commit into
kiro-agent[bot] wants to merge 1 commit into
Conversation
…ated-command-line
Owner
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.
This pull request was created by @kiro-agent on behalf of @mrigankpawagi 👻
Comment with /kiro fix to address specific feedback or /kiro all to address everything.
Learn about Kiro Web
Summary
This PR improves the
java/concatenated-command-linequery by expanding thesaneStringpredicate to recognize more safe value patterns and by excluding test files.Problem
The existing
saneStringpredicate inExecUnescaped.qlwas extremely restrictive — it only recognizedStringLiteral,NullLiteral, and variables assigned only sane values. This caused many false positives where command lines were built with:.toString()representationsstatic finalfields with known valuesAdditionally, many alerts were in test files where command concatenation is used for test setup.
Changes
Expanded
saneStringpredicateAdded recognition of:
IntegerLiteral,LongLiteral,FloatingPointLiteral,DoubleLiteralPrimitiveTypeorBoxedType(when converted to string via concatenation, these produce numeric/boolean text only)EnumConstantaccessesCompileTimeConstantExpr(coversstatic finalfields and other compile-time constants)Test file exclusion
Added
not isInTestFile(argument.getFile())using the existingisInTestFilepredicate fromModelExclusions.Why this is correct
int,long,float,double,Integer,Long, etc. when converted to strings via concatenation produce only digits, decimal points, minus signs, and 'E' for scientific notation — none of which are shell metacharacters.toString()returns the enum name (e.g.,"RUNNING") which is programmer-defined and cannot contain shell metacharacters.Example false positives eliminated