dependabot-gradle 0.140.3 → 0.143.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: e0707f978b7368a4b6ef86ee54be8615b8a3c09ab5fc7381965f8257f63c6ea6
4
- data.tar.gz: 80586d572a78a4f0966561c5c8cda816973f0a7b0ca211370fc9b52d9c058f44
3
+ metadata.gz: db6059748f0c1f692f360fda9e80311ccafc6fd84ad878183c4c4316f48a4d7e
4
+ data.tar.gz: 1b5ea811c9ef709285f5dbde439aa4b913cec9af04c1bf15297f5079b89a47ce
5
5
  SHA512:
6
- metadata.gz: 0c470e94a9f37bf739eff87b8a50c3b3fdfbfb23d0d85bad6a40e1d82a29de68482818a7d05165955950a62e7c03cfe21d00da56003a7f4782c31f089aab3f7c
7
- data.tar.gz: 0154d1d87165e101ade7d54c19a4a1ba08107857cd3e3cc5b550f838e43f6aef7da4ed5e6d04ffb66e63e0f5113e04075c29ae0d4e45d8a3d6ce09fffe084a3e
6
+ metadata.gz: cf4462b6930947c632b12aeb6b8fd06a7906e2c4afc88ef6c5ae56cd2cd2ea82c6572723242f487f8febc26a7698561697a7f064ebbefdd1395fd185d23b771b
7
+ data.tar.gz: ae774d6872823ad22a079104c94c8f8fe4d2fde67c446e040d82a11004d85138977ed62afa10090ea08a8670342307a717c09410a26797eb26b752e2ce3b8c73
@@ -5,6 +5,7 @@ require "dependabot/metadata_finders"
5
5
  require "dependabot/metadata_finders/base"
6
6
  require "dependabot/file_fetchers/base"
7
7
  require "dependabot/gradle/file_parser/repositories_finder"
8
+ require "dependabot/maven/utils/auth_headers_finder"
8
9
 
9
10
  module Dependabot
10
11
  module Gradle
@@ -112,7 +113,7 @@ module Dependabot
112
113
  "#{dependency.version}/"\
113
114
  "#{artifact_id}-#{dependency.version}.pom",
114
115
  idempotent: true,
115
- **SharedHelpers.excon_defaults(headers: auth_details)
116
+ **SharedHelpers.excon_defaults(headers: auth_headers)
116
117
  )
117
118
 
118
119
  @dependency_pom_file = Nokogiri::XML(response.body)
@@ -135,7 +136,7 @@ module Dependabot
135
136
  "#{version}/"\
136
137
  "#{artifact_id}-#{version}.pom",
137
138
  idempotent: true,
138
- **SharedHelpers.excon_defaults(headers: auth_details)
139
+ **SharedHelpers.excon_defaults(headers: auth_headers)
139
140
  )
140
141
 
141
142
  Nokogiri::XML(response.body)
@@ -170,21 +171,8 @@ module Dependabot
170
171
  plugin? && dependency.requirements.any? { |r| r.fetch(:groups).include? "kotlin" }
171
172
  end
172
173
 
173
- def auth_details
174
- cred =
175
- credentials.select { |c| c["type"] == "maven_repository" }.
176
- find do |c|
177
- cred_url = c.fetch("url").gsub(%r{/+$}, "")
178
- next false unless cred_url == maven_repo_url
179
-
180
- c.fetch("username", nil)
181
- end
182
-
183
- return {} unless cred
184
-
185
- token = cred.fetch("username") + ":" + cred.fetch("password")
186
- encoded_token = Base64.encode64(token).delete("\n")
187
- { "Authorization" => "Basic #{encoded_token}" }
174
+ def auth_headers
175
+ @auth_headers ||= Dependabot::Maven::Utils::AuthHeadersFinder.new(credentials).auth_headers(maven_repo_url)
188
176
  end
189
177
  end
190
178
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "dependabot/utils"
4
+ require "dependabot/maven/requirement"
4
5
  require "dependabot/gradle/version"
5
6
 
6
7
  module Dependabot
@@ -32,7 +33,14 @@ module Dependabot
32
33
 
33
34
  def initialize(*requirements)
34
35
  requirements = requirements.flatten.flat_map do |req_string|
35
- convert_java_constraint_to_ruby_constraint(req_string)
36
+ # NOTE: Support ruby-style version requirements that are created from
37
+ # PR ignore conditions
38
+ version_reqs = req_string.split(",").map(&:strip)
39
+ if version_reqs.all? { |s| Gem::Requirement::PATTERN.match?(s) }
40
+ version_reqs
41
+ else
42
+ convert_java_constraint_to_ruby_constraint(req_string)
43
+ end
36
44
  end
37
45
 
38
46
  super(requirements)
@@ -46,7 +54,9 @@ module Dependabot
46
54
  private
47
55
 
48
56
  def self.split_java_requirement(req_string)
49
- req_string.split(/(?<=\]|\)),/).flat_map do |str|
57
+ return [req_string] unless req_string.match?(Maven::Requirement::OR_SYNTAX)
58
+
59
+ req_string.split(Maven::Requirement::OR_SYNTAX).flat_map do |str|
50
60
  next str if str.start_with?("(", "[")
51
61
 
52
62
  exacts, *rest = str.split(/,(?=\[|\()/)
@@ -6,6 +6,7 @@ require "dependabot/gradle/file_parser/repositories_finder"
6
6
  require "dependabot/gradle/update_checker"
7
7
  require "dependabot/gradle/version"
8
8
  require "dependabot/gradle/requirement"
9
+ require "dependabot/maven/utils/auth_headers_finder"
9
10
 
10
11
  module Dependabot
11
12
  module Gradle
@@ -16,8 +17,6 @@ module Dependabot
16
17
  KOTLIN_PLUGIN_REPO_PREFIX = "org.jetbrains.kotlin"
17
18
  TYPE_SUFFICES = %w(jre android java).freeze
18
19
 
19
- GRADLE_RANGE_REGEX = /[\(\[].*,.*[\)\]]/.freeze
20
-
21
20
  def initialize(dependency:, dependency_files:, credentials:,
22
21
  ignored_versions:, raise_on_ignored: false,
23
22
  security_advisories:)
@@ -98,10 +97,10 @@ module Dependabot
98
97
  filtered = possible_versions
99
98
 
100
99
  ignored_versions.each do |req|
101
- ignore_req = Gradle::Requirement.new(parse_requirement_string(req))
100
+ ignore_requirements = Gradle::Requirement.requirements_array(req)
102
101
  filtered =
103
102
  filtered.
104
- reject { |v| ignore_req.satisfied_by?(v.fetch(:version)) }
103
+ reject { |v| ignore_requirements.any? { |r| r.satisfied_by?(v.fetch(:version)) } }
105
104
  end
106
105
 
107
106
  raise AllVersionsIgnored if @raise_on_ignored && filtered.empty? && possible_versions.any?
@@ -127,12 +126,6 @@ module Dependabot
127
126
  end
128
127
  end
129
128
 
130
- def parse_requirement_string(string)
131
- return string if string.match?(GRADLE_RANGE_REGEX)
132
-
133
- string.split(",").map(&:strip)
134
- end
135
-
136
129
  def wants_prerelease?
137
130
  return false unless dependency.version
138
131
  return false unless version_class.correct?(dependency.version)
@@ -184,10 +177,8 @@ module Dependabot
184
177
  begin
185
178
  response = Excon.get(
186
179
  dependency_metadata_url(repository_details.fetch("url")),
187
- user: repository_details.fetch("username"),
188
- password: repository_details.fetch("password"),
189
180
  idempotent: true,
190
- **SharedHelpers.excon_defaults
181
+ **Dependabot::SharedHelpers.excon_defaults(headers: repository_details.fetch("auth_headers"))
191
182
  )
192
183
  check_response(response, repository_details.fetch("url"))
193
184
  Nokogiri::XML(response.body)
@@ -226,10 +217,10 @@ module Dependabot
226
217
 
227
218
  @repositories =
228
219
  details.reject do |repo|
229
- next if repo["password"]
220
+ next if repo["auth_headers"]
230
221
 
231
- # Reject this entry if an identical one with a password exists
232
- details.any? { |r| r["url"] == repo["url"] && r["password"] }
222
+ # Reject this entry if an identical one with non-empty auth_headers exists
223
+ details.any? { |r| r["url"] == repo["url"] && r["auth_headers"] != {} }
233
224
  end
234
225
  end
235
226
 
@@ -239,8 +230,7 @@ module Dependabot
239
230
  map do |cred|
240
231
  {
241
232
  "url" => cred.fetch("url").gsub(%r{/+$}, ""),
242
- "username" => cred.fetch("username", nil),
243
- "password" => cred.fetch("password", nil)
233
+ "auth_headers" => auth_headers(cred.fetch("url").gsub(%r{/+$}, ""))
244
234
  }
245
235
  end
246
236
  end
@@ -258,7 +248,7 @@ module Dependabot
258
248
  target_dependency_file: target_file
259
249
  ).repository_urls.
260
250
  map do |url|
261
- { "url" => url, "username" => nil, "password" => nil }
251
+ { "url" => url, "auth_headers" => {} }
262
252
  end
263
253
  end.uniq
264
254
  end
@@ -266,8 +256,7 @@ module Dependabot
266
256
  def plugin_repository_details
267
257
  [{
268
258
  "url" => GRADLE_PLUGINS_REPO,
269
- "username" => nil,
270
- "password" => nil
259
+ "auth_headers" => {}
271
260
  }] + dependency_repository_details
272
261
  end
273
262
 
@@ -333,6 +322,14 @@ module Dependabot
333
322
  def version_class
334
323
  Gradle::Version
335
324
  end
325
+
326
+ def auth_headers_finder
327
+ @auth_headers_finder ||= Dependabot::Maven::Utils::AuthHeadersFinder.new(credentials)
328
+ end
329
+
330
+ def auth_headers(maven_repo_url)
331
+ auth_headers_finder.auth_headers(maven_repo_url)
332
+ end
336
333
  end
337
334
  end
338
335
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-gradle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.140.3
4
+ version: 0.143.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-12 00:00:00.000000000 Z
11
+ date: 2021-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.140.3
19
+ version: 0.143.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.140.3
26
+ version: 0.143.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: dependabot-maven
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.143.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.143.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: byebug
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +114,14 @@ dependencies:
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: 1.12.0
117
+ version: 1.13.0
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: 1.12.0
124
+ version: 1.13.0
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: simplecov
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -220,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
234
  - !ruby/object:Gem::Version
221
235
  version: 2.5.0
222
236
  requirements: []
223
- rubygems_version: 3.2.3
237
+ rubygems_version: 3.2.15
224
238
  signing_key:
225
239
  specification_version: 4
226
240
  summary: Gradle support for dependabot