dependabot-npm_and_yarn 0.268.0 → 0.270.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 473cf091eca02d2d3e0ff9920708779183b7a9a9dba2771c35ffe602eda18003
4
- data.tar.gz: 3ff951a1e1970c6818b615b5f10b78950e5cc53c01b3a2b9540a28f3451ac294
3
+ metadata.gz: b2276d76c9fe0718302cab8ccf1044b0a4ff7f20c84e29d34805e7defed16c78
4
+ data.tar.gz: 4e08e01d7b52645d0c5d3283dc509fe9a06ad2fde18bdaec55d8ac64ec89648f
5
5
  SHA512:
6
- metadata.gz: 73a7da3b2062a4adaa70d33616698d418bcda9684e8cf301279bac6756537079136872cc68d6623af7f1ea8bd09197d7ac98edd287da6aafef63f1f6f25243c1
7
- data.tar.gz: 68e3d2e1a3b50ccad6359b961a1e3093d6095d08fb8e79175aa83025c57716f080ca03dd5aea9e4f1dead654fa881cf4f20698971150ac5b361a25efbaa74b04
6
+ metadata.gz: 4942e5053f375513c9c5e0666848fb05a1abacd4bd276b7642f3aa08282bcd437e46a7334174a34117d81f23dbaa57b78a9e4116366afbb4c64deeaf494ec2c8
7
+ data.tar.gz: 47ac31be39537d7f54b1d0683ddf51db345e6b05fa6bab37dd1addceb611387ae5a82c405ecb555268f34ec330736eff776fb04150fe337663d1e28508c50291
@@ -166,7 +166,7 @@ module Dependabot
166
166
 
167
167
  sig { override.void }
168
168
  def check_required_files
169
- raise "No package.json!" unless get_original_file("package.json")
169
+ raise DependencyFileNotFound.new(nil, "package.json not found.") unless get_original_file("package.json")
170
170
  end
171
171
 
172
172
  sig { params(requirement: String).returns(T::Boolean) }
@@ -72,7 +72,8 @@ module Dependabot
72
72
  -\sGET\shttps?://(?<source>[^/]+)/(?<package_req>[^/\s]+)}x
73
73
  MISSING_PACKAGE = %r{(?<package_req>[^/]+) - Not found}
74
74
  INVALID_PACKAGE = /Can't install (?<package_req>.*): Missing/
75
- SOCKET_HANG_UP = /request to (?<url>.*) failed, reason: socket hang up/
75
+ SOCKET_HANG_UP = /(?:request to )?(?<url>.*): socket hang up/
76
+ ESOCKETTIMEDOUT = /(?<url>.*): ESOCKETTIMEDOUT/
76
77
  UNABLE_TO_AUTH_NPMRC = /Unable to authenticate, need: Basic, Bearer/
77
78
  UNABLE_TO_AUTH_REGISTRY = /Unable to authenticate, need: *.*(Basic|BASIC) *.*realm="(?<url>.*)"/
78
79
  MISSING_AUTH_TOKEN = /401 Unauthorized - GET (?<url>.*) - authentication token not provided/
@@ -83,10 +84,12 @@ module Dependabot
83
84
  NESTED_ALIAS = /nested aliases not supported/
84
85
  PEER_DEPS_PATTERNS = T.let([/Cannot read properties of null/,
85
86
  /ERESOLVE overriding peer dependency/].freeze, T::Array[Regexp])
86
-
87
+ PREMATURE_CLOSE = /premature close/
88
+ EMPTY_OBJECT_ERROR = /Object for dependency "(?<package>.*)" is empty/
87
89
  ERROR_E401 = /code E401/
88
90
  ERROR_E403 = /code E403/
89
91
  ERROR_EAI_AGAIN = /request to (?<url>.*) failed, reason: getaddrinfo EAI_AGAIN/
92
+ PACKAGE_DISCOVERY_FAIL = /Couldn't find package "(?<pkg>.*)" *.* on the "(?<regis>.*)" registry./
90
93
 
91
94
  # TODO: look into fixing this in npm, seems like a bug in the git
92
95
  # downloader introduced in npm 7
@@ -513,7 +516,12 @@ module Dependabot
513
516
 
514
517
  # NOTE: This check was introduced in npm8/arborist
515
518
  if error_message.include?("must provide string spec")
516
- msg = "Error parsing your package.json manifest: the version requirement must be a string"
519
+ msg = "Error parsing your package.json manifest: the version requirement must be a string."
520
+ raise Dependabot::DependencyFileNotParseable, msg
521
+ end
522
+
523
+ if error_message.match?(PREMATURE_CLOSE)
524
+ msg = "Error parsing your package.json manifest"
517
525
  raise Dependabot::DependencyFileNotParseable, msg
518
526
  end
519
527
 
@@ -523,15 +531,21 @@ module Dependabot
523
531
  raise Dependabot::DependencyFileNotResolvable, msg
524
532
  end
525
533
 
526
- if (git_source = error_message.match(SOCKET_HANG_UP))
527
- msg = git_source.named_captures.fetch("url")
528
- raise Dependabot::PrivateSourceTimedOut, T.must(msg)
534
+ if (git_source = error_message.match(SOCKET_HANG_UP) || error_message.match(ESOCKETTIMEDOUT))
535
+ msg = sanitize_uri(git_source.named_captures.fetch("url"))
536
+ raise Dependabot::PrivateSourceTimedOut, msg
537
+ end
538
+
539
+ if (package = error_message.match(EMPTY_OBJECT_ERROR))
540
+ msg = "Error resolving package-lock.json file. " \
541
+ "Object for dependency \"#{package.named_captures.fetch('package')}\" is empty."
542
+ raise Dependabot::DependencyFileNotResolvable, msg
529
543
  end
530
544
 
531
545
  # Error handled when no authentication info ( _auth = user:pass )
532
546
  # is provided in config file (.npmrc) to access private registry
533
547
  if error_message.match?(UNABLE_TO_AUTH_NPMRC)
534
- msg = "check .npmrc config file"
548
+ msg = "check .npmrc config file."
535
549
  raise Dependabot::PrivateSourceAuthenticationFailure, msg
536
550
  end
537
551
 
@@ -553,7 +567,7 @@ module Dependabot
553
567
  end
554
568
 
555
569
  if (dep = error_message.match(EOVERRIDE))
556
- msg = "Override for #{dep.named_captures.fetch('deps')} conflicts with direct dependency"
570
+ msg = "Override for #{dep.named_captures.fetch('deps')} conflicts with direct dependency."
557
571
  raise Dependabot::DependencyFileNotResolvable, msg
558
572
  end
559
573
 
@@ -562,6 +576,8 @@ module Dependabot
562
576
  raise Dependabot::DependencyFileNotResolvable, msg
563
577
  end
564
578
 
579
+ raise Dependabot::DependencyFileNotResolvable, error_message if error_message.match(PACKAGE_DISCOVERY_FAIL)
580
+
565
581
  raise error
566
582
  end
567
583
  # rubocop:enable Metrics/AbcSize
@@ -1067,6 +1083,11 @@ module Dependabot
1067
1083
  )
1068
1084
  end
1069
1085
 
1086
+ sig { params(uri: T.nilable(String)).returns(String) }
1087
+ def sanitize_uri(uri)
1088
+ URI.decode_www_form_component(T.must(URI.extract(T.must(uri)).first))
1089
+ end
1090
+
1070
1091
  sig { returns(T::Hash[String, T.untyped]) }
1071
1092
  def parsed_package_json
1072
1093
  return {} unless package_json
@@ -45,6 +45,27 @@ module Dependabot
45
45
  MISSING_PACKAGE = /ERR_PNPM_FETCH_404[ [^:print:]]+GET (?<dependency_url>.*): (?:Not Found)? - 404/
46
46
  UNAUTHORIZED_PACKAGE = /ERR_PNPM_FETCH_401[ [^:print:]]+GET (?<dependency_url>.*): Unauthorized - 401/
47
47
 
48
+ # ERR_PNPM_FETCH ERROR CODES
49
+ ERR_PNPM_FETCH_401 = /ERR_PNPM_FETCH_401.*GET (?<dependency_url>.*): - 401/
50
+ ERR_PNPM_FETCH_403 = /ERR_PNPM_FETCH_403.*GET (?<dependency_url>.*): - 403/
51
+ ERR_PNPM_FETCH_500 = /ERR_PNPM_FETCH_500.*GET (?<dependency_url>.*): - 500/
52
+ ERR_PNPM_FETCH_502 = /ERR_PNPM_FETCH_502.*GET (?<dependency_url>.*): - 502/
53
+
54
+ # ERR_PNPM_UNSUPPORTED_ENGINE
55
+ ERR_PNPM_UNSUPPORTED_ENGINE = /ERR_PNPM_UNSUPPORTED_ENGINE/
56
+ PACAKGE_MANAGER = /Your (?<pkg_mgr>.*) version is incompatible with/
57
+ VERSION_REQUIREMENT = /Expected version: (?<supported_ver>.*)\nGot: (?<detected_ver>.*)\n/
58
+
59
+ ERR_PNPM_TARBALL_INTEGRITY = /ERR_PNPM_TARBALL_INTEGRITY/
60
+
61
+ ERR_PNPM_PATCH_NOT_APPLIED = /ERR_PNPM_PATCH_NOT_APPLIED/
62
+
63
+ # ERR_PNPM_UNSUPPORTED_PLATFORM
64
+ ERR_PNPM_UNSUPPORTED_PLATFORM = /ERR_PNPM_UNSUPPORTED_PLATFORM/
65
+ PLATFORM_PACAKGE_DEP = /Unsupported platform for (?<dep>.*)\: wanted/
66
+ PLATFORM_VERSION_REQUIREMENT = /wanted {(?<supported_ver>.*)} \(current: (?<detected_ver>.*)\)/
67
+ PLATFORM_PACAKGE_MANAGER = "pnpm"
68
+
48
69
  def run_pnpm_update(pnpm_lock:)
49
70
  SharedHelpers.in_a_temporary_repo_directory(base_dir, repo_contents_path) do
50
71
  File.write(".npmrc", npmrc_content(pnpm_lock))
@@ -88,6 +109,8 @@ module Dependabot
88
109
  ).parse
89
110
  end
90
111
 
112
+ # rubocop:disable Metrics/AbcSize
113
+ # rubocop:disable Metrics/PerceivedComplexity
91
114
  def handle_pnpm_lock_updater_error(error, pnpm_lock)
92
115
  error_message = error.message
93
116
 
@@ -107,16 +130,36 @@ module Dependabot
107
130
  raise Dependabot::GitDependenciesNotReachable, url
108
131
  end
109
132
 
110
- [FORBIDDEN_PACKAGE, MISSING_PACKAGE, UNAUTHORIZED_PACKAGE].each do |regexp|
133
+ [FORBIDDEN_PACKAGE, MISSING_PACKAGE, UNAUTHORIZED_PACKAGE, ERR_PNPM_FETCH_401,
134
+ ERR_PNPM_FETCH_403, ERR_PNPM_FETCH_500, ERR_PNPM_FETCH_502].each do |regexp|
111
135
  next unless error_message.match?(regexp)
112
136
 
113
137
  dependency_url = error_message.match(regexp).named_captures["dependency_url"]
138
+ raise_package_access_error(error_message, dependency_url, pnpm_lock)
139
+ end
140
+
141
+ # TO-DO : subclassifcation of ERR_PNPM_TARBALL_INTEGRITY errors
142
+ if error_message.match?(ERR_PNPM_TARBALL_INTEGRITY)
143
+ dependency_names = dependencies.map(&:name).join(", ")
114
144
 
115
- raise_package_access_error(dependency_url, pnpm_lock)
145
+ msg = "Error (ERR_PNPM_TARBALL_INTEGRITY) while resolving \"#{dependency_names}\"."
146
+ Dependabot.logger.warn(error_message)
147
+ raise Dependabot::DependencyFileNotResolvable, msg
148
+ end
149
+
150
+ raise_patch_dependency_error(error_message) if error_message.match?(ERR_PNPM_PATCH_NOT_APPLIED)
151
+
152
+ raise_unsupported_engine_error(error_message, pnpm_lock) if error_message.match?(ERR_PNPM_UNSUPPORTED_ENGINE)
153
+
154
+ if error_message.match?(ERR_PNPM_UNSUPPORTED_PLATFORM)
155
+ raise_unsupported_platform_error(error_message,
156
+ pnpm_lock)
116
157
  end
117
158
 
118
159
  raise
119
160
  end
161
+ # rubocop:enable Metrics/AbcSize
162
+ # rubocop:enable Metrics/PerceivedComplexity
120
163
 
121
164
  def raise_resolvability_error(error_message, pnpm_lock)
122
165
  dependency_names = dependencies.map(&:name).join(", ")
@@ -125,7 +168,28 @@ module Dependabot
125
168
  raise Dependabot::DependencyFileNotResolvable, msg
126
169
  end
127
170
 
128
- def raise_package_access_error(dependency_url, pnpm_lock)
171
+ def raise_patch_dependency_error(error_message)
172
+ dependency_names = dependencies.map(&:name).join(", ")
173
+ msg = "Error while updating \"#{dependency_names}\" in " \
174
+ "update group \"patchedDependencies\"."
175
+ Dependabot.logger.warn(error_message)
176
+ raise Dependabot::DependencyFileNotResolvable, msg
177
+ end
178
+
179
+ def raise_unsupported_engine_error(error_message, _pnpm_lock)
180
+ unless error_message.match(PACAKGE_MANAGER) &&
181
+ error_message.match(VERSION_REQUIREMENT)
182
+ return
183
+ end
184
+
185
+ package_manager = error_message.match(PACAKGE_MANAGER).named_captures["pkg_mgr"]
186
+ supported_version = error_message.match(VERSION_REQUIREMENT).named_captures["supported_ver"]
187
+ detected_version = error_message.match(VERSION_REQUIREMENT).named_captures["detected_ver"]
188
+
189
+ raise Dependabot::ToolVersionNotSupported.new(package_manager, supported_version, detected_version)
190
+ end
191
+
192
+ def raise_package_access_error(error_message, dependency_url, pnpm_lock)
129
193
  package_name = RegistryParser.new(resolved_url: dependency_url, credentials: credentials).dependency_name
130
194
  missing_dep = lockfile_dependencies(pnpm_lock)
131
195
  .find { |dep| dep.name == package_name }
@@ -136,7 +200,7 @@ module Dependabot
136
200
  credentials: credentials,
137
201
  npmrc_file: npmrc_file
138
202
  ).registry
139
-
203
+ Dependabot.logger.warn("Error while accessing #{reg}. Response (truncated) - #{error_message[0..500]}...")
140
204
  raise PrivateSourceAuthenticationFailure, reg
141
205
  end
142
206
 
@@ -148,6 +212,23 @@ module Dependabot
148
212
  end
149
213
  end
150
214
 
215
+ def raise_unsupported_platform_error(error_message, _pnpm_lock)
216
+ unless error_message.match(PLATFORM_PACAKGE_DEP) &&
217
+ error_message.match(PLATFORM_VERSION_REQUIREMENT)
218
+ return
219
+ end
220
+
221
+ supported_version = error_message.match(PLATFORM_VERSION_REQUIREMENT)
222
+ .named_captures["supported_ver"]
223
+ .then { sanitize_message(_1) }
224
+ detected_version = error_message.match(PLATFORM_VERSION_REQUIREMENT)
225
+ .named_captures["detected_ver"]
226
+ .then { sanitize_message(_1) }
227
+
228
+ Dependabot.logger.warn(error_message)
229
+ raise Dependabot::ToolVersionNotSupported.new(PLATFORM_PACAKGE_MANAGER, supported_version, detected_version)
230
+ end
231
+
151
232
  def npmrc_content(pnpm_lock)
152
233
  NpmrcBuilder.new(
153
234
  credentials: credentials,
@@ -176,6 +257,10 @@ module Dependabot
176
257
  def npmrc_file
177
258
  dependency_files.find { |f| f.name == ".npmrc" }
178
259
  end
260
+
261
+ def sanitize_message(message)
262
+ message.gsub(/"|\[|\]|\}|\{/, "")
263
+ end
179
264
  end
180
265
  end
181
266
  end
@@ -278,7 +278,8 @@ module Dependabot
278
278
  error_message.include?(DEPENDENCY_MATCH_NOT_FOUND)
279
279
 
280
280
  unless resolvable_before_update?(yarn_lock)
281
- error_handler.raise_resolvability_error(error_message, yarn_lock)
281
+ error_handler.raise_resolvability_error(error_message,
282
+ yarn_lock)
282
283
  end
283
284
 
284
285
  # Dependabot has probably messed something up with the update and we
@@ -632,7 +633,7 @@ module Dependabot
632
633
  ).void
633
634
  end
634
635
  def handle_group_patterns(error, usage_error_message, params) # rubocop:disable Metrics/PerceivedComplexity
635
- error_message = error.message
636
+ error_message = error.message.gsub(/\e\[\d+(;\d+)*m/, "")
636
637
  VALIDATION_GROUP_PATTERNS.each do |group|
637
638
  patterns = group[:patterns]
638
639
  matchfn = group[:matchfn]
@@ -644,8 +645,8 @@ module Dependabot
644
645
  message = usage_error_message.empty? ? error_message : usage_error_message
645
646
  if in_usage && pattern_in_message(patterns, usage_error_message)
646
647
  raise create_error(handler, message, error, params)
647
- elsif !in_usage && pattern_in_message(patterns, error.message)
648
- raise create_error(handler, error.message, error, params)
648
+ elsif !in_usage && pattern_in_message(patterns, error_message)
649
+ raise create_error(handler, error_message, error, params)
649
650
  end
650
651
 
651
652
  raise create_error(handler, message, error, params) if matchfn&.call(usage_error_message, error_message)
@@ -30,15 +30,26 @@ module Dependabot
30
30
  end
31
31
  end
32
32
 
33
- sig { override.returns(T::Array[Regexp]) }
34
- def self.updated_files_regex
35
- [
36
- /^package\.json$/,
37
- /^package-lock\.json$/,
38
- /^npm-shrinkwrap\.json$/,
39
- /^yarn\.lock$/,
40
- /^pnpm-lock\.yaml$/
41
- ]
33
+ sig { override.params(allowlist_enabled: T::Boolean).returns(T::Array[Regexp]) }
34
+ def self.updated_files_regex(allowlist_enabled = false)
35
+ if allowlist_enabled
36
+ [
37
+ %r{^(?:.*\/)?package\.json$},
38
+ %r{^(?:.*\/)?package-lock\.json$},
39
+ %r{^(?:.*\/)?npm-shrinkwrap\.json$},
40
+ %r{^(?:.*\/)?yarn\.lock$},
41
+ %r{^(?:.*\/)?pnpm-lock\.yaml$}
42
+ ]
43
+ else
44
+ # Old regex. After 100% rollout of the allowlist, this will be removed.
45
+ [
46
+ /^package\.json$/,
47
+ /^package-lock\.json$/,
48
+ /^npm-shrinkwrap\.json$/,
49
+ /^yarn\.lock$/,
50
+ /^pnpm-lock\.yaml$/
51
+ ]
52
+ end
42
53
  end
43
54
 
44
55
  sig { override.returns(T::Array[DependencyFile]) }
@@ -139,7 +150,7 @@ module Dependabot
139
150
 
140
151
  sig { override.void }
141
152
  def check_required_files
142
- raise "No package.json!" unless get_original_file("package.json")
153
+ raise DependencyFileNotFound.new(nil, "package.json not found.") unless get_original_file("package.json")
143
154
  end
144
155
 
145
156
  sig { params(updated_files: T::Array[DependencyFile]).returns(T::Hash[Symbol, T.untyped]) }
@@ -338,7 +338,22 @@ module Dependabot
338
338
  raise PrivateSourceAuthenticationFailure, dependency_registry
339
339
  end
340
340
 
341
+ # handles scenario when private registry returns a server error 5xx
342
+ if private_dependency_server_error?(npm_response)
343
+ msg = "Server error #{npm_response.status} returned while accessing registry" \
344
+ " #{dependency_registry}."
345
+ raise DependencyFileNotResolvable, msg
346
+ end
347
+
341
348
  status = npm_response.status
349
+
350
+ # handles issue when status 200 is returned from registry but with an invalid JSON object
351
+ if status.to_s.start_with?("2") && response_invalid_json?(npm_response)
352
+ msg = "Invalid JSON object returned from registry #{dependency_registry}."
353
+ Dependabot.logger.warn("#{msg} Response body (truncated) : #{npm_response.body[0..500]}...")
354
+ raise DependencyFileNotResolvable, msg
355
+ end
356
+
342
357
  return if status.to_s.start_with?("2")
343
358
 
344
359
  # Ignore 404s from the registry for updates where a lockfile doesn't
@@ -373,6 +388,23 @@ module Dependabot
373
388
  true
374
389
  end
375
390
 
391
+ def private_dependency_server_error?(npm_response)
392
+ if [500, 501, 502, 503].include?(npm_response.status)
393
+ Dependabot.logger.warn("#{dependency_registry} returned code #{npm_response.status} with " \
394
+ "body #{npm_response.body}.")
395
+ return true
396
+ end
397
+ false
398
+ end
399
+
400
+ def response_invalid_json?(npm_response)
401
+ result = JSON.parse(npm_response.body)
402
+ result.is_a?(Hash) || result.is_a?(Array)
403
+ false
404
+ rescue JSON::ParserError, TypeError
405
+ true
406
+ end
407
+
376
408
  def dependency_url
377
409
  registry_finder.dependency_url
378
410
  end
@@ -57,17 +57,29 @@ module Dependabot
57
57
  end
58
58
 
59
59
  def lowest_security_fix_version
60
+ # This will require a full unlock to update multiple top level ancestors.
61
+ return if vulnerability_audit["fix_available"] && vulnerability_audit["top_level_ancestors"].count > 1
62
+
60
63
  latest_version_finder.lowest_security_fix_version
61
64
  end
62
65
 
63
66
  def lowest_resolvable_security_fix_version
64
67
  raise "Dependency not vulnerable!" unless vulnerable?
65
- # NOTE: we currently don't resolve transitive/sub-dependencies as
68
+
69
+ # NOTE: Currently, we don't resolve transitive/sub-dependencies as
66
70
  # npm/yarn don't provide any control over updating to a specific
67
- # sub-dependency version
71
+ # sub-dependency version.
72
+
73
+ # Return nil for vulnerable transitive dependencies if there are conflicting dependencies.
74
+ # This helps catch errors in such cases.
75
+ return nil if !dependency.top_level? && conflicting_dependencies.any?
76
+
77
+ # For transitive dependencies without conflicts, return the latest resolvable transitive
78
+ # security fix version that does not require unlocking other dependencies.
68
79
  return latest_resolvable_transitive_security_fix_version_with_no_unlock unless dependency.top_level?
69
80
 
70
- # TODO: Might want to check resolvability here?
81
+ # For top-level dependencies, return the lowest security fix version.
82
+ # TODO: Consider checking resolvability here in the future.
71
83
  lowest_security_fix_version
72
84
  end
73
85
 
@@ -174,7 +186,7 @@ module Dependabot
174
186
  end
175
187
 
176
188
  def updated_dependencies_after_full_unlock
177
- return conflicting_updated_dependencies if !dependency.top_level? && security_advisories.any?
189
+ return conflicting_updated_dependencies if security_advisories.any? && vulnerability_audit["fix_available"]
178
190
 
179
191
  version_resolver.dependency_updates_from_full_unlock
180
192
  .map { |update_details| build_updated_dependency(update_details) }
@@ -56,6 +56,10 @@ module Dependabot
56
56
  # Used to check if error message contains timeout fetching package
57
57
  TIMEOUT_FETCHING_PACKAGE_REGEX = %r{(?<url>.+)/(?<package>[^/]+): ETIMEDOUT}
58
58
 
59
+ ESOCKETTIMEDOUT = /(?<package>.*?): ESOCKETTIMEDOUT/
60
+
61
+ SOCKET_HANG_UP = /(?<url>.*?): socket hang up/
62
+
59
63
  # Used to identify git unreachable error
60
64
  UNREACHABLE_GIT_CHECK_REGEX = /ls-remote --tags --heads (?<url>.*)/
61
65
 
@@ -79,6 +83,8 @@ module Dependabot
79
83
  FAILED_TO_RETRIEVE: %r{(?<package_req>@[\w-]+\/[\w-]+@\S+): The remote server failed to provide the requested resource} # rubocop:disable Layout/LineLength
80
84
  }.freeze, T::Hash[String, Regexp])
81
85
 
86
+ YN0082_PACKAGE_NOT_FOUND_REGEX = /YN0082:.*?(\S+@\S+): No candidates found/
87
+
82
88
  PACKAGE_NOT_FOUND2 = %r{/[^/]+: Not found}
83
89
  PACKAGE_NOT_FOUND2_PACKAGE_NAME_REGEX = %r{/(?<package_name>[^/]+): Not found}
84
90
  PACKAGE_NOT_FOUND2_PACKAGE_NAME_CAPTURE = "package_name"
@@ -102,6 +108,7 @@ module Dependabot
102
108
  # Used to identify if authentication failure error
103
109
  AUTHENTICATION_TOKEN_NOT_PROVIDED = "authentication token not provided"
104
110
  AUTHENTICATION_IS_NOT_CONFIGURED = "No authentication configured for request"
111
+ AUTHENTICATION_HEADER_NOT_PROVIDED = "Unauthenticated: request did not include an Authorization header."
105
112
 
106
113
  # Used to identify if error message is related to yarn workspaces
107
114
  DEPENDENCY_FILE_NOT_RESOLVABLE = "conflicts with direct dependency"
@@ -241,6 +248,18 @@ module Dependabot
241
248
  handler: lambda { |message, _error, _params|
242
249
  Dependabot::NetworkUnsafeHTTP.new(message)
243
250
  }
251
+ },
252
+ "YN0082" => {
253
+ message: "No candidates found",
254
+ handler: lambda { |message, _error, _params|
255
+ match_data = message.match(YN0082_PACKAGE_NOT_FOUND_REGEX)
256
+ if match_data
257
+ package_req = match_data[1]
258
+ Dependabot::DependencyNotFound.new("#{package_req} Detail: #{message}")
259
+ else
260
+ Dependabot::DependencyNotFound.new(message)
261
+ end
262
+ }
244
263
  }
245
264
  }.freeze, T::Hash[String, {
246
265
  message: T.any(String, NilClass),
@@ -303,7 +322,8 @@ module Dependabot
303
322
  matchfn: nil
304
323
  },
305
324
  {
306
- patterns: [AUTHENTICATION_TOKEN_NOT_PROVIDED, AUTHENTICATION_IS_NOT_CONFIGURED],
325
+ patterns: [AUTHENTICATION_TOKEN_NOT_PROVIDED, AUTHENTICATION_IS_NOT_CONFIGURED,
326
+ AUTHENTICATION_HEADER_NOT_PROVIDED],
307
327
  handler: lambda { |message, _error, _params|
308
328
  Dependabot::PrivateSourceAuthenticationFailure.new(message)
309
329
  },
@@ -345,7 +365,28 @@ module Dependabot
345
365
  },
346
366
  in_usage: false,
347
367
  matchfn: nil
368
+ },
369
+ {
370
+ patterns: [SOCKET_HANG_UP],
371
+ handler: lambda { |message, _error, _params|
372
+ url = message.match(SOCKET_HANG_UP).named_captures.fetch(URL_CAPTURE)
373
+
374
+ Dependabot::PrivateSourceTimedOut.new(url.gsub(HTTP_CHECK_REGEX, ""))
375
+ },
376
+ in_usage: false,
377
+ matchfn: nil
378
+ },
379
+ {
380
+ patterns: [ESOCKETTIMEDOUT],
381
+ handler: lambda { |message, _error, _params|
382
+ package_req = message.match(ESOCKETTIMEDOUT).named_captures.fetch("package")
383
+
384
+ Dependabot::PrivateSourceTimedOut.new(package_req.gsub(HTTP_CHECK_REGEX, ""))
385
+ },
386
+ in_usage: false,
387
+ matchfn: nil
348
388
  }
389
+
349
390
  ].freeze, T::Array[{
350
391
  patterns: T::Array[T.any(String, Regexp)],
351
392
  handler: ErrorHandler,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-npm_and_yarn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.268.0
4
+ version: 0.270.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-02 00:00:00.000000000 Z
11
+ date: 2024-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.268.0
19
+ version: 0.270.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.268.0
26
+ version: 0.270.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: debug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -345,7 +345,7 @@ licenses:
345
345
  - MIT
346
346
  metadata:
347
347
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
348
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.268.0
348
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.270.0
349
349
  post_install_message:
350
350
  rdoc_options: []
351
351
  require_paths: