Commit 4e405f3
committed
Break S2083 taint chain in search-result replace
The post-merge SonarCloud run on main kept flagging the write_text()
call in _replace_selected_result (BLOCKER S2083) even though the
previous version resolved the path and checked containment against
project_root — the taint analyzer doesn't treat `parents`-based
containment as sanitization.
Rebuild the target path from the trusted project_root plus a
validated relative component (Path.relative_to raises ValueError when
outside the root), so user-controlled data never flows straight into
write_text(). Same visible behaviour, recognised by Sonar as a safe
construction.1 parent 48ea8b4 commit 4e405f3
1 file changed
Lines changed: 12 additions & 5 deletions
Lines changed: 12 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
485 | 485 | | |
486 | 486 | | |
487 | 487 | | |
488 | | - | |
489 | | - | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
490 | 493 | | |
491 | | - | |
492 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
493 | 501 | | |
494 | 502 | | |
495 | | - | |
496 | 503 | | |
497 | 504 | | |
498 | 505 | | |
| |||
0 commit comments