gwc-pybundle 1.4.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of gwc-pybundle might be problematic. Click here for more details.

Files changed (55) hide show
  1. gwc_pybundle-1.4.5.dist-info/METADATA +876 -0
  2. gwc_pybundle-1.4.5.dist-info/RECORD +55 -0
  3. gwc_pybundle-1.4.5.dist-info/WHEEL +5 -0
  4. gwc_pybundle-1.4.5.dist-info/entry_points.txt +2 -0
  5. gwc_pybundle-1.4.5.dist-info/licenses/LICENSE.md +25 -0
  6. gwc_pybundle-1.4.5.dist-info/top_level.txt +1 -0
  7. pybundle/__init__.py +0 -0
  8. pybundle/__main__.py +4 -0
  9. pybundle/cli.py +365 -0
  10. pybundle/context.py +362 -0
  11. pybundle/doctor.py +148 -0
  12. pybundle/filters.py +178 -0
  13. pybundle/manifest.py +77 -0
  14. pybundle/packaging.py +45 -0
  15. pybundle/policy.py +132 -0
  16. pybundle/profiles.py +340 -0
  17. pybundle/roadmap_model.py +42 -0
  18. pybundle/roadmap_scan.py +295 -0
  19. pybundle/root_detect.py +14 -0
  20. pybundle/runner.py +163 -0
  21. pybundle/steps/__init__.py +26 -0
  22. pybundle/steps/bandit.py +72 -0
  23. pybundle/steps/base.py +20 -0
  24. pybundle/steps/compileall.py +76 -0
  25. pybundle/steps/context_expand.py +272 -0
  26. pybundle/steps/copy_pack.py +293 -0
  27. pybundle/steps/coverage.py +101 -0
  28. pybundle/steps/cprofile_step.py +155 -0
  29. pybundle/steps/dependency_sizes.py +120 -0
  30. pybundle/steps/duplication.py +94 -0
  31. pybundle/steps/error_refs.py +204 -0
  32. pybundle/steps/handoff_md.py +167 -0
  33. pybundle/steps/import_time.py +165 -0
  34. pybundle/steps/interrogate.py +84 -0
  35. pybundle/steps/license_scan.py +96 -0
  36. pybundle/steps/line_profiler.py +108 -0
  37. pybundle/steps/memory_profile.py +173 -0
  38. pybundle/steps/mutation_testing.py +136 -0
  39. pybundle/steps/mypy.py +60 -0
  40. pybundle/steps/pip_audit.py +45 -0
  41. pybundle/steps/pipdeptree.py +61 -0
  42. pybundle/steps/pylance.py +562 -0
  43. pybundle/steps/pytest.py +66 -0
  44. pybundle/steps/radon.py +121 -0
  45. pybundle/steps/repro_md.py +161 -0
  46. pybundle/steps/rg_scans.py +78 -0
  47. pybundle/steps/roadmap.py +153 -0
  48. pybundle/steps/ruff.py +111 -0
  49. pybundle/steps/shell.py +74 -0
  50. pybundle/steps/slow_tests.py +170 -0
  51. pybundle/steps/test_flakiness.py +172 -0
  52. pybundle/steps/tree.py +116 -0
  53. pybundle/steps/unused_deps.py +112 -0
  54. pybundle/steps/vulture.py +83 -0
  55. pybundle/tools.py +63 -0
pybundle/tools.py ADDED
@@ -0,0 +1,63 @@
1
+ from __future__ import annotations
2
+
3
+ import shutil
4
+ import os
5
+
6
+
7
+ def get_trusted_path_prefixes() -> list[str]:
8
+ """Return list of trusted directory prefixes for tool validation.
9
+
10
+ These are common system directories where legitimate tools are installed.
11
+ Can be extended via environment variable PYBUNDLE_TRUSTED_PATHS (colon-separated).
12
+ """
13
+ default_prefixes = [
14
+ "/usr/bin/",
15
+ "/usr/local/bin/",
16
+ "/bin/",
17
+ "/opt/homebrew/bin/", # macOS Homebrew (Apple Silicon)
18
+ "/opt/homebrew/opt/", # Homebrew linked tools
19
+ "/home/linuxbrew/.linuxbrew/bin/", # Linux Homebrew
20
+ "/snap/bin/", # Ubuntu snaps
21
+ "/usr/sbin/",
22
+ "/sbin/",
23
+ ]
24
+
25
+ # Allow user-specified trusted paths via environment
26
+ extra_paths = os.environ.get("PYBUNDLE_TRUSTED_PATHS", "")
27
+ if extra_paths:
28
+ default_prefixes.extend(p.strip() for p in extra_paths.split(":") if p.strip())
29
+
30
+ return default_prefixes
31
+
32
+
33
+ def is_path_trusted(tool_path: str | None) -> bool:
34
+ """Check if a tool path is in a trusted directory."""
35
+ if not tool_path:
36
+ return False
37
+
38
+ # Virtual environment paths are implicitly trusted
39
+ # (they're part of the project context)
40
+ if ".venv" in tool_path or "venv" in tool_path or ".pybundle-venv" in tool_path:
41
+ return True
42
+
43
+ trusted_prefixes = get_trusted_path_prefixes()
44
+ return any(tool_path.startswith(prefix) for prefix in trusted_prefixes)
45
+
46
+
47
+ def which(cmd: str, strict: bool = False) -> str | None:
48
+ """Resolve tool path with optional strict mode validation.
49
+
50
+ Args:
51
+ cmd: Command name to resolve
52
+ strict: If True, only return paths in trusted directories
53
+
54
+ Returns:
55
+ Full path to command, or None if not found (or not trusted in strict mode)
56
+ """
57
+ path = shutil.which(cmd)
58
+
59
+ if strict and path:
60
+ if not is_path_trusted(path):
61
+ return None
62
+
63
+ return path