Skip to content

Fix issues with authenticated indexes #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 27, 2025

Conversation

MarcelBochtler
Copy link
Contributor

@MarcelBochtler MarcelBochtler commented Jun 18, 2025

This PR fixes two issues with the netrc handling of python-inspector:

  1. Support host names in the netrc file, instead of relying on full URLs. This fixes .netrc file is queried incorrectly #176.
  2. Support the special default host name

Please take a look at the specific commits for details.

Resolves: #127 and #176

According to the netrc specification (see [1] and [2]), the `machine`
part should not be a full URL, but only a host name.
Before, using the correct netrc format with only a host name did not
work for authentication purposes in Python Inspector.
Fix this by using urllib.parse to find the matching host name.

[1]: https://www.ibm.com/docs/en/aix/7.2.0?topic=formats-netrc-file-format-tcpip
[2]: https://docs.python.org/3/library/netrc.html#netrc.netrc.hosts

Resolves: aboutcode-org#176.

Signed-off-by: Marcel Bochtler <marcel.bochtler@bosch.com>
Support the fallback to `default` if the user did not set a specific
host name in their netrc file.

Signed-off-by: Marcel Bochtler <marcel.bochtler@bosch.com>
@MarcelBochtler MarcelBochtler marked this pull request as draft June 18, 2025 11:10
Signed-off-by: Marcel Bochtler <marcel.bochtler@bosch.com>
@MarcelBochtler MarcelBochtler changed the title Fix incorrect netrc handling Fix issues with authenticated indexes Jun 18, 2025
@MarcelBochtler MarcelBochtler marked this pull request as ready for review June 18, 2025 12:50
In PyPI simple repository format, package URLs typically end with the
package name and should have a trailing slash [1].
To ensure this trailing slash, the some web servers might redirect to
the URL with the trailing slash.
This causes the issue that the BasicAuth credentials are removed from
the request for security reasons.

This was observed with an internal Artifactory repository and adding a
trailing slash to the package_url fixes the issue.

[1]: https://peps.python.org/pep-0503/#specification

Resolves: aboutcode-org#127.

Signed-off-by: Marcel Bochtler <marcel.bochtler@bosch.com>
@MarcelBochtler
Copy link
Contributor Author

@pombredanne do you mind taking a look?

@kerstin-bosch
Copy link

Hi @pombredanne, Could you give us an update here? Can you approve Marcel's PR and create a release? It would be extremely important for us, as our customer has been waiting for a solution for months. If there's anything we can do to help, please let us know. Thank you!

@sschuberth
Copy link
Contributor

@tsteenbe can you help to move this forward?

@pombredanne pombredanne merged commit e1b179e into aboutcode-org:main Jun 27, 2025
11 of 15 checks passed
@tsteenbe
Copy link

tsteenbe commented Jun 27, 2025

@sschuberth Had a call with Philippe - the PR was blocked due to failing tests, updated expected test results was needed - created a 2nd PR as we couldn't update the one from @MarcelBochtler due to lack of permissions.

@mnonnenmacher
Copy link

@pombredanne @tsteenbe Could you please make a release with this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.netrc file is queried incorrectly Having private packages makes python-inspector crashes
6 participants