Skip to content

fix(implode): prevent deletion of protected and unowned directories - #3228

Open
jong-kyung wants to merge 4 commits into
voidzero-dev:mainfrom
jong-kyung:fix/implode-protected-roots
Open

jong-kyung wants to merge 4 commits into
voidzero-dev:mainfrom
jong-kyung:fix/implode-protected-roots

Conversation

@jong-kyung

@jong-kyung jong-kyung commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

vp implode could recursively delete the user home or unrelated directories selected through directory overrides.

Reject the user home, its ancestors, and filesystem roots, including symlink aliases. Require ownership verification for every existing data, cache, config, and state root, including nested roots, before modifying files, shell profiles, or PATH. These checks also apply with --yes.

Setup creates .vp-owned markers only for new or empty roots. Installation into nonempty unmarked roots remains supported, but implode refuses to delete them. This also applies to older installations without ownership markers, which must be inspected and removed manually.

Reject protected deletion targets before modifying shell profiles, PATH,
or managed files, including with --yes. Check canonical paths to catch
symlink aliases and validate all roots before starting split-layout cleanup.

Add regression coverage for protected roots, normal installations,
symlink aliases, and preservation of files when validation fails.
@jong-kyung jong-kyung self-assigned this Oct 25, 2026
@jong-kyung

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-25T08:39:50.784194Z
We couldn’t complete this review. Comment @codex review to try again.
03ddbdf Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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".

@jong-kyung
jong-kyung marked this pull request as ready for review October 25, 2026 03:32
@jong-kyung

Copy link
Copy Markdown
Collaborator Author

@codex review

@jong-kyung
jong-kyung requested a review from fengmk2 October 25, 2026 03:33
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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".

@fengmk2 fengmk2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The home/root protection works in the targeted Linux tests, but I would like us to complete the directory ownership protection in this PR before merging. A mistaken VP_HOME override can still delete unrelated data. Please address the inline comment and add regression coverage for unowned directories.

Comment thread crates/vp_global_cli/src/commands/implode.rs
@jong-kyung
jong-kyung marked this pull request as draft October 25, 2026 05:26
Require ownership markers for every existing data, cache, config, and state root before changing files, shell profiles, or PATH. Validate nested roots independently and collapse them only when building the final recursive deletion targets. Preserve the home and filesystem root safeguards.

Check that new installation roots are empty before recording ownership. Keep nonempty legacy roots unmarked so existing installations remain usable without granting permission to delete unrelated contents.

Cover ownership checks, nested and split roots, fresh setup, and legacy setup with isolated unit tests and CLI snapshots.
@jong-kyung

Copy link
Copy Markdown
Collaborator Author

@codex review

Recognize an existing current entry without following its target, matching
installation directory resolution even when the active binary is missing.
Keep repaired legacy roots unmarked so implode still refuses their removal.

Extend the existing installer CI cases to verify ownership is not claimed
when reusing a legacy root or repairing a dangling junction.
Keep ownership checks focused on recursive removal. Setup may use an
existing nonempty root without marking it as owned, so implode still
refuses to delete it. Remove the unnecessary existing-install distinction.

Verify that setup succeeds without claiming personal files and that
implode preserves those files and shell configuration. Keep preflight
coverage for invalid roots and update the doctor cache-directory snapshot.
@jong-kyung
jong-kyung marked this pull request as ready for review October 25, 2026 08:38
@jong-kyung

Copy link
Copy Markdown
Collaborator Author

I've made some changes to address your feedback, but I'm not sure if this is the right approach. I'd appreciate it if you could take another look 🙇‍♂️

@jong-kyung
jong-kyung requested a review from fengmk2 October 25, 2026 08:39
@jong-kyung jong-kyung changed the title fix(implode): prevent deletion of home and filesystem roots fix(implode): prevent deletion of protected and unowned directories Oct 25, 2026

This branch has not been deployed

No deployments
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.

2 participants