Skip to content

fix: harden rewrite and file handling edge cases#6

Merged
OneNoted merged 6 commits intomainfrom
fix-rewrite-file-handling
Mar 24, 2026
Merged

fix: harden rewrite and file handling edge cases#6
OneNoted merged 6 commits intomainfrom
fix-rewrite-file-handling

Conversation

@OneNoted
Copy link
Copy Markdown
Owner

@OneNoted OneNoted commented Mar 24, 2026

Summary

  • guard WAV header length calculations and simplify rewrite mode config normalization
  • preserve structured literal fallback behavior for possessives and contractions by tightening trailing-boundary handling and restoring contraction meta-wrapper support
  • allow reading symlinked regular files while keeping safe writes protected against symlink clobbering, with regression coverage

Testing

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test
  • cargo test structured_text -- --nocapture
  • cargo test build_rewrite_plan -- --nocapture
  • cargo test safe_fs -- --nocapture
  • cargo test runtime_diagnostics -- --nocapture
  • cargo check --no-default-features
  • cargo check --no-default-features --features osd
  • cargo check --no-default-features --features local-rewrite
  • cargo check --no-default-features --features cuda
  • cargo check --no-default-features --features cuda,local-rewrite
  • cargo package --locked
  • cargo install --path . --features cuda --force

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f595f4367b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eae422ff38

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 616b40779d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


fn ensure_existing_regular_file(path: &Path, operation: &str) -> io::Result<()> {
let metadata = fs::symlink_metadata(path)?;
let metadata = fs::metadata(path)?;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject symlinks when validating readable files

Switching this check to fs::metadata makes safe_fs::read_to_string follow symlinks, so symlink paths now pass the regular-file guard. I checked src/session/persistence.rs, and session_file_path() falls back to /tmp/whispers/session.json when XDG_RUNTIME_DIR is unset; a precreated symlink there can redirect reads to attacker-chosen regular files, causing session-load DoS or parsing attacker-controlled JSON that was previously blocked by symlink rejection. Keeping symlink-safe read validation (symlink_metadata and nofollow semantics) avoids this /tmp symlink attack surface.

Useful? React with 👍 / 👎.

@OneNoted OneNoted merged commit d776845 into main Mar 24, 2026
2 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