Skip to content

Exclude home subdirs from isRootHomeOrSystemPath - #7

Open
vivienm wants to merge 1 commit into
czottmann:mainfrom
vivienm:main
Open

Exclude home subdirs from isRootHomeOrSystemPath#7
vivienm wants to merge 1 commit into
czottmann:mainfrom
vivienm:main

Conversation

@vivienm

@vivienm vivienm commented Jul 27, 2026

Copy link
Copy Markdown

Hi, I'm trying to use this package on Bluefin (Fedora Silverblue-based, with HOME under /var, e.g. /var/home/jdoe) and I'm hitting an over-broad hard-deny.

When the agent runs a recursive rm on any path under the user's home (e.g. rm -rf /var/home/jdoe/projects/foobar/build), isRootHomeOrSystemPath in extensions/auto-mode/hard-deny.ts returns true and the command is unconditionally denied with "irreversible deletion of home/root/system paths is hard-denied".

function isRootHomeOrSystemPath(path: string): boolean {
const systemRoots = [
"/bin",
"/boot",
"/dev",
"/etc",
"/lib",
"/lib64",
"/private",
"/sbin",
"/sys",
"/usr",
"/var",
];
return (
path === "/" ||
path === HOME ||
systemRoots.some((root) => path === root || path.startsWith(`${root}/`))
);
}

The path === HOME check is correct. The over-match comes from the system-roots branch: /var is in systemRoots, and path.startsWith("/var/") swallows the whole HOME subtree on distros where HOME lives under /var.

The PR implements a minimal fix: exempt HOME's own subtree before checking system roots. This preserves path === HOME (still blocks rm -rf ~), keeps /var/log, /etc, etc. protected, and only stops the rule from swallowing ~/... on /var/home distros.

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