@westbayberry/dg 1.3.3 → 2.0.1

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.
Files changed (126) hide show
  1. package/LICENSE +1 -201
  2. package/NOTICE +1 -4
  3. package/README.md +293 -0
  4. package/dist/api/analyze.js +210 -0
  5. package/dist/audit/deep.js +180 -0
  6. package/dist/audit/detectors.js +247 -0
  7. package/dist/audit/events.js +41 -0
  8. package/dist/audit/rules.js +426 -0
  9. package/dist/audit-ui/AuditApp.js +39 -0
  10. package/dist/audit-ui/components/AuditHeader.js +24 -0
  11. package/dist/audit-ui/components/AuditResultsView.js +307 -0
  12. package/dist/audit-ui/components/DeepStatusRow.js +11 -0
  13. package/dist/audit-ui/export.js +85 -0
  14. package/dist/audit-ui/format.js +34 -0
  15. package/dist/audit-ui/launch.js +34 -0
  16. package/dist/auth/device-login.js +271 -0
  17. package/dist/auth/env-token.js +6 -0
  18. package/dist/auth/login-app.js +156 -0
  19. package/dist/auth/store.js +147 -0
  20. package/dist/bin/dg.js +71 -0
  21. package/dist/commands/audit.js +362 -0
  22. package/dist/commands/completion.js +116 -0
  23. package/dist/commands/config.js +99 -0
  24. package/dist/commands/doctor.js +39 -0
  25. package/dist/commands/explain.js +100 -0
  26. package/dist/commands/guard-commit.js +158 -0
  27. package/dist/commands/help.js +74 -0
  28. package/dist/commands/licenses.js +435 -0
  29. package/dist/commands/login.js +81 -0
  30. package/dist/commands/logout.js +37 -0
  31. package/dist/commands/router.js +98 -0
  32. package/dist/commands/scan.js +18 -0
  33. package/dist/commands/service.js +475 -0
  34. package/dist/commands/setup.js +302 -0
  35. package/dist/commands/status.js +115 -0
  36. package/dist/commands/suggest.js +35 -0
  37. package/dist/commands/types.js +4 -0
  38. package/dist/commands/unavailable.js +11 -0
  39. package/dist/commands/uninstall.js +111 -0
  40. package/dist/commands/update.js +210 -0
  41. package/dist/commands/verify.js +151 -0
  42. package/dist/commands/version.js +22 -0
  43. package/dist/commands/wrap.js +55 -0
  44. package/dist/config/settings.js +302 -0
  45. package/dist/install-ui/LiveInstall.js +24 -0
  46. package/dist/install-ui/block-render.js +85 -0
  47. package/dist/install-ui/live-install-app.js +48 -0
  48. package/dist/install-ui/prompt.js +24 -0
  49. package/dist/launcher/classify.js +116 -0
  50. package/dist/launcher/env.js +53 -0
  51. package/dist/launcher/live-install.js +50 -0
  52. package/dist/launcher/output-redaction.js +77 -0
  53. package/dist/launcher/preflight-prompt.js +139 -0
  54. package/dist/launcher/resolve-real-binary.js +73 -0
  55. package/dist/launcher/run.js +417 -0
  56. package/dist/policy/evaluate.js +128 -0
  57. package/dist/presentation/mode.js +52 -0
  58. package/dist/presentation/theme.js +29 -0
  59. package/dist/proxy/buffer-budget.js +64 -0
  60. package/dist/proxy/ca.js +126 -0
  61. package/dist/proxy/classify-host.js +26 -0
  62. package/dist/proxy/enforcement.js +102 -0
  63. package/dist/proxy/metadata-map.js +336 -0
  64. package/dist/proxy/server.js +919 -0
  65. package/dist/proxy/upstream-proxy.js +102 -0
  66. package/dist/proxy/worker.js +39 -0
  67. package/dist/publish-set/collect.js +51 -0
  68. package/dist/publish-set/no-exec-shell.js +19 -0
  69. package/dist/publish-set/npm.js +109 -0
  70. package/dist/publish-set/pack.js +36 -0
  71. package/dist/publish-set/pypi.js +59 -0
  72. package/dist/runtime/cli.js +17 -0
  73. package/dist/runtime/first-run.js +60 -0
  74. package/dist/runtime/node-version.js +58 -0
  75. package/dist/runtime/nudges.js +105 -0
  76. package/dist/scan/analyze-worker.js +21 -0
  77. package/dist/scan/collect.js +153 -0
  78. package/dist/scan/command.js +159 -0
  79. package/dist/scan/discovery.js +209 -0
  80. package/dist/scan/render.js +240 -0
  81. package/dist/scan/scanner-report.js +82 -0
  82. package/dist/scan/staged.js +173 -0
  83. package/dist/scan/types.js +1 -0
  84. package/dist/scan-ui/LegacyApp.js +156 -0
  85. package/dist/scan-ui/alt-screen.js +84 -0
  86. package/dist/scan-ui/api-aliases.js +1 -0
  87. package/dist/scan-ui/components/ErrorView.js +23 -0
  88. package/dist/scan-ui/components/InteractiveResultsView.js +1179 -0
  89. package/dist/scan-ui/components/ProgressBar.js +89 -0
  90. package/dist/scan-ui/components/ProjectSelector.js +62 -0
  91. package/dist/scan-ui/components/ScoreHeader.js +20 -0
  92. package/dist/scan-ui/components/SetupBanner.js +13 -0
  93. package/dist/scan-ui/components/Spinner.js +4 -0
  94. package/dist/scan-ui/format-helpers.js +40 -0
  95. package/dist/scan-ui/hooks/useExpandAnimation.js +40 -0
  96. package/dist/scan-ui/hooks/useScan.js +113 -0
  97. package/dist/scan-ui/hooks/useTerminalSize.js +24 -0
  98. package/dist/scan-ui/launch.js +27 -0
  99. package/dist/scan-ui/logo.js +91 -0
  100. package/dist/scan-ui/shims.js +30 -0
  101. package/dist/security/sanitize.js +28 -0
  102. package/dist/service/state.js +837 -0
  103. package/dist/service/trust-store.js +234 -0
  104. package/dist/service/worker.js +88 -0
  105. package/dist/setup/git-hook.js +244 -0
  106. package/dist/setup/optional-support.js +58 -0
  107. package/dist/setup/plan.js +935 -0
  108. package/dist/state/cleanup-registry.js +60 -0
  109. package/dist/state/index.js +5 -0
  110. package/dist/state/locks.js +161 -0
  111. package/dist/state/paths.js +24 -0
  112. package/dist/state/sessions.js +170 -0
  113. package/dist/state/store.js +50 -0
  114. package/dist/telemetry/events.js +40 -0
  115. package/dist/util/git.js +20 -0
  116. package/dist/util/tty-prompt.js +43 -0
  117. package/dist/verify/local.js +400 -0
  118. package/dist/verify/package-check.js +240 -0
  119. package/dist/verify/preflight.js +698 -0
  120. package/dist/verify/render.js +184 -0
  121. package/dist/verify/types.js +1 -0
  122. package/package.json +33 -50
  123. package/dist/index.mjs +0 -54116
  124. package/dist/postinstall.mjs +0 -731
  125. package/dist/python-hook/dg_pip_hook.pth +0 -1
  126. package/dist/python-hook/dg_pip_hook.py +0 -130
@@ -1 +0,0 @@
1
- import dg_pip_hook
@@ -1,130 +0,0 @@
1
- """Dependency Guardian pip-install interceptor.
2
-
3
- Loaded via dg_pip_hook.pth in user site-packages. Patches
4
- pip._internal.commands.install.InstallCommand.run to route through
5
- dg __wrap pip-hook before the real install runs.
6
-
7
- DEFENSIVE CONTRACT (do not violate):
8
- - Must never break Python startup. Any exception is swallowed; the
9
- user's Python interpreter must always come up.
10
- - Must patch only InstallCommand.run; nothing else in pip is touched.
11
- - Must be re-entrant safe via DG_PIP_HOOK_ACTIVE env var.
12
- - Must live ONLY in user-site (never system-site).
13
- - Removed cleanly by `dg uninstall`.
14
- - At .pth-load time pip is NOT yet on sys.path on some systems, so
15
- we register a meta-path finder that patches when pip is first
16
- imported (and also try an immediate patch as a fast path).
17
- """
18
-
19
-
20
- def _build_dg_wrapped_run(orig_run):
21
- def dg_wrapped_run(self, options, args):
22
- import os, sys, subprocess
23
- try:
24
- has_target = bool(args) or bool(getattr(options, "requirements", None))
25
- if not has_target:
26
- return orig_run(self, options, args)
27
- except Exception:
28
- return orig_run(self, options, args)
29
-
30
- if os.environ.get("DG_PIP_HOOK_ACTIVE"):
31
- return orig_run(self, options, args)
32
-
33
- os.environ["DG_PIP_HOOK_ACTIVE"] = "1"
34
- try:
35
- # Resolve the absolute dg-entry rather than a bare "dg" on PATH:
36
- # a PATH entry ahead of the real dg would otherwise intercept every
37
- # hooked install. Fall back to "dg" only if the entry isn't usable.
38
- dg_cmd = "dg"
39
- try:
40
- entry_path = os.path.join(os.path.expanduser("~"), ".dg", "state", "dg-entry")
41
- if sys.platform != "win32" and os.path.isfile(entry_path):
42
- with open(entry_path, "r") as fh:
43
- candidate = fh.read().strip()
44
- if candidate and os.access(candidate, os.X_OK):
45
- dg_cmd = candidate
46
- except Exception:
47
- dg_cmd = "dg"
48
- cmd = [dg_cmd, "__wrap", "pip-hook", "--"] + list(sys.argv[1:])
49
- try:
50
- proc = subprocess.run(cmd)
51
- except FileNotFoundError:
52
- sys.stderr.write("dg: scanner not found; pip install proceeding UNSCANNED.\n")
53
- return orig_run(self, options, args)
54
- if proc.returncode != 0:
55
- return proc.returncode
56
- finally:
57
- os.environ.pop("DG_PIP_HOOK_ACTIVE", None)
58
-
59
- return orig_run(self, options, args)
60
- return dg_wrapped_run
61
-
62
-
63
- def _patch_install_command_module(mod):
64
- try:
65
- if not hasattr(mod, "InstallCommand"):
66
- return
67
- run = mod.InstallCommand.run
68
- if getattr(run, "_dg_wrapped", False):
69
- return
70
- wrapped = _build_dg_wrapped_run(run)
71
- wrapped._dg_wrapped = True
72
- mod.InstallCommand.run = wrapped
73
- except Exception:
74
- pass
75
-
76
-
77
- def _install_hook():
78
- import sys
79
- try:
80
- if "pip._internal.commands.install" in sys.modules:
81
- _patch_install_command_module(sys.modules["pip._internal.commands.install"])
82
- return
83
- except Exception:
84
- pass
85
-
86
- try:
87
- from importlib.machinery import PathFinder
88
- except Exception:
89
- return
90
-
91
- if getattr(PathFinder, "_dg_patched", False):
92
- return
93
-
94
- orig_find_spec = PathFinder.find_spec
95
-
96
- def dg_find_spec(fullname, path=None, target=None):
97
- try:
98
- spec = orig_find_spec(fullname, path, target)
99
- except Exception:
100
- return None
101
- if spec is None:
102
- return spec
103
- if fullname != "pip._internal.commands.install":
104
- return spec
105
- try:
106
- loader = spec.loader
107
- if loader is None:
108
- return spec
109
- orig_exec = loader.exec_module
110
-
111
- def wrapped_exec(module):
112
- orig_exec(module)
113
- _patch_install_command_module(module)
114
-
115
- loader.exec_module = wrapped_exec
116
- except Exception:
117
- pass
118
- return spec
119
-
120
- try:
121
- PathFinder.find_spec = staticmethod(dg_find_spec)
122
- PathFinder._dg_patched = True
123
- except Exception:
124
- pass
125
-
126
-
127
- try:
128
- _install_hook()
129
- except Exception:
130
- pass