Improve sefety and add config file #2

Merged
mdaleo404 merged 3 commits from update_filedust_20251129 into main 2025-11-29 10:52:40 +00:00
2 changed files with 15 additions and 2 deletions
Showing only changes of commit c75a5246e3 - Show all commits

View File

@@ -172,6 +172,19 @@ def main(argv: list[str] | None = None) -> int:
args = parser.parse_args(argv)
root = Path(args.path).expanduser()
home = Path.home().resolve()
root_resolved = root.resolve()
# Ensure root is inside the user's home directory
try:
root_resolved.relative_to(home)
except ValueError:
console.print(
f"[red]Error:[/] Refusing to operate outside the user's home directory.\n"
f"Requested: {root_resolved}\n"
f"Allowed: {home}"
)
return 1
if not root.exists():
console.print(f"[red]Error:[/] Path not found: {root}")

View File

@@ -23,7 +23,6 @@ JUNK_DIR_NAMES = {
".nox",
".tox",
".hypothesis",
".cache",
".gradle",
".parcel-cache",
".turbo",
@@ -31,7 +30,6 @@ JUNK_DIR_NAMES = {
".vite",
".sass-cache",
".sass-cache",
"build",
"dist",
}
@@ -53,6 +51,8 @@ JUNK_FILE_PATTERNS = [
# VCS / system dirs
SKIP_DIR_NAMES = {
".cache",
"build",
".git",
".hg",
".svn",