Repository navigation
fix(security): validate report/heatmap basenames under output_dir - #98
Merged
Merged
Conversation
…ts() - Strict Relatorio_Auditoria_*.xlsx / heatmap_*.png under output_dir only - Regenerate report/heatmap when stored path is unsafe or missing - Test: reject non-standard report basename inside output_dir Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Replace Path(stored_path).name with _validated_output_basename() using os.path.basename(os.fspath) and regex before out_dir/filename.resolve(). Addresses py/path-injection on refs/pull/98/merge. Made-with: Cursor
… tests/docs - _resolved_existing_file_under_out_dir: os.path.join/normpath/realpath + prefix check - Heatmap flow via _heatmap_png_path_under_out_dir and _safe_report_path_for_heatmap - Extend test_report_path_safety; document in TESTING; rule/skill for path safety Made-with: Cursor
… heatmap bytes response
- _real_file_under_out_dir_str: normpath(join)+startswith(base_path)+isfile (doc-aligned)
- Base dir from _report_output_dir_resolved(engine) only, not report_path.parent
- GET /heatmap and /heatmap/{id}: _heatmap_png_response + open(safe_path) avoids FileResponse path sink
- Tests + rule/skill updates
Made-with: Cursor
FabioLeitao
added a commit
that referenced
this pull request
Mar 20, 2026
* chore(deps): bump certifi floor and refresh lock + requirements Batch security hygiene for Dependabot alignment (PEM bundle / advisory churn). Made-with: Cursor * docs(plans): track A1 deps PR #101 in MAINTENANCE_FRONT_OF_WORK - S4 table + progress: link #101, status in progress - Footer: #98-#100 on main Made-with: Cursor
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.
Summary
Security (API): Harden
GET /reportand heatmap download paths:Relatorio_Auditoria_*.xlsxandheatmap_*.pngbasename patterns (_REPORT_FILENAME_PATTERN,_HEATMAP_FILENAME_PATTERN)._safe_report_output_path/_safe_heatmap_output_pathresolve only under configuredreport.output_dir; no trusting arbitrary paths thenPath().exists()on attacker-controlled strings beyond basename validation.not_a_report.xlsxeven when underoutput_dir.Note: Old branch
pr/api-report-path-hardeningwas far behindmain; this work is cherry-picked commitb415c79onto currentmain, with test merge resolution.Chore: Ruff format
tests/test_scripts.py(pre-commit).Tests
.\scripts\check-all.ps1