Repository navigation
fix(core): bound CSV preview before wide-row padding - #1927
Merged
Merged
Conversation
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
phernandez
changed the base branch from
codex/security-markdown-token-work
to
main
October 28, 2026 22:23
phernandez
added a commit
that referenced
this pull request
Oct 28, 2026
) ## Why Legacy upload normalizes literal POSIX backslashes into separators without validating the resulting destination. A real temporary filename `safe\..\..\other-project\leak.md` became `safe/../../other-project/leak.md`; the HTTP client dispatched its PUT to `/webdav/other-project/leak.md`. Fixes #1905. ## What Changed Validate every destination using the shared portable relative-path contract before sizing, dry-run reporting, or any authenticated request. Reject the batch when a destination carries traversal, a drive, or an absolute root. ## Implementation Details Reject literal backslash filenames instead of remapping them to another remote key. Convert native directory separators with Path.as_posix(), then use the shared portable path-value validator with filename-preserving behavior. This preserves distinct edge-space and Unicode filename spellings. Skip archive validation because archives never reach dispatch. Cover both directory discovery and explicitly selected files. Regression tests run real files and a FastAPI HTTP receiver through ASGITransport, without mocking upload behavior. Stacked on #1927; only upload destination validation and its tests are new here. ## Testing - Before the fix: both public upload regressions failed; the directory case reached the wrong project route. - `uv run pytest tests/cli/cloud/test_upload_destination.py tests/cli/cloud/test_upload_symlinks.py tests/cli/cloud/test_upload_path.py tests/cli/test_upload.py -q --no-cov`: 30 passed. - Additional review regression: both ordinary backslash filename cases failed before the fix; 10 focused upload tests pass after it. - Review follow-up: whitespace-only files/components and skipped backslash archives failed before the fix; 56 upload/path tests pass. The shared validator is reused here without trimming names. - Literal-colon follow-up: five real HTTP regressions failed before the fix. 62 upload/path tests, 23 focused colon-policy tests, and 332 combined utility/filter/ZIP/upload/sink tests pass on the updated stack. - `just fast-check`: passed, including repository type checking. - `just doctor`: passed sandboxed write/index/search self-test. ## Risks / Follow-ups A client-side route escape is reproduced, not a hosted authorization bypass: server-side project authorization is still a separate boundary. Single-file and directory uploads reject unsupported literal backslashes. Native upload filenames explicitly allow literal colons, including one-letter prefixes, because these names are discovered relative to the selected tree and URL-encoded. Path-reference callers retain the default Windows-drive restriction. Filename spaces and Unicode spelling are preserved; three added real HTTP regressions failed before the spelling fix. --------- Signed-off-by: phernandez <[email protected]>
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.
Why
A CSV header controls the width used to pad every retained row. The existing output limit is checked only after building the expanded table. A 5 KiB source with 5,000 columns and 200 short rows allocates over 9 MiB before rejection. Fixes #1912.
What Changed
Pass the configured output budget into preview rendering and count the exact projected UTF-8 Markdown size before table padding and rendering. Reuse the existing configured limit and error type.
Implementation Details
The projection includes header/separator widths, padded cells, escaped pipes/backslashes, CRLF flattening, line endings, and the row-count footer. This keeps normal preview output byte-identical while preventing header-driven amplification. Empty-file previews also honor their output budget.
Stacked on #1926; only CSV preview budgeting and its tests are new here.
Testing
uv run pytest tests/document_ingestion/test_csv_preview_budget.py tests/document_ingestion/test_csv_extractor.py -q --no-cov: 24 passed.just fast-check: passed, including repository type checking.just doctor: passed sandboxed write/index/search self-test.Risks / Follow-ups
No new budget value or file-size policy: the existing CsvLimits.max_output_bytes now applies before output construction. The source and field limits continue to bound decoding and parsing.