📦 deps(thirdparty): update snapshots
This commit is contained in:
@@ -17,6 +17,19 @@ import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def safe_user_path(path_value, base_dir="."):
|
||||
"""Resolve a CLI path under the current workspace."""
|
||||
if base_dir != ".":
|
||||
raise ValueError("Custom base directories are not supported for CLI paths")
|
||||
base_path = Path.cwd().resolve()
|
||||
resolved_path = Path(path_value).expanduser().resolve()
|
||||
try:
|
||||
resolved_path.relative_to(base_path)
|
||||
except ValueError as exc:
|
||||
raise ValueError(f"Path escapes allowed directory: {path_value}") from exc
|
||||
return resolved_path
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Imports from the 007 config hub (same directory)
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -134,20 +147,16 @@ def collect_files(target: Path, logger) -> list[Path]:
|
||||
files: list[Path] = []
|
||||
max_files = LIMITS["max_files_per_scan"]
|
||||
|
||||
for root, dirs, filenames in os.walk(target):
|
||||
# Prune skipped directories in-place so os.walk does not descend
|
||||
dirs[:] = [d for d in dirs if not _should_skip_dir(d)]
|
||||
|
||||
for fname in filenames:
|
||||
if len(files) >= max_files:
|
||||
logger.warning(
|
||||
"Reached max_files_per_scan limit (%d). Stopping collection.", max_files
|
||||
)
|
||||
return files
|
||||
|
||||
fpath = Path(root) / fname
|
||||
if _is_scannable(fpath):
|
||||
files.append(fpath)
|
||||
for fpath in safe_user_path(target).rglob("*"):
|
||||
if not fpath.is_file() or any(_should_skip_dir(part) for part in fpath.parts):
|
||||
continue
|
||||
if len(files) >= max_files:
|
||||
logger.warning(
|
||||
"Reached max_files_per_scan limit (%d). Stopping collection.", max_files
|
||||
)
|
||||
return files
|
||||
if _is_scannable(fpath):
|
||||
files.append(fpath)
|
||||
|
||||
return files
|
||||
|
||||
@@ -368,7 +377,7 @@ def run_scan(target_path: str, output_format: str = "text", verbose: bool = Fals
|
||||
logger = setup_logging("007-quick-scan")
|
||||
ensure_directories()
|
||||
|
||||
target = Path(target_path).resolve()
|
||||
target = safe_user_path(target_path).resolve()
|
||||
if not target.exists():
|
||||
logger.error("Target path does not exist: %s", target)
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user