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

(#3566) Avoid credential bleed from saved sources with the same hostname #3572

Merged
merged 3 commits into from
Nov 26, 2024

Commits on Nov 25, 2024

  1. (chocolatey#3566) Add ExplicitSources property

    The ExplicitSources property is used when looking up credentials. This
    backports this property from 2.x to 1.x.
    corbob committed Nov 25, 2024
    Configuration menu
    Copy the full SHA
    e9911c6 View commit details
    Browse the repository at this point in the history
  2. (chocolatey#3566) Rework NugetCredentialProvider

    Previously we looked up any available sources in the config by the
    hostname, before falling back to trying an exact match if we had
    collisions.
    
    This still allowed credentials to be reused in situations where we don't
    actually know if they're applicable; many repository servers will
    support different credentials for individual repositories, so we cannot
    and should not assume that credentials for one repository will actually
    match another repository, nor that users want the credentials to be
    shared for both.
    
    It also led to the possibility of users storing one repository first,
    and then later specifying a different repository on the same server, and
    choco would try to use the stored credentials for the first repository
    for the explicitly-entered URL which is nowhere in config.
    
    Instead, we should only match the whole URL (which can be done with
    Uri. Equals to ensure that we match hostnames case-insensitively, but
    routes case-sensitively), and expect users to provide credentials if
    they provide a URL that is not explicitly in the sources.
    
    Additionally, we try to ensure that if a user has named a specific
    source, rather than themselves providing a URL at the command line, we
    prioritise finding that in the already-configured sources and use that
    source if the URL matches the current URL that NuGet requires a
    credential for.
    corbob committed Nov 25, 2024
    Configuration menu
    Copy the full SHA
    bafa7eb View commit details
    Browse the repository at this point in the history

Commits on Nov 26, 2024

  1. (chocolatey#3566) Add Pester tests for Credential Provider

    Add Pester tests to ensure we don't inadvertently bleed configured
    credentials into scenarios where they should not be used.
    corbob committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    3d599b1 View commit details
    Browse the repository at this point in the history