python-inspector 0.15.3__tar.gz → 0.15.4__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 (111) hide show
  1. {python_inspector-0.15.3 → python_inspector-0.15.4}/CHANGELOG.rst +11 -0
  2. {python_inspector-0.15.3 → python_inspector-0.15.4}/PKG-INFO +1 -1
  3. {python_inspector-0.15.3 → python_inspector-0.15.4}/setup.cfg +1 -1
  4. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/utils_pypi.py +43 -1
  5. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector.egg-info/PKG-INFO +1 -1
  6. {python_inspector-0.15.3 → python_inspector-0.15.4}/tests/test_utils_pypi.py +89 -0
  7. {python_inspector-0.15.3 → python_inspector-0.15.4}/.gitignore +0 -0
  8. {python_inspector-0.15.3 → python_inspector-0.15.4}/.readthedocs.yml +0 -0
  9. {python_inspector-0.15.3 → python_inspector-0.15.4}/AUTHORS.rst +0 -0
  10. {python_inspector-0.15.3 → python_inspector-0.15.4}/CODE_OF_CONDUCT.rst +0 -0
  11. {python_inspector-0.15.3 → python_inspector-0.15.4}/MANIFEST.in +0 -0
  12. {python_inspector-0.15.3 → python_inspector-0.15.4}/Makefile +0 -0
  13. {python_inspector-0.15.3 → python_inspector-0.15.4}/NOTICE +0 -0
  14. {python_inspector-0.15.3 → python_inspector-0.15.4}/README.rst +0 -0
  15. {python_inspector-0.15.3 → python_inspector-0.15.4}/apache-2.0.LICENSE +0 -0
  16. {python_inspector-0.15.3 → python_inspector-0.15.4}/azure-pipelines.yml +0 -0
  17. {python_inspector-0.15.3 → python_inspector-0.15.4}/configure +0 -0
  18. {python_inspector-0.15.3 → python_inspector-0.15.4}/configure.bat +0 -0
  19. {python_inspector-0.15.3 → python_inspector-0.15.4}/docs/Makefile +0 -0
  20. {python_inspector-0.15.3 → python_inspector-0.15.4}/docs/make.bat +0 -0
  21. {python_inspector-0.15.3 → python_inspector-0.15.4}/docs/source/_static/theme_overrides.css +0 -0
  22. {python_inspector-0.15.3 → python_inspector-0.15.4}/docs/source/conf.py +0 -0
  23. {python_inspector-0.15.3 → python_inspector-0.15.4}/docs/source/contribute/contrib_doc.rst +0 -0
  24. {python_inspector-0.15.3 → python_inspector-0.15.4}/docs/source/dependencies-design.rst +0 -0
  25. {python_inspector-0.15.3 → python_inspector-0.15.4}/docs/source/index.rst +0 -0
  26. {python_inspector-0.15.3 → python_inspector-0.15.4}/docs/source/test-protocol.rst +0 -0
  27. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/ci/azure-container-deb.yml +0 -0
  28. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/ci/azure-container-rpm.yml +0 -0
  29. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/ci/azure-posix.yml +0 -0
  30. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/ci/azure-win.yml +0 -0
  31. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/ci/install_sudo.sh +0 -0
  32. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/ci/macports-ci +0 -0
  33. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/ci/macports-ci.ABOUT +0 -0
  34. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/ci/mit.LICENSE +0 -0
  35. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/README.rst +0 -0
  36. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/check_thirdparty.py +0 -0
  37. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/fetch_thirdparty.py +0 -0
  38. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/gen_pypi_simple.py +0 -0
  39. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/gen_pypi_simple.py.ABOUT +0 -0
  40. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/gen_pypi_simple.py.NOTICE +0 -0
  41. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/gen_requirements.py +0 -0
  42. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/gen_requirements_dev.py +0 -0
  43. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/requirements.txt +0 -0
  44. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/test_utils_pip_compatibility_tags.py +0 -0
  45. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/test_utils_pip_compatibility_tags.py.ABOUT +0 -0
  46. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/test_utils_pypi_supported_tags.py +0 -0
  47. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/test_utils_pypi_supported_tags.py.ABOUT +0 -0
  48. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/update_skeleton.py +0 -0
  49. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/utils_dejacode.py +0 -0
  50. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/utils_pip_compatibility_tags.py +0 -0
  51. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/utils_pip_compatibility_tags.py.ABOUT +0 -0
  52. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/utils_pypi_supported_tags.py +0 -0
  53. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/utils_pypi_supported_tags.py.ABOUT +0 -0
  54. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/utils_requirements.py +0 -0
  55. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/utils_thirdparty.py +0 -0
  56. {python_inspector-0.15.3 → python_inspector-0.15.4}/etc/scripts/utils_thirdparty.py.ABOUT +0 -0
  57. {python_inspector-0.15.3 → python_inspector-0.15.4}/pyproject.toml +0 -0
  58. {python_inspector-0.15.3 → python_inspector-0.15.4}/requirements-dev.txt +0 -0
  59. {python_inspector-0.15.3 → python_inspector-0.15.4}/requirements.txt +0 -0
  60. {python_inspector-0.15.3 → python_inspector-0.15.4}/requirements_builder.ABOUT +0 -0
  61. {python_inspector-0.15.3 → python_inspector-0.15.4}/setup.py +0 -0
  62. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/_packagedcode/__init__.py +0 -0
  63. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/_packagedcode/models.py +0 -0
  64. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/_packagedcode/pypi.py +0 -0
  65. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/_packagedcode/pypi.py.ABOUT +0 -0
  66. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/_packagedcode/pypi.py.NOTICE +0 -0
  67. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/_packagedcode/pypi_setup_py.py +0 -0
  68. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/_packagedcode/pypi_setup_py.py.ABOUT +0 -0
  69. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/_packagedcode/pypi_setup_py.py.LICENSE +0 -0
  70. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/_packagedcode/utils.py +0 -0
  71. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/__init__.py +0 -0
  72. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/api.py +0 -0
  73. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/cli_utils.py +0 -0
  74. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/dependencies.py +0 -0
  75. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/error.py +0 -0
  76. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/lockfile.py +0 -0
  77. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/package_data.py +0 -0
  78. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/pylock_toml.py +0 -0
  79. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/resolution.py +0 -0
  80. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/resolution.py.ABOUT +0 -0
  81. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/resolution.py.LICENSE +0 -0
  82. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/resolve_cli.py +0 -0
  83. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/settings.py +0 -0
  84. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/setup_py_live_eval.py +0 -0
  85. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/setup_py_live_eval.py.ABOUT +0 -0
  86. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/setup_py_live_eval.py.LICENSE +0 -0
  87. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/utils.py +0 -0
  88. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/utils_pip_compatibility_tags.py +0 -0
  89. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/utils_pip_compatibility_tags.py.ABOUT +0 -0
  90. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/utils_pypi.py.ABOUT +0 -0
  91. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/utils_pypi_supported_tags.py +0 -0
  92. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector/utils_pypi_supported_tags.py.ABOUT +0 -0
  93. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector.egg-info/SOURCES.txt +0 -0
  94. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector.egg-info/dependency_links.txt +0 -0
  95. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector.egg-info/entry_points.txt +0 -0
  96. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector.egg-info/not-zip-safe +0 -0
  97. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector.egg-info/requires.txt +0 -0
  98. {python_inspector-0.15.3 → python_inspector-0.15.4}/src/python_inspector.egg-info/top_level.txt +0 -0
  99. {python_inspector-0.15.3 → python_inspector-0.15.4}/tests/test_api.py +0 -0
  100. {python_inspector-0.15.3 → python_inspector-0.15.4}/tests/test_cli.py +0 -0
  101. {python_inspector-0.15.3 → python_inspector-0.15.4}/tests/test_packagecode_pypi.py +0 -0
  102. {python_inspector-0.15.3 → python_inspector-0.15.4}/tests/test_pylock.py +0 -0
  103. {python_inspector-0.15.3 → python_inspector-0.15.4}/tests/test_pypi.py +0 -0
  104. {python_inspector-0.15.3 → python_inspector-0.15.4}/tests/test_requirement_parsing.py +0 -0
  105. {python_inspector-0.15.3 → python_inspector-0.15.4}/tests/test_resolution.py +0 -0
  106. {python_inspector-0.15.3 → python_inspector-0.15.4}/tests/test_sdist_extract.py +0 -0
  107. {python_inspector-0.15.3 → python_inspector-0.15.4}/tests/test_setup_py_live_eval.py +0 -0
  108. {python_inspector-0.15.3 → python_inspector-0.15.4}/tests/test_setup_py_parsing.py +0 -0
  109. {python_inspector-0.15.3 → python_inspector-0.15.4}/tests/test_utils.py +0 -0
  110. {python_inspector-0.15.3 → python_inspector-0.15.4}/tests/test_utils_pip_compatibility_tags.py +0 -0
  111. {python_inspector-0.15.3 → python_inspector-0.15.4}/tests/test_utils_pypi_supported_tags.py +0 -0
@@ -1,6 +1,17 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ v0.15.4
5
+ -----------
6
+ - Stop sending private-index credentials to wheel hosts that are not the index.
7
+ Netrc credentials were chosen for the index hostname and stored on the
8
+ repository. Wheel downloads then copied those credentials onto every linked
9
+ wheel, and the HTTP helper sent them as Basic authentication. A private feed
10
+ can link a wheel on another host, such as a public mirror or CDN, so that
11
+ host received the index token on a new request. Credentials are now attached
12
+ only when the wheel URL has the same origin as the index URL: scheme,
13
+ hostname, and port. A wheel served by the index itself still receives them.
14
+
4
15
  v0.15.3
5
16
  -----------
6
17
  - Add support for PEP 751 pylock.toml lock files as input.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-inspector
3
- Version: 0.15.3
3
+ Version: 0.15.4
4
4
  Summary: python-inspector is is a collection of utilities to collect PyPI package metadata and resolve packages dependencies.
5
5
  Home-page: https://github.com/aboutcode-org/python-inspector
6
6
  Author: nexB. Inc. and others
@@ -1,7 +1,7 @@
1
1
  [metadata]
2
2
  name = python-inspector
3
3
  license = Apache-2.0
4
- version = 0.15.3
4
+ version = 0.15.4
5
5
  description = python-inspector is is a collection of utilities to collect PyPI package metadata and resolve packages dependencies.
6
6
  long_description = file:README.rst
7
7
  long_description_content_type = text/x-rst
@@ -218,6 +218,44 @@ collect_urls = re.compile('href="([^"]+)"').findall
218
218
  ################################################################################
219
219
 
220
220
 
221
+ def _url_origin(url):
222
+ """
223
+ Return the ``(scheme, hostname, port)`` origin of ``url``, or None.
224
+ """
225
+ parsed = urlparse(url)
226
+ scheme = (parsed.scheme or "").lower()
227
+ hostname = (parsed.hostname or "").lower()
228
+ if not scheme or not hostname:
229
+ return None
230
+ try:
231
+ port = parsed.port
232
+ except ValueError:
233
+ return None
234
+ if port is None:
235
+ if scheme == "https":
236
+ port = 443
237
+ elif scheme == "http":
238
+ port = 80
239
+ else:
240
+ return None
241
+ return scheme, hostname, port
242
+
243
+
244
+ def credentials_for_linked_download(credentials, index_url, download_url):
245
+ """
246
+ Return ``credentials`` when ``download_url`` has the same origin as ``index_url``.
247
+
248
+ Credentials selected for a private index authorize that index origin only.
249
+ A wheel or sdist linked on another host must be fetched without them.
250
+ """
251
+ if not credentials:
252
+ return None
253
+ index_origin = _url_origin(index_url)
254
+ if not index_origin or index_origin != _url_origin(download_url):
255
+ return None
256
+ return credentials
257
+
258
+
221
259
  class DistributionNotFound(Exception):
222
260
  pass
223
261
 
@@ -258,7 +296,11 @@ async def download_wheel(
258
296
  )
259
297
  continue
260
298
  for wheel in supported_and_valid_wheels:
261
- wheel.credentials = repo.credentials
299
+ wheel.credentials = credentials_for_linked_download(
300
+ credentials=repo.credentials,
301
+ index_url=repo.index_url,
302
+ download_url=wheel.path_or_url,
303
+ )
262
304
  fetched_wheel_filename = await wheel.download(
263
305
  dest_dir=dest_dir,
264
306
  verbose=verbose,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-inspector
3
- Version: 0.15.3
3
+ Version: 0.15.4
4
4
  Summary: python-inspector is is a collection of utilities to collect PyPI package metadata and resolve packages dependencies.
5
5
  Home-page: https://github.com/aboutcode-org/python-inspector
6
6
  Author: nexB. Inc. and others
@@ -165,3 +165,92 @@ def test_PypiPackage_get_supported_wheels(linux_platform):
165
165
  supported_wheels = list(pkg.get_supported_wheels(environment=env))
166
166
 
167
167
  assert supported_wheels == [whl]
168
+
169
+
170
+ INDEX_CREDENTIALS = {"login": "index-user", "password": "index-secret"}
171
+
172
+
173
+ def test_credentials_stay_on_the_index_origin():
174
+ index_url = "https://127.0.0.1:8443/simple"
175
+ same_origin = "https://127.0.0.1:8443/packages/demo-1.0.0-py3-none-any.whl"
176
+ other_host = "https://localhost:8443/packages/demo-1.0.0-py3-none-any.whl"
177
+ other_scheme = "http://127.0.0.1:8443/packages/demo-1.0.0-py3-none-any.whl"
178
+ default_https_port = "https://127.0.0.1/packages/demo-1.0.0-py3-none-any.whl"
179
+
180
+ assert (
181
+ utils_pypi.credentials_for_linked_download(INDEX_CREDENTIALS, index_url, same_origin)
182
+ == INDEX_CREDENTIALS
183
+ )
184
+ assert (
185
+ utils_pypi.credentials_for_linked_download(INDEX_CREDENTIALS, index_url, other_host) is None
186
+ )
187
+ assert (
188
+ utils_pypi.credentials_for_linked_download(INDEX_CREDENTIALS, index_url, other_scheme)
189
+ is None
190
+ )
191
+ assert (
192
+ utils_pypi.credentials_for_linked_download(INDEX_CREDENTIALS, index_url, default_https_port)
193
+ is None
194
+ )
195
+ assert utils_pypi.credentials_for_linked_download(None, index_url, same_origin) is None
196
+
197
+
198
+ @pytest.mark.asyncio
199
+ async def test_download_wheel_does_not_send_index_credentials_to_another_host(monkeypatch):
200
+ repo = utils_pypi.PypiSimpleRepository(
201
+ index_url="https://127.0.0.1:8443/simple",
202
+ credentials=INDEX_CREDENTIALS,
203
+ )
204
+ wheel = Wheel.from_filename("demo-1.0.0-py3-none-any.whl")
205
+ wheel.path_or_url = "https://localhost:8443/packages/demo-1.0.0-py3-none-any.whl"
206
+ seen = {}
207
+
208
+ async def fake_wheels(*args, **kwargs):
209
+ return [wheel]
210
+
211
+ async def fake_download(self, **kwargs):
212
+ seen["credentials"] = self.credentials
213
+ return self.filename
214
+
215
+ monkeypatch.setattr(utils_pypi, "get_supported_and_valid_wheels", fake_wheels)
216
+ monkeypatch.setattr(utils_pypi.Distribution, "download", fake_download)
217
+
218
+ filenames = await utils_pypi.download_wheel(
219
+ name="demo",
220
+ version="1.0.0",
221
+ environment=None,
222
+ repos=(repo,),
223
+ )
224
+
225
+ assert filenames == ["demo-1.0.0-py3-none-any.whl"]
226
+ assert seen["credentials"] is None
227
+
228
+
229
+ @pytest.mark.asyncio
230
+ async def test_download_wheel_keeps_credentials_for_the_index_origin(monkeypatch):
231
+ repo = utils_pypi.PypiSimpleRepository(
232
+ index_url="https://127.0.0.1:8443/simple",
233
+ credentials=INDEX_CREDENTIALS,
234
+ )
235
+ wheel = Wheel.from_filename("demo-1.0.0-py3-none-any.whl")
236
+ wheel.path_or_url = "https://127.0.0.1:8443/packages/demo-1.0.0-py3-none-any.whl"
237
+ seen = {}
238
+
239
+ async def fake_wheels(*args, **kwargs):
240
+ return [wheel]
241
+
242
+ async def fake_download(self, **kwargs):
243
+ seen["credentials"] = self.credentials
244
+ return self.filename
245
+
246
+ monkeypatch.setattr(utils_pypi, "get_supported_and_valid_wheels", fake_wheels)
247
+ monkeypatch.setattr(utils_pypi.Distribution, "download", fake_download)
248
+
249
+ await utils_pypi.download_wheel(
250
+ name="demo",
251
+ version="1.0.0",
252
+ environment=None,
253
+ repos=(repo,),
254
+ )
255
+
256
+ assert seen["credentials"] == INDEX_CREDENTIALS