Repository navigation
SONARJAVA-6383 Fix FP on S2077 when using conditional operators or integer constants - #6406
Luqmansonar wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks @asya-vorobeva, this replaces #6388 and is rebased on master after #6379 merged. I checked #6379 for code to reuse. It only adds private methods that count '?' placeholders, so there is no shared helper to extract. The ternary logic differs: you take the max of the branches, S2077 flags the query if either branch is dynamic. The primitive check is one line (isPrimitive || isPrimitiveWrapper), and char is handled differently: you allow for '?', S2077 keeps its existing behavior. A shared helper would need flags for these differences, so I kept the code local. |
|
Code Review ✅ Approved🟡 Medium risk · Adjusting SQL injection analysis to treat primitive values and constant ternary branches as safe could suppress findings if these cases are misclassified. Fixes two S2077 false positives in the Java analyzer: constant ternary expressions and primitive operands are no longer flagged. No issues found. Verification Rules 2/2 met Repos 5 inspectedFunctional validation No results Rules 2 passed 1 not applicable
Broader impact Repos 5 inspectedCross-repo 5 repositories inspected 0 open impacts
Auto-approval Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |




Fixes two false positives from SONARJAVA-6383: constant ternaries and primitive operands. Not addressed: s + "" (needs symbolic execution). Replaces #6388, rebased on master after #6379.