dependabot-maven 0.186.1 → 0.189.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: 2e1a2783c11d5d8604b71ca5b61ae195a9301643612473feba9f36c088d791b1
4
- data.tar.gz: 81b870922031db076a242e4f12b51985c4ecc2357cf87fa7c63ab1ae8635acea
3
+ metadata.gz: bb809a76fc89757535851f229a3da24216246e51202de85b11bf2adf468de0c9
4
+ data.tar.gz: 187f16b34d5207f8c3f47cb99f5e37a2fe9f10ad93574a78f772d2b3cf48043b
5
5
  SHA512:
6
- metadata.gz: c9312ba524cde77bab1d5993857371d10cbd4f1fb3a92eee035577655b70e6bcf496ea5f19003ff87e5e4983c418ec880c9a58bfeefaac2aa55ae97e3efb9102
7
- data.tar.gz: 51fbad4d09cfd030c51e31bac82788c4d1126e7ff0988a6093b6de1378bdd68ec85884c478fe0a7c72228a2bc1d61495966a4597ecdcebb003cd1dff1a874676
6
+ metadata.gz: 94ae994c766edc2b666da5b85bb0e6a91103a36b7682b42c7a0215d3afe0727737a8a6aefe57f9da866f4f25feb4657929ad86ea71760df2372a7fe86b36ce36
7
+ data.tar.gz: dbf67e08c040fe66d7f8adb2f8216347aa4f4c940c9fe81647b5c70d1f84991b08c23066161484b7fe107d01296b56d6474ac534e533d099181bf1ebc04c936a
@@ -4,7 +4,6 @@ require "nokogiri"
4
4
 
5
5
  require "dependabot/dependency_file"
6
6
  require "dependabot/maven/file_parser"
7
- require "dependabot/shared_helpers"
8
7
 
9
8
  # For documentation, see:
10
9
  # - http://maven.apache.org/guides/introduction/introduction-to-the-pom.html
@@ -128,11 +127,7 @@ module Dependabot
128
127
  url = remote_pom_url(group_id, artifact_id, version, base_url)
129
128
 
130
129
  @maven_responses ||= {}
131
- @maven_responses[url] ||= Excon.get(
132
- url,
133
- idempotent: true,
134
- **SharedHelpers.excon_defaults
135
- )
130
+ @maven_responses[url] ||= RegistryClient.get(url: url)
136
131
  next unless @maven_responses[url].status == 200
137
132
  next unless pom?(@maven_responses[url].body)
138
133
 
@@ -4,7 +4,6 @@ require "nokogiri"
4
4
 
5
5
  require "dependabot/dependency_file"
6
6
  require "dependabot/maven/file_parser"
7
- require "dependabot/shared_helpers"
8
7
  require "dependabot/errors"
9
8
 
10
9
  # For documentation, see:
@@ -110,10 +109,13 @@ module Dependabot
110
109
  url = remote_pom_url(group_id, artifact_id, version, base_url)
111
110
 
112
111
  @maven_responses ||= {}
113
- @maven_responses[url] ||= Excon.get(
114
- url,
115
- idempotent: true,
116
- **SharedHelpers.excon_defaults
112
+ @maven_responses[url] ||= RegistryClient.get(
113
+ url: url,
114
+ # We attempt to find dependencies in private repos before failing over to the CENTRAL_REPO_URL,
115
+ # but this can burn a lot of a job's time against slow servers due to our `read_timeout` being 20 seconds.
116
+ #
117
+ # In order to avoid the overall job timing out, we only make one retry attempt
118
+ options: { retry_limit: 1 }
117
119
  )
118
120
  next unless @maven_responses[url].status == 200
119
121
  next unless pom?(@maven_responses[url].body)
@@ -104,12 +104,9 @@ module Dependabot
104
104
  def dependency_pom_file
105
105
  return @dependency_pom_file unless @dependency_pom_file.nil?
106
106
 
107
- response = Excon.get(
108
- "#{maven_repo_dependency_url}/"\
109
- "#{dependency.version}/"\
110
- "#{dependency_artifact_id}-#{dependency.version}.pom",
111
- idempotent: true,
112
- **SharedHelpers.excon_defaults(headers: auth_headers)
107
+ response = RegistryClient.get(
108
+ url: "#{maven_repo_dependency_url}/#{dependency.version}/#{dependency_artifact_id}-#{dependency.version}.pom",
109
+ headers: auth_headers
113
110
  )
114
111
 
115
112
  @dependency_pom_file = Nokogiri::XML(response.body)
@@ -137,10 +134,9 @@ module Dependabot
137
134
  "#{version}/"\
138
135
  "#{artifact_id}-#{version}.pom"
139
136
 
140
- response = Excon.get(
141
- substitute_properties_in_source_url(url, pom),
142
- idempotent: true,
143
- **SharedHelpers.excon_defaults(headers: auth_headers)
137
+ response = RegistryClient.get(
138
+ url: substitute_properties_in_source_url(url, pom),
139
+ headers: auth_headers
144
140
  )
145
141
 
146
142
  Nokogiri::XML(response.body)
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dependabot/shared_helpers"
4
+
5
+ # This class provides a thin wrapper around our normal usage of Excon as a simple HTTP client in order to
6
+ # provide some minor caching functionality.
7
+ #
8
+ # This is not used to support full response caching currently, we just use it to ensure we detect unreachable
9
+ # hosts and fast-fail on any subsequent requests to them to avoid excessive use of retries and connect- or
10
+ # read-timeouts as Maven jobs tend to be sensitive to exceeding our overall 45 minute timeout.
11
+ module Dependabot
12
+ module Maven
13
+ class RegistryClient
14
+ @cached_errors = {}
15
+
16
+ def self.get(url:, headers: {}, options: {})
17
+ raise cached_error_for(url) if cached_error_for(url)
18
+
19
+ Excon.get(
20
+ url,
21
+ idempotent: true,
22
+ **SharedHelpers.excon_defaults({ headers: headers }.merge(options))
23
+ )
24
+ rescue Excon::Error::Timeout => e
25
+ cache_error(url, e)
26
+ raise e
27
+ end
28
+
29
+ def self.head(url:, headers: {}, options: {})
30
+ raise cached_error_for(url) if cached_error_for(url)
31
+
32
+ Excon.head(
33
+ url,
34
+ idempotent: true,
35
+ **SharedHelpers.excon_defaults({ headers: headers }.merge(options))
36
+ )
37
+ rescue Excon::Error::Timeout => e
38
+ cache_error(url, e)
39
+ raise e
40
+ end
41
+
42
+ def self.clear_cache!
43
+ @cached_errors = {}
44
+ end
45
+
46
+ private_class_method def self.cache_error(url, error)
47
+ host = URI(url).host
48
+ @cached_errors[host] = error
49
+ end
50
+
51
+ private_class_method def self.cached_error_for(url)
52
+ host = URI(url).host
53
+ @cached_errors.fetch(host, nil)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -23,8 +23,9 @@ module Dependabot
23
23
 
24
24
  def update_possible?
25
25
  return false unless target_version
26
+ return @update_possible if defined?(@update_possible)
26
27
 
27
- @update_possible ||=
28
+ @update_possible =
28
29
  dependencies_using_property.all? do |dep|
29
30
  next false if includes_property_reference?(updated_version(dep))
30
31
 
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "nokogiri"
4
- require "dependabot/shared_helpers"
5
4
  require "dependabot/update_checkers/version_filters"
6
5
  require "dependabot/maven/file_parser/repositories_finder"
7
6
  require "dependabot/maven/update_checker"
@@ -25,6 +24,7 @@ module Dependabot
25
24
  @raise_on_ignored = raise_on_ignored
26
25
  @security_advisories = security_advisories
27
26
  @forbidden_urls = []
27
+ @dependency_metadata = {}
28
28
  end
29
29
 
30
30
  def latest_version_details
@@ -138,10 +138,9 @@ module Dependabot
138
138
  @released_check[version] =
139
139
  repositories.any? do |repository_details|
140
140
  url = repository_details.fetch("url")
141
- response = Excon.head(
142
- dependency_files_url(url, version),
143
- idempotent: true,
144
- **SharedHelpers.excon_defaults(headers: repository_details.fetch("auth_headers"))
141
+ response = RegistryClient.head(
142
+ url: dependency_files_url(url, version),
143
+ headers: repository_details.fetch("auth_headers")
145
144
  )
146
145
 
147
146
  response.status < 400
@@ -154,25 +153,27 @@ module Dependabot
154
153
  end
155
154
 
156
155
  def dependency_metadata(repository_details)
157
- @dependency_metadata ||= {}
158
- @dependency_metadata[repository_details.hash] ||=
159
- begin
160
- response = Excon.get(
161
- dependency_metadata_url(repository_details.fetch("url")),
162
- idempotent: true,
163
- **Dependabot::SharedHelpers.excon_defaults(headers: repository_details.fetch("auth_headers"))
164
- )
165
- check_response(response, repository_details.fetch("url"))
156
+ repository_key = repository_details.hash
157
+ return @dependency_metadata[repository_key] if @dependency_metadata.key?(repository_key)
166
158
 
167
- Nokogiri::XML(response.body)
168
- rescue URI::InvalidURIError
169
- Nokogiri::XML("")
170
- rescue Excon::Error::Socket, Excon::Error::Timeout,
171
- Excon::Error::TooManyRedirects
172
- raise if central_repo_urls.include?(repository_details["url"])
159
+ @dependency_metadata[repository_key] = fetch_dependency_metadata(repository_details)
160
+ end
173
161
 
174
- Nokogiri::XML("")
175
- end
162
+ def fetch_dependency_metadata(repository_details)
163
+ response = RegistryClient.get(
164
+ url: dependency_metadata_url(repository_details.fetch("url")),
165
+ headers: repository_details.fetch("auth_headers")
166
+ )
167
+ check_response(response, repository_details.fetch("url"))
168
+
169
+ Nokogiri::XML(response.body)
170
+ rescue URI::InvalidURIError
171
+ Nokogiri::XML("")
172
+ rescue Excon::Error::Socket, Excon::Error::Timeout,
173
+ Excon::Error::TooManyRedirects
174
+ raise if central_repo_urls.include?(repository_details["url"])
175
+
176
+ Nokogiri::XML("")
176
177
  end
177
178
 
178
179
  def check_response(response, repository_url)
@@ -184,7 +185,7 @@ module Dependabot
184
185
  end
185
186
 
186
187
  def repositories
187
- return @repositories if @repositories
188
+ return @repositories if defined?(@repositories)
188
189
 
189
190
  details = pom_repository_details + credentials_repository_details
190
191
 
@@ -9,6 +9,7 @@ require "dependabot/maven/file_updater"
9
9
  require "dependabot/maven/metadata_finder"
10
10
  require "dependabot/maven/requirement"
11
11
  require "dependabot/maven/version"
12
+ require "dependabot/maven/registry_client"
12
13
 
13
14
  require "dependabot/pull_request_creator/labeler"
14
15
  Dependabot::PullRequestCreator::Labeler.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-maven
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.186.1
4
+ version: 0.189.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-10 00:00:00.000000000 Z
11
+ date: 2022-05-17 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.186.1
19
+ version: 0.189.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.186.1
26
+ version: 0.189.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: debase
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.28.2
131
+ version: 1.29.1
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.28.2
138
+ version: 1.29.1
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: ruby-debug-ide
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -236,6 +236,7 @@ files:
236
236
  - lib/dependabot/maven/file_updater/declaration_finder.rb
237
237
  - lib/dependabot/maven/file_updater/property_value_updater.rb
238
238
  - lib/dependabot/maven/metadata_finder.rb
239
+ - lib/dependabot/maven/registry_client.rb
239
240
  - lib/dependabot/maven/requirement.rb
240
241
  - lib/dependabot/maven/update_checker.rb
241
242
  - lib/dependabot/maven/update_checker/property_updater.rb