📦 deps(thirdparty): update snapshots
This commit is contained in:
@@ -27,6 +27,19 @@ import time
|
||||
from datetime import datetime, timezone
|
||||
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)
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -397,31 +410,30 @@ def _phase1_surface_mapping(target: Path, verbose: bool = False) -> dict:
|
||||
|
||||
_config_extensions = {".json", ".yaml", ".yml", ".toml", ".ini", ".cfg", ".conf", ".env"}
|
||||
|
||||
for root, dirs, filenames in os.walk(target):
|
||||
dirs[:] = [d for d in dirs if d not in SKIP_DIRECTORIES]
|
||||
for fpath in safe_user_path(target).rglob("*"):
|
||||
if not fpath.is_file() or any(part in SKIP_DIRECTORIES for part in fpath.parts):
|
||||
continue
|
||||
fname = fpath.name
|
||||
total_files += 1
|
||||
suffix = fpath.suffix.lower()
|
||||
|
||||
for fname in filenames:
|
||||
total_files += 1
|
||||
fpath = Path(root) / fname
|
||||
suffix = fpath.suffix.lower()
|
||||
# Categorize by extension
|
||||
ext_key = suffix if suffix else "(no extension)"
|
||||
files_by_type[ext_key] = files_by_type.get(ext_key, 0) + 1
|
||||
|
||||
# Categorize by extension
|
||||
ext_key = suffix if suffix else "(no extension)"
|
||||
files_by_type[ext_key] = files_by_type.get(ext_key, 0) + 1
|
||||
# Detect entry points
|
||||
for pat in _entry_point_patterns:
|
||||
if pat.search(fname) or pat.search(str(fpath)):
|
||||
entry_points.append(str(fpath))
|
||||
break
|
||||
|
||||
# Detect entry points
|
||||
for pat in _entry_point_patterns:
|
||||
if pat.search(fname) or pat.search(str(fpath)):
|
||||
entry_points.append(str(fpath))
|
||||
break
|
||||
# Detect dependency files
|
||||
if fname.lower() in _dep_file_names:
|
||||
dependency_files.append(str(fpath))
|
||||
|
||||
# Detect dependency files
|
||||
if fname.lower() in _dep_file_names:
|
||||
dependency_files.append(str(fpath))
|
||||
|
||||
# Detect config files
|
||||
if suffix in _config_extensions or fname.lower().startswith(".env"):
|
||||
config_files.append(str(fpath))
|
||||
# Detect config files
|
||||
if suffix in _config_extensions or fname.lower().startswith(".env"):
|
||||
config_files.append(str(fpath))
|
||||
|
||||
# Sort by count descending
|
||||
sorted_types = sorted(files_by_type.items(), key=lambda x: x[1], reverse=True)
|
||||
@@ -1053,7 +1065,7 @@ def run_audit(
|
||||
|
||||
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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Import from the 007 config hub (parent directory)
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -850,27 +863,26 @@ def discover_dependency_files(target: Path) -> list[Path]:
|
||||
"""
|
||||
found: list[Path] = []
|
||||
|
||||
for root, dirs, filenames in os.walk(target):
|
||||
dirs[:] = [d for d in dirs if d not in config.SKIP_DIRECTORIES]
|
||||
for fpath in safe_user_path(target).rglob("*"):
|
||||
if not fpath.is_file() or any(part in config.SKIP_DIRECTORIES for part in fpath.parts):
|
||||
continue
|
||||
fname = fpath.name
|
||||
fname_lower = fname.lower()
|
||||
|
||||
for fname in filenames:
|
||||
fpath = Path(root) / fname
|
||||
fname_lower = fname.lower()
|
||||
# Exact name matches
|
||||
if fname in ALL_DEP_FILES:
|
||||
found.append(fpath)
|
||||
continue
|
||||
|
||||
# Exact name matches
|
||||
if fname in ALL_DEP_FILES:
|
||||
found.append(fpath)
|
||||
continue
|
||||
# requirements*.txt variants
|
||||
if _REQUIREMENTS_RE.match(fname):
|
||||
found.append(fpath)
|
||||
continue
|
||||
|
||||
# requirements*.txt variants
|
||||
if _REQUIREMENTS_RE.match(fname):
|
||||
found.append(fpath)
|
||||
continue
|
||||
|
||||
# Docker files (prefix match)
|
||||
if any(fname_lower.startswith(prefix.lower()) for prefix in DOCKER_PREFIXES):
|
||||
found.append(fpath)
|
||||
continue
|
||||
# Docker files (prefix match)
|
||||
if any(fname_lower.startswith(prefix.lower()) for prefix in DOCKER_PREFIXES):
|
||||
found.append(fpath)
|
||||
continue
|
||||
|
||||
return found
|
||||
|
||||
@@ -1158,7 +1170,7 @@ def run_scan(
|
||||
|
||||
config.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)
|
||||
|
||||
@@ -20,6 +20,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
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Import from the 007 config hub (parent directory)
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -546,19 +559,16 @@ def collect_files(target: Path) -> list[Path]:
|
||||
files: list[Path] = []
|
||||
max_files = config.LIMITS["max_files_per_scan"]
|
||||
|
||||
for root, dirs, filenames in os.walk(target):
|
||||
dirs[:] = [d for d in dirs if d not in config.SKIP_DIRECTORIES]
|
||||
|
||||
for fname in filenames:
|
||||
if len(files) >= max_files:
|
||||
logger.warning(
|
||||
"Reached max_files_per_scan limit (%d). Stopping.", max_files
|
||||
)
|
||||
return files
|
||||
|
||||
fpath = Path(root) / fname
|
||||
if _should_scan_file(fpath):
|
||||
files.append(fpath)
|
||||
for fpath in safe_user_path(target).rglob("*"):
|
||||
if not fpath.is_file() or any(part in config.SKIP_DIRECTORIES for part in fpath.parts):
|
||||
continue
|
||||
if len(files) >= max_files:
|
||||
logger.warning(
|
||||
"Reached max_files_per_scan limit (%d). Stopping.", max_files
|
||||
)
|
||||
return files
|
||||
if _should_scan_file(fpath):
|
||||
files.append(fpath)
|
||||
|
||||
return files
|
||||
|
||||
@@ -961,7 +971,7 @@ def run_scan(
|
||||
|
||||
config.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)
|
||||
|
||||
@@ -20,6 +20,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
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Import from the 007 config hub (parent directory)
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -375,19 +388,16 @@ def collect_files(target: Path) -> list[Path]:
|
||||
files: list[Path] = []
|
||||
max_files = config.LIMITS["max_files_per_scan"]
|
||||
|
||||
for root, dirs, filenames in os.walk(target):
|
||||
dirs[:] = [d for d in dirs if d not in config.SKIP_DIRECTORIES]
|
||||
|
||||
for fname in filenames:
|
||||
if len(files) >= max_files:
|
||||
logger.warning(
|
||||
"Reached max_files_per_scan limit (%d). Stopping.", max_files
|
||||
)
|
||||
return files
|
||||
|
||||
fpath = Path(root) / fname
|
||||
if _should_scan_file(fpath):
|
||||
files.append(fpath)
|
||||
for fpath in safe_user_path(target).rglob("*"):
|
||||
if not fpath.is_file() or any(part in config.SKIP_DIRECTORIES for part in fpath.parts):
|
||||
continue
|
||||
if len(files) >= max_files:
|
||||
logger.warning(
|
||||
"Reached max_files_per_scan limit (%d). Stopping.", max_files
|
||||
)
|
||||
return files
|
||||
if _should_scan_file(fpath):
|
||||
files.append(fpath)
|
||||
|
||||
return files
|
||||
|
||||
@@ -869,7 +879,7 @@ def run_scan(
|
||||
|
||||
config.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)
|
||||
|
||||
@@ -24,6 +24,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)
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -141,18 +154,17 @@ def _collect_source_files(target: Path) -> list[Path]:
|
||||
files: list[Path] = []
|
||||
max_files = LIMITS["max_files_per_scan"]
|
||||
|
||||
for root, dirs, filenames in os.walk(target):
|
||||
dirs[:] = [d for d in dirs if d not in SKIP_DIRECTORIES]
|
||||
for fname in filenames:
|
||||
if len(files) >= max_files:
|
||||
return files
|
||||
fpath = Path(root) / fname
|
||||
suffix = fpath.suffix.lower()
|
||||
name = fpath.name.lower()
|
||||
for ext in SCANNABLE_EXTENSIONS:
|
||||
if name.endswith(ext) or suffix == ext:
|
||||
files.append(fpath)
|
||||
break
|
||||
for fpath in safe_user_path(target).rglob("*"):
|
||||
if not fpath.is_file() or any(part in SKIP_DIRECTORIES for part in fpath.parts):
|
||||
continue
|
||||
if len(files) >= max_files:
|
||||
return files
|
||||
suffix = fpath.suffix.lower()
|
||||
name = fpath.name.lower()
|
||||
for ext in SCANNABLE_EXTENSIONS:
|
||||
if name.endswith(ext) or suffix == ext:
|
||||
files.append(fpath)
|
||||
break
|
||||
|
||||
return files
|
||||
|
||||
@@ -529,7 +541,7 @@ def run_score(
|
||||
|
||||
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