Repository navigation
Harden (1): Validate seed file paths when creating a repository - #1157
Conversation
Repository create writes the seed files carried in a create request by joining each file's path onto the new repository. Run every seed path through util::fs::validate_and_normalize_path before the first write, the validation the workspace file routes already apply, so each file lands inside the new repository. It refuses absolute paths, parent-directory components, .oxen components, and empty paths, and validates every entry before writing any, so a refused path fails the create with nothing written. Placing the check in set_up_new_repo confines every caller of repositories::create. ENG-2429
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Validate seed paths before setup crates/liboxen/src/repositories.rs |
set_up_new_repo validates and normalizes seed paths before setup. Tests check that absolute and parent-traversal paths are rejected without creating a repository or outside canary, and that creation can be retried with the same name and UUID. |
Propagate seed path errors crates/oxen-server/src/controllers/repositories.rs |
create_repo_response returns PathOutsideWorkingTree and EmptyPath errors directly. A controller test checks that an outside seed path returns 400 and leaves the name unclaimed. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Possibly related PRs
- Oxen-AI/Oxen#1096: Both changes validate user-supplied file paths before repository content is written or staged.
- Oxen-AI/Oxen#1121: Both changes validate repository paths before filesystem changes.
Merge Risk: 
Minimal · up to 44e46
-
The change safely rejects invalid seed paths and reports them as client errors, with no unresolved merge-blocking risk identified.
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title names the main change: seed file paths are now validated when a repository is created. It matches the raw summary and the description, which both describe validation in set_up_new_repo and the create path. It is specific and does not use vague terms.
Full details: Description check
-
Explanation
The description states that every seed path goes through util::fs::validate_and_normalize_path before the first write. It lists the rejected cases (absolute paths, parent-directory components, .oxen components, empty paths) and says validation runs before any write. This matches the changeset, which is in repositories.rs and the server controller.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Usage-based review receipt
- Mode: Continue automatically
- Reviewed files: 2
- Charged: $0.50
- View usage details
Note
This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.
Repository create answered a seed file path outside the repository with a 500, since the create handler's own error mapping turned every error it did not list into a server error. Send these refusals through the server's shared mapping, which answers 400.
Repository create writes the seed files carried in a create request by joining each file's path onto the new repository. Run every seed path through util::fs::validate_and_normalize_path before the first write, the validation the workspace file routes already apply, so each file lands inside the new repository. It refuses absolute paths, parent-directory components, .oxen components, and empty paths, and validates every entry before writing any, so a refused path fails the create with nothing written. Placing the check in set_up_new_repo confines every caller of repositories::create.
ENG-2429