Skip to content

Restrict API reports to the configured output root - #13

Merged
dev-belly merged 1 commit into
mainfrom
codex/report-path-scope-20261012
Oct 12, 2026
Merged

dev-belly merged 1 commit into
mainfrom
codex/report-path-scope-20261012

Conversation

@dev-belly

Copy link
Copy Markdown
Owner

GET /reports/{name}?directory=... previously treated the caller-selected directory as its allowed root, so a readable HTML file anywhere on the server could be returned. Select the report root at server startup with TRADEFORGE_REPORT_ROOT (default artifacts/reports), and allow requests to choose only relative subdirectories within it.

Reject absolute and parent paths, Windows drive/UNC/stream syntax, filename path components, and resolved symlink escapes. Generated HTML reports remain available through the default endpoint and valid subdirectories; the guide documents the new directory semantics.

Validation:

  • Windows Python 3.12: API and HTML report tests: 48 passed, 2 skipped. The two real symlink cases require Windows symlink privileges unavailable to this user; the tests run without that skip on Linux CI.
  • Ruff lint/format, API mypy, architecture checks and whitespace checks pass.
  • The same readable HTML file outside the configured root returns 200 before the change and 400 after it.
  • A subprocess test starts the API with a custom server-owned root and serves a generated report through the default route.

@dev-belly
dev-belly merged commit 0d9fba9 into main Oct 12, 2026
6 checks passed
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