Repository navigation
fix(core): preserve configured project root during moves - #1930
Conversation
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. |
678b3a2 to
51e7300
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
813e940 to
e9b26b8
Compare
51e7300 to
1f8f180
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
1f8f180 to
b20b121
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
b20b121 to
23333cb
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
23333cb to
dbb46a2
Compare
94745ce to
157a9f2
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
dbb46a2 to
982b178
Compare
157a9f2 to
0ab764e
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
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]>
0ab764e to
145a5ec
Compare
982b178 to
29935e1
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
29935e1 to
f86424e
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Signed-off-by: phernandez <[email protected]>
f86424e to
1ed4f67
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
) ## Why Importer destinations, local accepted-note materialization, and regular-file moves can escape the selected project through traversal, absolute paths, or existing symlink ancestors. Twelve bounded real-filesystem regressions reproduced writes or moves outside the project. A complete directory-call audit reproduced two additional bypasses in Memory JSON and Claude project imports, which now use the guarded importer helper. Fixes #1908 (K34/K41/K42). ## What Changed Add one explicit FileService project-path guard and call it at importer folder/write boundaries, all local materialization storage reads/writes/deletes and cleanup alias checks, and regular-file move source/destination boundaries. Reject before creating directories or changing files. ## Implementation Details Reuse the existing portable relative-path validator and resolved local ancestry check. Absolute spellings remain supported within the chosen local root, including resolved aliases. Object storage validates relative logical keys without consulting the host filesystem. Validate EntityService move paths before existence preflight and rollback probes; remove its redundant mkdir so the guarded storage move owns parent creation. Storage paths permit literal tildes because these boundaries do not expand home markers. Native local POSIX storage also preserves literal-colon names; remote keys retain the portable drive restriction. The shared resolved-root helper also translates resolution failures, including Python 3.12 symlink-loop RuntimeError, into validation errors before storage mapping. General directory creation stays available for choosing arbitrary local project roots. Stacked on #1930; only these destination boundaries and their regressions are new here. ## Testing - Before the fix: all twelve traversal/absolute/symlink regressions failed across the four real sinks. - `uv run pytest tests/importers/test_import_directory_containment.py tests/services/test_destination_containment.py tests/importers/test_importer_base.py tests/services/test_file_service.py tests/cloud/test_note_content_materialization.py -q --no-cov`: 75 passed. - Controls preserve in-root absolute paths and remote logical keys; rejected operations preserve source bytes and create no outside directory. - A real EntityService symlink-move regression reproduced an outside parent directory created before rejection; 25 move/import/sink tests pass after removing the caller mkdir. - Review follow-up: a real outside-existing-destination probe and a literal-tilde file move both failed before correction. `uv run pytest tests/services/test_non_markdown_moves.py tests/services/test_destination_containment.py tests/importers/test_import_directory_containment.py tests/services/test_file_service.py tests/utils/test_validate_project_path.py -q --no-cov`: 74 passed. - Native-colon follow-up: two real local file moves failed before correction; 83 focused storage, move, importer and validation tests pass, including remote-key drive restrictions. - Python 3.12 follow-up: four real symlink-loop move cases failed before the shared resolver correction. The 3.12 destination suite passes 21 tests; 87 focused move/storage/import/validation tests pass on 3.14. - Canonical-file follow-up: nine real materialization/reuse/cleanup/alias/storage-access regressions failed before adding the shared path guard at every adapter access. `uv run pytest tests/services/test_materialization_containment.py tests/services/test_destination_containment.py tests/cloud/test_note_content_materialization.py -q --no-cov`: 59 passed. - `just fast-check`: passed, including repository type checking. - `just doctor`: passed sandboxed write/index/search self-test. ## Risks / Follow-ups This enforces the selected project boundary while preserving arbitrary project-root selection. It does not claim to prevent a concurrent local process swapping symlinks after validation. Symlink regressions skip Windows where privileges may be needed. Hosted adapters overriding these file operations retain their own storage authorization responsibilities. --------- Signed-off-by: phernandez <[email protected]>
Why
Configured project-root containment applies during creation but was bypassed by move_project, which persisted arbitrary replacement paths. Fixes #1896.
What Changed
Require a move destination to resolve strictly beneath the configured root before any config or database mutation. Reject sibling-prefix paths, unrelated paths, the shared root itself, and symlink escapes. Preserve unconstrained local moves.
Implementation Details
Use the same resolved ancestry rule as project creation. Legitimate constrained destinations are stored in resolved form. The existing update_project API caller updates only active status; path moves run through move_project.
Stacked on #1928 (the ignore-rule PR is held separately for a compatibility decision); only move containment and its regression tests are new here.
Testing
uv run pytest tests/services/test_project_move_root.py tests/services/test_project_service.py tests/services/test_project_service_operations.py -q --no-cov: 78 passed, 2 existing skips.just fast-check: passed, including repository type checking.just doctor: passed sandboxed write/index/search self-test.Risks / Follow-ups
This addresses a configured local-root boundary, not a demonstrated hosted tenant escape. Symlink creation tests skip Windows. It does not add protection against a concurrent local process replacing symlinks after validation.