depgate 0.6.1__tar.gz

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 (124) hide show
  1. depgate-0.6.1/LICENSE +201 -0
  2. depgate-0.6.1/MANIFEST.in +3 -0
  3. depgate-0.6.1/NOTICE +17 -0
  4. depgate-0.6.1/PKG-INFO +374 -0
  5. depgate-0.6.1/README.md +348 -0
  6. depgate-0.6.1/pyproject.toml +51 -0
  7. depgate-0.6.1/setup.cfg +4 -0
  8. depgate-0.6.1/src/analysis/__init__.py +0 -0
  9. depgate-0.6.1/src/analysis/analysis_runner.py +53 -0
  10. depgate-0.6.1/src/analysis/facts.py +94 -0
  11. depgate-0.6.1/src/analysis/heuristics.py +469 -0
  12. depgate-0.6.1/src/analysis/linked.py +100 -0
  13. depgate-0.6.1/src/analysis/policy.py +142 -0
  14. depgate-0.6.1/src/analysis/policy_comparators.py +152 -0
  15. depgate-0.6.1/src/analysis/policy_rules.py +474 -0
  16. depgate-0.6.1/src/analysis/policy_runner.py +228 -0
  17. depgate-0.6.1/src/args.py +357 -0
  18. depgate-0.6.1/src/cli_build.py +335 -0
  19. depgate-0.6.1/src/cli_classify.py +303 -0
  20. depgate-0.6.1/src/cli_config.py +33 -0
  21. depgate-0.6.1/src/cli_io.py +201 -0
  22. depgate-0.6.1/src/cli_mcp.py +822 -0
  23. depgate-0.6.1/src/cli_registry.py +39 -0
  24. depgate-0.6.1/src/common/__init__.py +1 -0
  25. depgate-0.6.1/src/common/http_client.py +227 -0
  26. depgate-0.6.1/src/common/http_errors.py +80 -0
  27. depgate-0.6.1/src/common/http_metrics.py +93 -0
  28. depgate-0.6.1/src/common/http_policy.py +99 -0
  29. depgate-0.6.1/src/common/http_rate_middleware.py +445 -0
  30. depgate-0.6.1/src/common/logging_utils.py +504 -0
  31. depgate-0.6.1/src/constants.py +495 -0
  32. depgate-0.6.1/src/depgate.egg-info/PKG-INFO +374 -0
  33. depgate-0.6.1/src/depgate.egg-info/SOURCES.txt +122 -0
  34. depgate-0.6.1/src/depgate.egg-info/dependency_links.txt +1 -0
  35. depgate-0.6.1/src/depgate.egg-info/entry_points.txt +2 -0
  36. depgate-0.6.1/src/depgate.egg-info/requires.txt +9 -0
  37. depgate-0.6.1/src/depgate.egg-info/top_level.txt +16 -0
  38. depgate-0.6.1/src/depgate.py +199 -0
  39. depgate-0.6.1/src/depgate_mcp/__init__.py +5 -0
  40. depgate-0.6.1/src/depgate_mcp/schemas.py +111 -0
  41. depgate-0.6.1/src/depgate_mcp/validate.py +50 -0
  42. depgate-0.6.1/src/metapackage.py +700 -0
  43. depgate-0.6.1/src/registry/__init__.py +1 -0
  44. depgate-0.6.1/src/registry/depsdev/client.py +292 -0
  45. depgate-0.6.1/src/registry/depsdev/enrich.py +405 -0
  46. depgate-0.6.1/src/registry/maven/__init__.py +49 -0
  47. depgate-0.6.1/src/registry/maven/client.py +176 -0
  48. depgate-0.6.1/src/registry/maven/discovery.py +344 -0
  49. depgate-0.6.1/src/registry/maven/enrich.py +303 -0
  50. depgate-0.6.1/src/registry/npm/__init__.py +49 -0
  51. depgate-0.6.1/src/registry/npm/client.py +239 -0
  52. depgate-0.6.1/src/registry/npm/discovery.py +176 -0
  53. depgate-0.6.1/src/registry/npm/enrich.py +322 -0
  54. depgate-0.6.1/src/registry/npm/scan.py +67 -0
  55. depgate-0.6.1/src/registry/pypi/__init__.py +44 -0
  56. depgate-0.6.1/src/registry/pypi/client.py +153 -0
  57. depgate-0.6.1/src/registry/pypi/discovery.py +96 -0
  58. depgate-0.6.1/src/registry/pypi/enrich.py +314 -0
  59. depgate-0.6.1/src/registry/pypi/scan.py +124 -0
  60. depgate-0.6.1/src/repository/__init__.py +6 -0
  61. depgate-0.6.1/src/repository/github.py +195 -0
  62. depgate-0.6.1/src/repository/gitlab.py +180 -0
  63. depgate-0.6.1/src/repository/license_discovery.py +155 -0
  64. depgate-0.6.1/src/repository/provider_adapters.py +148 -0
  65. depgate-0.6.1/src/repository/provider_registry.py +63 -0
  66. depgate-0.6.1/src/repository/provider_validation.py +190 -0
  67. depgate-0.6.1/src/repository/providers.py +107 -0
  68. depgate-0.6.1/src/repository/rtd.py +92 -0
  69. depgate-0.6.1/src/repository/url_normalize.py +122 -0
  70. depgate-0.6.1/src/repository/version_match.py +274 -0
  71. depgate-0.6.1/src/versioning/__init__.py +1 -0
  72. depgate-0.6.1/src/versioning/cache.py +43 -0
  73. depgate-0.6.1/src/versioning/errors.py +9 -0
  74. depgate-0.6.1/src/versioning/models.py +147 -0
  75. depgate-0.6.1/src/versioning/parser.py +385 -0
  76. depgate-0.6.1/src/versioning/resolvers/__init__.py +13 -0
  77. depgate-0.6.1/src/versioning/resolvers/base.py +55 -0
  78. depgate-0.6.1/src/versioning/resolvers/maven.py +263 -0
  79. depgate-0.6.1/src/versioning/resolvers/npm.py +214 -0
  80. depgate-0.6.1/src/versioning/resolvers/pypi.py +157 -0
  81. depgate-0.6.1/src/versioning/service.py +84 -0
  82. depgate-0.6.1/tests/test_cli_actions.py +72 -0
  83. depgate-0.6.1/tests/test_client_logging.py +160 -0
  84. depgate-0.6.1/tests/test_depsdev_client_unit.py +102 -0
  85. depgate-0.6.1/tests/test_depsdev_enrich_unit.py +117 -0
  86. depgate-0.6.1/tests/test_depsdev_enrich_unit_maven.py +89 -0
  87. depgate-0.6.1/tests/test_discovery_enrichment_logging.py +286 -0
  88. depgate-0.6.1/tests/test_github_client.py +169 -0
  89. depgate-0.6.1/tests/test_gitlab_client.py +183 -0
  90. depgate-0.6.1/tests/test_heuristics_breakdown_logging.py +43 -0
  91. depgate-0.6.1/tests/test_heuristics_repo_signals.py +180 -0
  92. depgate-0.6.1/tests/test_http_client_wrapped_unit.py +260 -0
  93. depgate-0.6.1/tests/test_http_metrics_unit.py +164 -0
  94. depgate-0.6.1/tests/test_http_policy_unit.py +205 -0
  95. depgate-0.6.1/tests/test_license_discovery.py +110 -0
  96. depgate-0.6.1/tests/test_linked_analysis.py +92 -0
  97. depgate-0.6.1/tests/test_logging_integration_e2e.py +273 -0
  98. depgate-0.6.1/tests/test_logging_utils_formatters.py +405 -0
  99. depgate-0.6.1/tests/test_logging_utils_redaction.py +170 -0
  100. depgate-0.6.1/tests/test_maven_repo_discovery.py +80 -0
  101. depgate-0.6.1/tests/test_mcp_findings_comprehensive.py +450 -0
  102. depgate-0.6.1/tests/test_mcp_scan_project_integration.py +292 -0
  103. depgate-0.6.1/tests/test_mcp_server_basic.py +39 -0
  104. depgate-0.6.1/tests/test_mcp_stdio_integration.py +261 -0
  105. depgate-0.6.1/tests/test_mcp_version_mismatch.py +262 -0
  106. depgate-0.6.1/tests/test_npm_exists_preservation.py +32 -0
  107. depgate-0.6.1/tests/test_npm_repo_discovery.py +626 -0
  108. depgate-0.6.1/tests/test_parse_tokens.py +164 -0
  109. depgate-0.6.1/tests/test_policy_comparators.py +106 -0
  110. depgate-0.6.1/tests/test_policy_engine_integration.py +197 -0
  111. depgate-0.6.1/tests/test_policy_evaluators.py +225 -0
  112. depgate-0.6.1/tests/test_policy_example_yaml.py +129 -0
  113. depgate-0.6.1/tests/test_provider_validation_matching.py +165 -0
  114. depgate-0.6.1/tests/test_pypi_license_enrichment.py +88 -0
  115. depgate-0.6.1/tests/test_pypi_repo_discovery.py +285 -0
  116. depgate-0.6.1/tests/test_repo_url_normalize.py +131 -0
  117. depgate-0.6.1/tests/test_resolver_maven.py +309 -0
  118. depgate-0.6.1/tests/test_resolver_npm.py +272 -0
  119. depgate-0.6.1/tests/test_resolver_pypi.py +233 -0
  120. depgate-0.6.1/tests/test_rtd.py +125 -0
  121. depgate-0.6.1/tests/test_score_normalization.py +122 -0
  122. depgate-0.6.1/tests/test_serialization_exports.py +144 -0
  123. depgate-0.6.1/tests/test_serialization_policy_outputs.py +197 -0
  124. depgate-0.6.1/tests/test_version_match.py +212 -0
depgate-0.6.1/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,3 @@
1
+ include LICENSE
2
+ include NOTICE
3
+ include README.md
depgate-0.6.1/NOTICE ADDED
@@ -0,0 +1,17 @@
1
+ DepGate
2
+ Copyright (c) 2025 cognitivegears
3
+
4
+ This product includes software originally developed by Apiiro and
5
+ contributors as "Dependency Combobulator" (https://github.com/apiiro/combobulator).
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
depgate-0.6.1/PKG-INFO ADDED
@@ -0,0 +1,374 @@
1
+ Metadata-Version: 2.4
2
+ Name: depgate
3
+ Version: 0.6.1
4
+ Summary: DepGate detects and prevents dependency confusion and supply-chain risks. (Hard fork of Apiiro's Dependency Combobulator)
5
+ Author: cognitivegears
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/cognitivegears/depgate
8
+ Project-URL: Bug Tracker, https://github.com/cognitivegears/depgate/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ License-File: NOTICE
16
+ Requires-Dist: requests<2.32.6,>=2.32.4
17
+ Requires-Dist: gql>=3.5.0
18
+ Requires-Dist: python-dotenv>=0.19.2
19
+ Requires-Dist: requirements-parser>=0.11.0
20
+ Requires-Dist: packaging>=23.2
21
+ Requires-Dist: semantic_version>=2.10.0
22
+ Requires-Dist: PyYAML>=6.0
23
+ Requires-Dist: mcp[cli]>=1.18.0
24
+ Requires-Dist: jsonschema>=4.19.0
25
+ Dynamic: license-file
26
+
27
+ # DepGate — Dependency Supply‑Chain Risk & Confusion Checker
28
+
29
+ DepGate is a modular CLI that detects dependency confusion and related supply‑chain risks across npm, Maven, and PyPI projects. It analyzes dependencies from manifests, checks public registries, and flags potential risks with a simple, scriptable interface.
30
+
31
+ DepGate is a fork of Apiiro’s “Dependency Combobulator”, maintained going forward by cognitivegears. See Credits & Attribution below.
32
+
33
+ ## Features
34
+
35
+ - Pluggable analysis: compare, heuristics, policy, and linked levels (`compare/comp`, `heuristics/heur`, `policy/pol`, `linked`).
36
+ - Multiple ecosystems: npm (`package.json`), Maven (`pom.xml`), PyPI (`requirements.txt`).
37
+ - Cross‑ecosystem version resolution with strict prerelease policies (npm/PyPI exclude prereleases by default; Maven latest excludes SNAPSHOT).
38
+ - Repository discovery and version validation (GitHub/GitLab): provenance, metrics (stars, last activity, contributors), and version match strategies (exact, pattern, exact‑bare, v‑prefix, suffix‑normalized).
39
+ - Flexible inputs: single package, manifest scan, or list from file.
40
+ - Structured outputs: human‑readable logs plus CSV/JSON exports for CI.
41
+ - Designed for automation: predictable exit codes and quiet/log options.
42
+
43
+ ## MCP server (experimental, additive)
44
+
45
+ DepGate includes an MCP server mode that exposes existing analysis via three tools using the official MCP Python SDK.
46
+
47
+ Quickstart:
48
+
49
+ 1. Start the server over stdio (default):
50
+
51
+ ```bash
52
+ depgate mcp
53
+ ```
54
+
55
+ 2. Or start a local TCP endpoint for testing (non-standard transport used by this repo for convenience):
56
+
57
+ ```bash
58
+ depgate mcp --host 127.0.0.1 --port 8765
59
+ ```
60
+
61
+ Tools exposed:
62
+
63
+ - Lookup_Latest_Version: Resolve latest stable version for npm/pypi/maven per DepGate rules.
64
+ - Scan_Project: Equivalent to `depgate scan` on a project directory.
65
+ - Scan_Dependency: Analyze a single coordinate without changing your project.
66
+
67
+ Common client examples:
68
+
69
+ - Claude Desktop / IDEs with MCP: Add a server entry pointing to the `depgate mcp` executable (stdio). The client handles the stdio handshake automatically.
70
+ - Node/JS agents (stdio): Spawn `depgate mcp` with stdio pipes and speak JSON‑RPC 2.0. List tools via `tools/list`, then call with `tools/call`.
71
+ - Python agents: Use the official MCP client libs; connect over stdio to `depgate mcp`.
72
+
73
+ Try it quickly (stdio, JSON-RPC):
74
+
75
+ - List tools
76
+
77
+ ```bash
78
+ printf '%s\n' \
79
+ '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","clientInfo":{"name":"cli","version":"0"},"capabilities":{}}}' \
80
+ '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' \
81
+ | depgate mcp
82
+ ```
83
+
84
+ - Call Lookup_Latest_Version and Scan_Dependency
85
+
86
+ ```bash
87
+ # npm (left-pad)
88
+ printf '%s\n' \
89
+ '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","clientInfo":{"name":"cli","version":"0"},"capabilities":{}}}' \
90
+ '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"Lookup_Latest_Version","arguments":{"name":"left-pad","ecosystem":"npm","versionRange":"^1.0.0"}}}' \
91
+ '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"Scan_Dependency","arguments":{"name":"left-pad","version":"1.3.0","ecosystem":"npm"}}}' \
92
+ | depgate mcp
93
+
94
+ # PyPI (requests)
95
+ # Use PEP 440 specifiers (e.g., ">=2,<3"); caret (^) is not valid for PyPI.
96
+ printf '%s\n' \
97
+ '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","clientInfo":{"name":"cli","version":"0"},"capabilities":{}}}' \
98
+ '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"Lookup_Latest_Version","arguments":{"name":"requests","ecosystem":"pypi","versionRange":">=2,<3"}}}' \
99
+ '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"Scan_Dependency","arguments":{"name":"requests","version":"2.32.5","ecosystem":"pypi"}}}' \
100
+ | depgate mcp
101
+
102
+ # Maven (groupId:artifactId coordinates)
103
+ printf '%s\n' \
104
+ '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","clientInfo":{"name":"cli","version":"0"},"capabilities":{}}}' \
105
+ '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"Lookup_Latest_Version","arguments":{"name":"org.apache.commons:commons-lang3","ecosystem":"maven"}}}' \
106
+ '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"Scan_Dependency","arguments":{"name":"org.apache.commons:commons-lang3","version":"3.19.0","ecosystem":"maven"}}}' \
107
+ | depgate mcp
108
+ ```
109
+
110
+ Sandboxing and environment:
111
+
112
+ - The server restricts filesystem access to a sandbox root. By default, it's the current working directory.
113
+ - If you pass absolute paths (e.g., to Scan_Project), run `depgate mcp --project-dir "/abs/path"` with a root that contains those paths.
114
+ - When developing with this repo installed in editable mode, avoid adding `src/` to PYTHONPATH when launching the server; it may shadow the external `mcp` SDK package. For tests that need mocks, add only `tests/e2e_mocks` to PYTHONPATH.
115
+
116
+ Flags & env:
117
+
118
+ - `--project-dir`: sandbox root for file access
119
+ - Networking: `--offline`, `--no-network`, cache TTL/dir
120
+ - Runtime: `--log-level`, `--max-concurrency`, `--request-timeout`
121
+
122
+ Notes:
123
+
124
+ - This mode is additive; existing commands and exit codes are unchanged.
125
+ - Tests and local development can use mocks via `FAKE_REGISTRY=1` with `PYTHONPATH=src:tests/e2e_mocks`.
126
+
127
+ ## Requirements
128
+
129
+ - Python 3.8+
130
+ - Network access for registry lookups when running analysis
131
+
132
+ ## Install
133
+
134
+ Using uv (development):
135
+
136
+ - `uv venv && source .venv/bin/activate`
137
+ - `uv sync`
138
+
139
+ From PyPI (after publishing):
140
+
141
+ - pip: `pip install depgate`
142
+ - pipx: `pipx install depgate`
143
+ - uvx: `uvx depgate --help`
144
+
145
+ ## Quick Start
146
+
147
+ - Single package (npm): `depgate scan -t npm -p left-pad`
148
+ - Scan a repo (Maven): `depgate scan -t maven -d ./tests`
149
+ - Heuristics + JSON: `depgate scan -t pypi -a heur -o out.json`
150
+ - Linked verification: `depgate scan -t npm -p left-pad -a linked -o out.json`
151
+
152
+ With uv during development:
153
+
154
+ - `uv run depgate scan -t npm -d ./tests`
155
+ - `uv run depgate scan -t pypi -a heur -o out.json`
156
+
157
+ ## Inputs and Scanning
158
+
159
+ - `-p, --package <name>`: single package name
160
+ - npm: package name (e.g., `left-pad`)
161
+ - PyPI: project name (e.g., `requests`)
162
+ - Maven: not used (see below)
163
+ - `-d, --directory <path>`: scan local source
164
+ - npm: finds `package.json` (and `devDependencies`)
165
+ - Maven: finds `pom.xml`, emits `groupId:artifactId`
166
+ - PyPI: finds `requirements.txt`
167
+ - `-l, --load_list <file>`: newline‑delimited identifiers
168
+ - npm/PyPI: package names per line
169
+ - Maven: `groupId:artifactId` per line
170
+
171
+ ## Analysis Levels
172
+
173
+ - `compare` or `comp`: presence/metadata checks against public registries
174
+ - `heuristics` or `heur`: adds scoring, version count, age signals
175
+ - `policy` or `pol`: declarative rule-based evaluation with allow/deny decisions
176
+ - `linked`: mirrors compare baseline and verifies repository linkage to an upstream source (GitHub/GitLab) and a tag or release matching the package version (including v‑prefix). Exits with code 0 only when all packages pass linkage; otherwise 1.
177
+
178
+ ### Linked analysis (repository linkage verification)
179
+
180
+ Supply‑chain context: recent attacks, particularly in the npm ecosystem, have involved attackers compromising developer credentials (for example, via phishing) and publishing malicious versions of popular libraries. Linked analysis helps mitigate this risk by verifying that each analyzed package:
181
+
182
+ - Has a resolvable upstream source repository (GitHub/GitLab)
183
+ - Contains a tag or release that exactly corresponds to the package’s published version (including v‑prefix compatibility)
184
+
185
+ Behavior and outputs:
186
+
187
+ - Strict exit semantics: process exits 0 only if all packages are linked; otherwise 1
188
+ - When `-a linked` is used, JSON includes: `repositoryUrl`, `tagMatch`, `releaseMatch`, and `linked`.
189
+
190
+ Examples:
191
+
192
+ - npm: `depgate scan -t npm -p left-pad -a linked -o out.json`
193
+ - pypi: `depgate scan -t pypi -p requests -a linked -o out.json`
194
+ - maven: `depgate scan -t maven -p org.apache.commons:commons-lang3 -a linked -o out.json`
195
+
196
+ ## Repository discovery & version validation
197
+
198
+ DepGate discovers canonical source repositories from registry metadata, normalizes URLs, fetches metrics, and attempts to match the published version against repository releases/tags.
199
+
200
+ - Discovery sources:
201
+ - npm: versions[dist‑tags.latest].repository (string or object), fallbacks to homepage and bugs.url
202
+ - PyPI: info.project_urls (Repository/Source/Code preferred), fallback Homepage/Documentation; Read the Docs URLs are resolved to backing repos
203
+ - Maven: POM scm (url/connection/developerConnection) with parent traversal; fallback url when repo‑like
204
+ - URL normalization: canonical host/owner/repo form (strip .git), host detection (github|gitlab), monorepo directory hints preserved in provenance
205
+ - Metrics: stars, last activity timestamp, approximate contributors
206
+ - Version matching strategies (in order):
207
+ 1) exact (raw label equality)
208
+ 2) pattern (custom patterns, run against raw labels)
209
+ 3) exact‑bare (extracted version token equality; e.g., 'v1.0.0' tag matches '1.0.0' request)
210
+ 4) v‑prefix (vX.Y.Z ↔ X.Y.Z)
211
+ 5) suffix‑normalized (e.g., Maven .RELEASE/.Final/.GA stripped)
212
+ - Tag/release name returned prefers the bare token unless both v‑prefixed and bare forms co‑exist, in which case the raw label is preserved.
213
+
214
+ Notes:
215
+
216
+ - Exact‑unsatisfiable guard: when an exact spec cannot be resolved to a concrete version (e.g., CLI requested exact but no resolved_version), matching is disabled (empty version passed to matcher). Metrics still populate and provenance is recorded.
217
+
218
+
219
+ ### Configuration (optional but recommended)
220
+
221
+ - export GITHUB_TOKEN and/or GITLAB_TOKEN to raise rate limits for provider API calls.
222
+
223
+ See detailed design in [docs/repository-integration.md](docs/repository-integration.md:1) and architecture in [docs/provider-architecture.md](docs/provider-architecture.md:1).
224
+
225
+ ## Output
226
+
227
+ - Default: logs to stdout (respecting `--loglevel` and `--quiet`)
228
+ - File export: `-o, --output <path>` and `-f, --format {json,csv}`
229
+ - If `--format` is omitted, inferred from `--output` extension (`.json` / `.csv`), otherwise defaults to JSON.
230
+ - CSV columns: `Package Name, Package Type, Exists on External, Org/Group ID, Score, Version Count, Timestamp, Risk: Missing, Risk: Low Score, Risk: Min Versions, Risk: Too New, Risk: Any Risks, [policy fields], [license fields]`
231
+ - JSON schema: objects with keys: `packageName, orgId, packageType, exists, score, versionCount, createdTimestamp, risk.{hasRisk,isMissing,hasLowScore,minVersions,isNew}, policy.{decision,violated_rules,evaluated_metrics}, license.{id,available,source}`. When `-a linked` is used, the JSON also includes: `repositoryUrl`, `tagMatch`, `releaseMatch`, and `linked`.
232
+
233
+ ## CLI Options (summary)
234
+
235
+ - `-t, --type {npm,pypi,maven}`: package manager
236
+ - `-p/‑d/‑l`: input source (mutually exclusive)
237
+ - `-a, --analysis {compare,comp,heuristics,heur,policy,pol,linked}`: analysis level
238
+ - Output: `-o, --output <path>` and `-f, --format {json,csv}`
239
+ - Config: `-c, --config <path>` (YAML/JSON/YML), `--set KEY=VALUE` (dot-path overrides)
240
+ - Logging: `--loglevel {DEBUG,INFO,WARNING,ERROR,CRITICAL}`, `--logfile <path>`, `-q, --quiet`
241
+ - Scanning: `-r, --recursive` (for `--directory` scans)
242
+ - CI: `--error-on-warnings` (non‑zero exit if risks detected)
243
+
244
+ ## Resolution semantics (overview)
245
+
246
+ - Rightmost‑colon token parsing for Maven coordinates (groupId:artifactId) while preserving ecosystem normalization for npm/PyPI names.
247
+ - Ecosystem‑aware resolution:
248
+ - npm: ranges respect semver; prereleases excluded from latest/ranges unless explicitly included
249
+ - PyPI: PEP 440; prereleases excluded unless explicitly requested
250
+ - Maven: latest excludes SNAPSHOT; ranges honor bracket semantics
251
+
252
+ ## YAML configuration
253
+
254
+ DepGate optionally reads a YAML configuration file to override defaults such as registry URLs and HTTP behavior.
255
+
256
+ Search order (first found wins):
257
+
258
+ 1. DEPGATE_CONFIG environment variable (absolute path)
259
+ 2. ./depgate.yml (or ./.depgate.yml)
260
+ 3. $XDG_CONFIG_HOME/depgate/depgate.yml (or ~/.config/depgate/depgate.yml)
261
+ 4. macOS: ~/Library/Application Support/depgate/depgate.yml
262
+ 5. Windows: %APPDATA%\\depgate\\depgate.yml
263
+
264
+ Example:
265
+
266
+ ```yaml
267
+ http:
268
+ request_timeout: 30 # seconds
269
+ retry_max: 3
270
+ retry_base_delay_sec: 0.3
271
+ cache_ttl_sec: 300
272
+
273
+ registry:
274
+ pypi_base_url: "https://pypi.org/pypi/"
275
+ npm_base_url: "https://registry.npmjs.org/"
276
+ npm_stats_url: "https://api.npms.io/v2/package/mget"
277
+ maven_search_url: "https://search.maven.org/solrsearch/select"
278
+
279
+ provider:
280
+ github_api_base: "https://api.github.com"
281
+ gitlab_api_base: "https://gitlab.com/api/v4"
282
+ per_page: 100
283
+
284
+ heuristics:
285
+ weights:
286
+ base_score: 0.30
287
+ repo_version_match: 0.30
288
+ repo_stars: 0.15
289
+ repo_contributors: 0.10
290
+ repo_last_activity: 0.10
291
+ repo_present_in_registry: 0.05
292
+
293
+ rtd:
294
+ api_base: "https://readthedocs.org/api/v3"
295
+ ```
296
+
297
+ All keys are optional; unspecified values fall back to built‑in defaults. Additional options may be added over time.
298
+
299
+ Heuristics weights are non‑negative numbers expressing relative priority for each signal. They are automatically re‑normalized across the metrics that are available for a given package, so the absolute values do not need to sum to 1. Unknown keys are ignored; missing metrics are excluded from the normalization set.
300
+
301
+ ## Policy Configuration
302
+
303
+ The `policy` analysis level uses declarative configuration to evaluate allow/deny rules against package facts. Policy configuration can be provided via `-c, --config` (YAML/JSON/YML file) and overridden with `--set KEY=VALUE` options.
304
+
305
+ ### Policy Configuration Schema
306
+
307
+ ```yaml
308
+ policy:
309
+ enabled: true # Global policy enable/disable
310
+ fail_fast: true # Stop at first violation (default: false)
311
+ metrics: # Declarative metric constraints
312
+ stars_count: { min: 5 } # Minimum stars
313
+ heuristic_score: { min: 0.6 } # Minimum heuristic score
314
+ version_count: { min: 3 } # Minimum version count
315
+ regex: # Regex-based rules
316
+ include: ["^@myorg/"] # Must match at least one include pattern
317
+ exclude: ["-beta$"] # Must not match any exclude pattern
318
+ license_check: # License validation
319
+ enabled: true # Enable license discovery/checking
320
+ disallowed_licenses: ["GPL-3.0-only", "AGPL-3.0-only"]
321
+ allow_unknown: false # Allow packages with unknown licenses
322
+ output:
323
+ include_license_fields: true # Include license fields in output
324
+ ```
325
+
326
+ ### Dot-path Override Examples
327
+
328
+ ```bash
329
+ # Override specific metric constraints
330
+ depgate scan -t npm -p left-pad -a policy --set policy.metrics.heuristic_score.min=0.8
331
+
332
+ # Disable license checking
333
+ depgate scan -t npm -p left-pad -a policy --set policy.license_check.enabled=false
334
+
335
+ # Change fail_fast behavior
336
+ depgate scan -t npm -p left-pad -a policy --set policy.fail_fast=true
337
+ ```
338
+
339
+ ### Implicit Heuristics Trigger
340
+
341
+ When policy rules reference heuristic-derived metrics (e.g., `heuristic_score`, `is_license_available`), the system automatically runs heuristics analysis for affected packages if those metrics are missing. This ensures policy evaluation has access to all required data without manual intervention.
342
+
343
+ ### License Discovery Performance
344
+
345
+ License discovery uses LRU caching (default maxsize: 256) to minimize network calls. It follows a metadata-first strategy:
346
+
347
+ 1. Check registry metadata for license information
348
+ 2. Optionally fall back to repository file parsing (LICENSE, LICENSE.md)
349
+ 3. Cache results per (repo_url, ref) combination
350
+
351
+ Set `policy.license_check.enabled=false` to disable all license-related network calls.
352
+
353
+ ### New Heuristic: is_license_available
354
+
355
+ The `is_license_available` heuristic indicates whether license information is available for a package. This boolean value is computed from existing registry enrichment data and is automatically included when heuristics run.
356
+
357
+ ## Exit Codes
358
+
359
+ - `0`: success (no risks or informational only)
360
+ - `1`: file/IO error
361
+ - `2`: connection error
362
+ - `3`: risks found and `--error-on-warnings` set
363
+
364
+ Note: For `-a linked`, the process exits with `0` only when all analyzed packages are linked (repository resolved+exists and version tag/release match); otherwise it exits with `1`.
365
+
366
+ ## Contributing
367
+
368
+ - See `AGENTS.md` for repo layout, dev commands, and linting.
369
+ - Lint: `uv run pylint src`
370
+
371
+ ## Credits & Attribution
372
+
373
+ - DepGate is a fork of “Dependency Combobulator” originally developed by Apiiro and its contributors: <https://github.com/apiiro/combobulator> - see `CONTRIBUTORS.md`.
374
+ - Licensed under the Apache License 2.0. See `LICENSE` and `NOTICE`.