Skip to content

Fix S2083 taint chain in search-result replace#225

Merged
JE-Chen merged 1 commit intomainfrom
dev
Apr 24, 2026
Merged

Fix S2083 taint chain in search-result replace#225
JE-Chen merged 1 commit intomainfrom
dev

Conversation

@JE-Chen
Copy link
Copy Markdown
Member

@JE-Chen JE-Chen commented Apr 24, 2026

Summary

Test plan

  • py -m pytest test/ --ignore=test/qt_ui — 77 passed
  • py -m ruff check je_editor — clean
  • SonarCloud quality gate on main turns green after this merges

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.
@JE-Chen JE-Chen merged commit 6c46854 into main Apr 24, 2026
6 checks passed
@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant