Skip to content

Handle absolute paths#306

Open
someotherself wants to merge 8 commits into
xoriors:mainfrom
someotherself:main
Open

Handle absolute paths#306
someotherself wants to merge 8 commits into
xoriors:mainfrom
someotherself:main

Conversation

@someotherself

Copy link
Copy Markdown
Collaborator

Handle absolute paths

Related to -#210

The function handle_paths was created and added on:
EncryptedFs::create
EncryptedFs::remove_file
EncryptedFs::remove_dir
EncryptedFs::rename

Tests added for each function too.

-> New feature (non-breaking change which adds functionality)

@someotherself someotherself requested a review from radumarias as a code owner July 3, 2025 18:14
@radumarias radumarias requested a review from Copilot July 10, 2025 22:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for nested and absolute path handling across filesystem operations by introducing a handle_path helper and updating tests to cover these scenarios.

  • Introduced handle_path to split and resolve multi-segment paths before core operations.
  • Updated create, remove_file, remove_dir, and rename to use handle_path.
  • Expanded encryptedfs tests to cover nested and absolute path cases; adjusted bench signature and added clippy suppressions.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/test_common.rs Removed unnecessary Sync bound from bench signature
src/encryptedfs/test.rs Added comprehensive nested/absolute path tests for create, remove, rename
src/encryptedfs.rs Implemented handle_path and wired it into core fs methods
src/crypto/write.rs Added #[allow(clippy::manual_is_multiple_of)] to seek impl
src/crypto/read.rs Added #[allow(clippy::manual_is_multiple_of)] to seek impl

Comment thread src/encryptedfs.rs
return Err(FsError::InodeNotFound);
}
if self.exists_by_name(parent, name)? {
let (parent, name) = self.handle_path(parent, name.clone()).await?;

Copilot AI Jul 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After you extract the final name via handle_path, run self.validate_filename(&name)? to enforce filename constraints and catch invalid characters.

Suggested change
let (parent, name) = self.handle_path(parent, name.clone()).await?;
let (parent, name) = self.handle_path(parent, name.clone()).await?;
self.validate_filename(&name)?;

Copilot uses AI. Check for mistakes.
Comment thread src/encryptedfs.rs Outdated
let input = name.expose_secret().to_string();
let path = input.strip_prefix(".").unwrap_or(&input).to_owned();
let mut path_segments = vec![];
for segment in path.split("/") {

Copilot AI Jul 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider explicitly rejecting ".." segments (e.g. return an error) to avoid directory traversal and prevent unintended parent‐dir resolution.

Copilot uses AI. Check for mistakes.
Comment thread src/encryptedfs.rs Outdated
self.data_dir.join(CONTENTS_DIR).join(ino.to_string())
}

// TO-DO-handle-path-maybe

Copilot AI Jul 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This TODO comment appears stale; either implement the missing logic here or remove it to keep the code clean.

Copilot uses AI. Check for mistakes.
@radumarias radumarias linked an issue Jul 10, 2025 that may be closed by this pull request
@radumarias radumarias added this to the mvp milestone Jul 10, 2025
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.

Handle absolute paths

3 participants