sonar-cryptography
sonar-cryptography copied to clipboard
fix: add recursion guard to traceSymbol to prevent StackOverflow on mutual assignment cycles
Summary
Fixes #400
Note: depends on #390. Once that merges this PR will show only the 4 files relevant to the recursion guard.
- Adds a
visited: Set<Symbol>overload totraceSymbolin bothPythonDetectionEngineandJavaDetectionEngine - The public overload delegates to the private one with
new HashSet<>(), so all call sites are unchanged - On the first revisit of any symbol the guard returns the current symbol immediately, terminating the cycle
Test plan
- [ ]
Issue400RecursionGuardTest(Python) — verifies a mutual assignment cycle (alg = intermediary; intermediary = alg) completes within 10 s withoutStackOverflowErrorand still detectsAES - [ ]
Issue8IntermediaryVariableTest(Python) — regression: single-hop indirection still resolves correctly - [ ]
Issue8IntermediaryVariableTest(Java) — regression: intermediary variable chain still resolves correctly - [ ]
Issue8MethodReceiverTest(Java) — regression: method-receiver intermediary still resolves correctly