Skip to content
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

Improve handling for hashing unknown packages #9556

Merged
merged 14 commits into from
May 3, 2024

Conversation

jurre
Copy link
Member

@jurre jurre commented Apr 22, 2024

Original issue: #7907

Dependabot attempts to resolve package hashes from PyPI, but some packages are hosted on private registries. To address this, we iterate though the index URLs set in dependaboy.yml and pass them to the native helper until a match is found.

@robaiken robaiken self-assigned this Apr 30, 2024
@robaiken robaiken marked this pull request as ready for review April 30, 2024 16:39
@robaiken robaiken requested a review from a team as a code owner April 30, 2024 16:39
@robaiken robaiken force-pushed the jurre/hash-private-packages branch from a38e561 to 4052a33 Compare May 1, 2024 15:02
@robaiken robaiken linked an issue May 2, 2024 that may be closed by this pull request
@robaiken robaiken merged commit aee7bb9 into main May 3, 2024
59 checks passed
@robaiken robaiken deleted the jurre/hash-private-packages branch May 3, 2024 14:51
@lorengordon
Copy link
Contributor

@jurre Since this change, in our dependabot-script implementation, I've been getting this error. Any idea what this change actually depends on or expects as far as configuration, in order to successfully setup the python updater?

E, [2024-06-04T13:31:42.916676 #7] ERROR -- : Dependabot encountered an error processing <project> : pip: / : undefined method `replaces_base?' for an instance of Hash.
E, [2024-06-04T13:31:42.916718 #7] ERROR -- : [
    "/home/dependabot/dependabot-script/vendor/ruby/3.3.0/gems/dependabot-python-0.259.0/lib/dependabot/python/file_updater.rb:123:in `any?'",
    "/home/dependabot/dependabot-script/vendor/ruby/3.3.0/gems/dependabot-python-0.259.0/lib/dependabot/python/file_updater.rb:123:in `pip_compile_index_urls'",
    "/home/dependabot/dependabot-script/vendor/ruby/3.3.0/gems/dependabot-python-0.259.0/lib/dependabot/python/file_updater.rb:118:in `updated_requirement_based_files'",
    "/home/dependabot/dependabot-script/vendor/ruby/3.3.0/gems/dependabot-python-0.259.0/lib/dependabot/python/file_updater.rb:36:in `updated_dependency_files'",
    "/home/dependabot/dependabot-script/updater.rb:153:in `block (2 levels) in update'",
    "/home/dependabot/dependabot-script/retries.rb:52:in `with_retries'",
    "/home/dependabot/dependabot-script/updater.rb:105:in `block in update'",
    "/home/dependabot/dependabot-script/updater.rb:99:in `each'",
    "/home/dependabot/dependabot-script/updater.rb:99:in `update'",
    "./dependabot.rb:70:in `block (3 levels) in <main>'",
    "./dependabot.rb:67:in `each'",
    "./dependabot.rb:67:in `block (2 levels) in <main>'",
    "./dependabot.rb:58:in `each'",
    "./dependabot.rb:58:in `block in <main>'",
    "./dependabot.rb:34:in `each'",
    "./dependabot.rb:34:in `<main>'"
]

@lorengordon
Copy link
Contributor

Ok, I'm guessing that since #8967, the Array of Hash for credentials is no longer valid, but still used by dependabot-script. Investigating how to setup the credential using the class...

@lorengordon
Copy link
Contributor

Yep, that was it. Fixed it, #8967 (comment)


index_urls.each do |index_url|
args = [name, version, algorithm]
args << index_url if index_url

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jurre: I think there is a problem with this 4th arg that is causing the issues seen in:

In some cases, that arg ends up being "/pypi/<package-name>/json" (e.g. "/pypi/zope-interface/json") which is not a full URL and causes an error when passed as is to hashin.get_package_hashes in python/helpers/lib/hasher.py.
https://pypi.org/pypi/zope-interface/json is a valid URL, so either the caller should provide the full URL, or some function down the line should concatenate that path to the domain to form a full URL before calling hashin.get_package_hashes.

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

Successfully merging this pull request may close these issues.

pip: Dependency Hashing does not work for Private Python Registries
5 participants