From 584ba8b149c9d866801ca1970e6cc44a4cf69764 Mon Sep 17 00:00:00 2001 From: rarebuffalo Date: Mon, 15 Jun 2026 01:02:00 +0530 Subject: [PATCH] add home and root directory safety check to prevent accidental scans --- cli/securelens/cli.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cli/securelens/cli.py b/cli/securelens/cli.py index d608848..5161a6e 100644 --- a/cli/securelens/cli.py +++ b/cli/securelens/cli.py @@ -172,6 +172,20 @@ async def _scan_async(path, model, output, max_files, ci, fail_on, no_ai, sync): root = Path(path).resolve() + # Safety check: prevent scanning home/root directories by mistake + if root == Path.home() or root == Path("/"): + if not ci: + if not Confirm.ask( + f"\n[bold yellow]⚠ Warning: You are attempting to scan your home or root directory ({root}).[/bold yellow]\n" + " This may contain system caches, virtual environments, and massive system files.\n" + " Do you want to continue?" + ): + console.print("[dim]Scan cancelled.[/dim]\n") + sys.exit(0) + else: + console.print(f"[bold red]✗ Error: Cannot scan home/root directory ({root}) in CI mode.[/bold red]\n") + sys.exit(1) + if not ci: print_banner() print_scan_header(str(root), cfg.default_model)