forked from dependabot/dependabot-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dependabot#8324 from dependabot/deivid-rodriguez/f…
…etch-pnpm-404 Catch more 404 PNPM fetch errors and raise them as user errors
- Loading branch information
Showing
15 changed files
with
486 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
npm_and_yarn/lib/dependabot/npm_and_yarn/registry_parser.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# typed: false | ||
# frozen_string_literal: true | ||
|
||
module Dependabot | ||
module NpmAndYarn | ||
class RegistryParser | ||
def initialize(resolved_url:, credentials:) | ||
@resolved_url = resolved_url | ||
@credentials = credentials | ||
end | ||
|
||
def registry_source_for(name) | ||
url = | ||
if resolved_url.include?("/~/") | ||
# Gemfury format | ||
resolved_url.split("/~/").first | ||
elsif resolved_url.include?("/#{name}/-/#{name}") | ||
# MyGet / Bintray format | ||
resolved_url.split("/#{name}/-/#{name}").first | ||
.gsub("dl.bintray.com//", "api.bintray.com/npm/"). | ||
# GitLab format | ||
gsub(%r{\/projects\/\d+}, "") | ||
elsif resolved_url.include?("/#{name}/-/#{name.split('/').last}") | ||
# Sonatype Nexus / Artifactory JFrog format | ||
resolved_url.split("/#{name}/-/#{name.split('/').last}").first | ||
elsif (cred_url = url_for_relevant_cred) then cred_url | ||
else | ||
resolved_url.split("/")[0..2].join("/") | ||
end | ||
|
||
{ type: "registry", url: url } | ||
end | ||
|
||
def dependency_name | ||
url_base = if resolved_url.include?("/-/") | ||
resolved_url.split("/-/").first | ||
else | ||
resolved_url | ||
end | ||
|
||
url_base.split("/")[3..-1].join("/").gsub("%2F", "/") | ||
end | ||
|
||
private | ||
|
||
attr_reader :resolved_url, :credentials | ||
|
||
def url_for_relevant_cred | ||
resolved_url_host = URI(resolved_url).host | ||
|
||
credential_matching_url = | ||
credentials | ||
.select { |cred| cred["type"] == "npm_registry" } | ||
.sort_by { |cred| cred["registry"].length } | ||
.find do |details| | ||
next true if resolved_url_host == details["registry"] | ||
|
||
uri = if details["registry"]&.include?("://") | ||
URI(details["registry"]) | ||
else | ||
URI("https://#{details['registry']}") | ||
end | ||
resolved_url_host == uri.host && resolved_url.include?(details["registry"]) | ||
end | ||
|
||
return unless credential_matching_url | ||
|
||
# Trim the resolved URL so that it ends at the same point as the | ||
# credential registry | ||
reg = credential_matching_url["registry"] | ||
resolved_url.gsub(/#{Regexp.quote(reg)}.*/, "") + reg | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
npm_and_yarn/spec/fixtures/projects/pnpm/nonexistent_locked_dependency/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "margins", | ||
"version": "0.0.1", | ||
"type": "module", | ||
"dependencies": { | ||
"@googleapis/youtube": "^10.1.0", | ||
"@tiptap-pro/extension-mathematics": "latest" | ||
} | ||
} |
Oops, something went wrong.