dependabot-gradle 0.319.1 → 0.320.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/dependabot/gradle/file_parser/property_value_finder.rb +28 -19
- data/lib/dependabot/gradle/file_parser/repositories_finder.rb +62 -34
- data/lib/dependabot/gradle/file_parser.rb +197 -65
- data/lib/dependabot/gradle/file_updater/property_value_updater.rb +4 -7
- data/lib/dependabot/gradle/file_updater.rb +1 -1
- data/lib/dependabot/gradle/package/package_details_fetcher.rb +11 -13
- data/lib/dependabot/gradle/update_checker/requirements_updater.rb +2 -2
- data/lib/dependabot/gradle/update_checker/version_finder.rb +1 -1
- data/lib/dependabot/gradle/update_checker.rb +54 -14
- data/lib/dependabot/gradle/version.rb +56 -27
- metadata +6 -6
@@ -1,10 +1,11 @@
|
|
1
|
-
# typed:
|
1
|
+
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require "sorbet-runtime"
|
5
5
|
require "toml-rb"
|
6
6
|
|
7
7
|
require "dependabot/dependency"
|
8
|
+
require "dependabot/ecosystem"
|
8
9
|
require "dependabot/file_parsers"
|
9
10
|
require "dependabot/file_parsers/base"
|
10
11
|
require "dependabot/shared_helpers"
|
@@ -20,30 +21,34 @@ require "dependabot/gradle/package_manager"
|
|
20
21
|
# - https://docs.gradle.org/current/userguide/plugins.html
|
21
22
|
module Dependabot
|
22
23
|
module Gradle
|
23
|
-
class FileParser < Dependabot::FileParsers::Base
|
24
|
+
class FileParser < Dependabot::FileParsers::Base # rubocop:disable Metrics/ClassLength
|
24
25
|
extend T::Sig
|
25
26
|
|
26
27
|
require "dependabot/file_parsers/base/dependency_set"
|
27
28
|
require_relative "file_parser/property_value_finder"
|
28
29
|
|
29
|
-
SUPPORTED_BUILD_FILE_NAMES = %w(build.gradle build.gradle.kts settings.gradle settings.gradle.kts).freeze
|
30
|
+
SUPPORTED_BUILD_FILE_NAMES = T.let(%w(build.gradle build.gradle.kts settings.gradle settings.gradle.kts).freeze,
|
31
|
+
T::Array[String])
|
30
32
|
|
31
|
-
PROPERTY_REGEX =
|
33
|
+
PROPERTY_REGEX = T.let(
|
32
34
|
/
|
33
35
|
(?:\$\{property\((?<property_name>[^:\s]*?)\)\})|
|
34
36
|
(?:\$\{(?<property_name>[^:\s]*?)\})|
|
35
37
|
(?:\$(?<property_name>[^:\s"']*))
|
36
|
-
/x
|
38
|
+
/x,
|
39
|
+
Regexp
|
40
|
+
)
|
37
41
|
|
38
|
-
PART = %r{[^\s,@'":/\\]+}
|
39
|
-
VSN_PART = %r{[^\s,'":/\\]+}
|
40
|
-
DEPENDENCY_DECLARATION_REGEX = /(?:\(|\s)\s*['"](?<declaration>#{PART}:#{PART}:#{VSN_PART})['"]/
|
42
|
+
PART = T.let(%r{[^\s,@'":/\\]+}, Regexp)
|
43
|
+
VSN_PART = T.let(%r{[^\s,'":/\\]+}, Regexp)
|
44
|
+
DEPENDENCY_DECLARATION_REGEX = T.let(/(?:\(|\s)\s*['"](?<declaration>#{PART}:#{PART}:#{VSN_PART})['"]/o, Regexp)
|
41
45
|
|
42
|
-
DEPENDENCY_SET_DECLARATION_REGEX = /(?:^|\s)dependencySet\((?<arguments>[^\)]+)\)\s*\{
|
43
|
-
DEPENDENCY_SET_ENTRY_REGEX = /entry\s+['"](?<name>#{PART})['"]/
|
44
|
-
PLUGIN_BLOCK_DECLARATION_REGEX = /(?:^|\s)plugins\s*\{
|
45
|
-
PLUGIN_ID_REGEX = /['"](?<id>#{PART})['"]/
|
46
|
+
DEPENDENCY_SET_DECLARATION_REGEX = T.let(/(?:^|\s)dependencySet\((?<arguments>[^\)]+)\)\s*\{/, Regexp)
|
47
|
+
DEPENDENCY_SET_ENTRY_REGEX = T.let(/entry\s+['"](?<name>#{PART})['"]/o, Regexp)
|
48
|
+
PLUGIN_BLOCK_DECLARATION_REGEX = T.let(/(?:^|\s)plugins\s*\{/, Regexp)
|
49
|
+
PLUGIN_ID_REGEX = T.let(/['"](?<id>#{PART})['"]/o, Regexp)
|
46
50
|
|
51
|
+
sig { override.returns(T::Array[Dependabot::Dependency]) }
|
47
52
|
def parse
|
48
53
|
dependency_set = DependencySet.new
|
49
54
|
buildfiles.each do |buildfile|
|
@@ -60,14 +65,21 @@ module Dependabot
|
|
60
65
|
end
|
61
66
|
end
|
62
67
|
|
68
|
+
sig { params(buildfile: T.nilable(Dependabot::DependencyFile)).returns(T::Array[String]) }
|
63
69
|
def self.find_include_names(buildfile)
|
64
70
|
return [] unless buildfile
|
65
71
|
|
66
|
-
buildfile.content
|
67
|
-
|
68
|
-
|
72
|
+
T.must(buildfile.content)
|
73
|
+
.scan(/apply(\(| )\s*from(\s+=|:)\s+['"]([^'"]+)['"]/)
|
74
|
+
.map { |match| T.must(match[2]) }
|
69
75
|
end
|
70
76
|
|
77
|
+
sig do
|
78
|
+
params(
|
79
|
+
buildfile: Dependabot::DependencyFile,
|
80
|
+
dependency_files: T::Array[Dependabot::DependencyFile]
|
81
|
+
).returns(T::Array[Dependabot::DependencyFile])
|
82
|
+
end
|
71
83
|
def self.find_includes(buildfile, dependency_files)
|
72
84
|
FileParser.find_include_names(buildfile)
|
73
85
|
.filter_map { |f| dependency_files.find { |bf| bf.name == f } }
|
@@ -102,6 +114,7 @@ module Dependabot
|
|
102
114
|
end, T.nilable(Dependabot::Gradle::Language))
|
103
115
|
end
|
104
116
|
|
117
|
+
sig { params(toml_file: Dependabot::DependencyFile).returns(DependencySet) }
|
105
118
|
def version_catalog_dependencies(toml_file)
|
106
119
|
dependency_set = DependencySet.new
|
107
120
|
parsed_toml_file = parsed_toml_file(toml_file)
|
@@ -110,27 +123,67 @@ module Dependabot
|
|
110
123
|
dependency_set
|
111
124
|
end
|
112
125
|
|
126
|
+
sig do
|
127
|
+
params(
|
128
|
+
parsed_toml_file: T::Hash[String, T.untyped],
|
129
|
+
toml_file: Dependabot::DependencyFile
|
130
|
+
).returns(DependencySet)
|
131
|
+
end
|
113
132
|
def version_catalog_library_dependencies(parsed_toml_file, toml_file)
|
114
|
-
dependencies_for_declarations(
|
133
|
+
dependencies_for_declarations(
|
134
|
+
T.cast(parsed_toml_file["libraries"], T.nilable(T::Hash[String, T.any(String, T::Hash[String, String])])),
|
135
|
+
toml_file,
|
136
|
+
:details_for_library_dependency
|
137
|
+
)
|
115
138
|
end
|
116
139
|
|
140
|
+
sig do
|
141
|
+
params(
|
142
|
+
parsed_toml_file: T::Hash[String, T.untyped],
|
143
|
+
toml_file: Dependabot::DependencyFile
|
144
|
+
).returns(DependencySet)
|
145
|
+
end
|
117
146
|
def version_catalog_plugin_dependencies(parsed_toml_file, toml_file)
|
118
|
-
dependencies_for_declarations(
|
147
|
+
dependencies_for_declarations(
|
148
|
+
T.cast(parsed_toml_file["plugins"], T.nilable(T::Hash[String, T.any(String, T::Hash[String, String])])),
|
149
|
+
toml_file,
|
150
|
+
:details_for_plugin_dependency
|
151
|
+
)
|
119
152
|
end
|
120
153
|
|
154
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
155
|
+
sig do
|
156
|
+
params(
|
157
|
+
declarations: T.nilable(T::Hash[String, T.any(String, T::Hash[String, String])]),
|
158
|
+
toml_file: Dependabot::DependencyFile,
|
159
|
+
details_getter: Symbol
|
160
|
+
).returns(DependencySet)
|
161
|
+
end
|
121
162
|
def dependencies_for_declarations(declarations, toml_file, details_getter)
|
122
163
|
dependency_set = DependencySet.new
|
123
164
|
return dependency_set unless declarations
|
124
165
|
|
125
166
|
declarations.each do |_mod, declaration|
|
126
|
-
|
167
|
+
details = send(details_getter, declaration)
|
168
|
+
next unless details
|
169
|
+
|
170
|
+
group, name, version = T.cast(
|
171
|
+
details,
|
172
|
+
[String, String, T.any(String, T::Hash[String, String])]
|
173
|
+
)
|
127
174
|
|
128
175
|
# Only support basic version and reference formats for now,
|
129
176
|
# refrain from updating anything else as it's likely to be a very deliberate choice.
|
130
177
|
next unless Gradle::Version.correct?(version) || (version.is_a?(Hash) && version.key?("ref"))
|
131
178
|
|
132
|
-
|
133
|
-
|
179
|
+
if version.is_a?(Hash)
|
180
|
+
version_details = "$" + T.must(version["ref"])
|
181
|
+
elsif Gradle::Version.correct?(version)
|
182
|
+
version_details = version
|
183
|
+
else
|
184
|
+
raise ArgumentError, "Unexpected version format: #{version.inspect}"
|
185
|
+
end
|
186
|
+
details = T.let({ group: group, name: name, version: version_details }, T::Hash[Symbol, String])
|
134
187
|
dependency = dependency_from(details_hash: details, buildfile: toml_file)
|
135
188
|
next unless dependency
|
136
189
|
|
@@ -138,33 +191,58 @@ module Dependabot
|
|
138
191
|
end
|
139
192
|
dependency_set
|
140
193
|
end
|
194
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
141
195
|
|
196
|
+
sig do
|
197
|
+
params(
|
198
|
+
declaration: T.any(String, T::Hash[String, T.any(String, T::Hash[String, String])])
|
199
|
+
).returns(T.nilable([String, String, T.any(String, T::Hash[String, String])]))
|
200
|
+
end
|
142
201
|
def details_for_library_dependency(declaration)
|
143
|
-
return declaration.split(":") if declaration.is_a?(String)
|
202
|
+
return T.cast(declaration.split(":"), [String, String, String]) if declaration.is_a?(String)
|
144
203
|
|
145
|
-
|
146
|
-
|
204
|
+
hash = declaration
|
205
|
+
version = hash["version"]
|
206
|
+
return nil if version.nil?
|
207
|
+
|
208
|
+
if hash["module"]
|
209
|
+
parts = T.cast(hash["module"], String).split(":")
|
210
|
+
[T.must(parts[0]), T.must(parts[1]), version]
|
147
211
|
else
|
148
|
-
[
|
212
|
+
[T.cast(hash["group"], String), T.cast(hash["name"], String), version]
|
149
213
|
end
|
150
214
|
end
|
151
215
|
|
216
|
+
sig do
|
217
|
+
params(declaration: T.any(String, T::Hash[String, String]))
|
218
|
+
.returns(T.nilable([String, String, T.any(String, T::Hash[String, String])]))
|
219
|
+
end
|
152
220
|
def details_for_plugin_dependency(declaration)
|
153
|
-
|
221
|
+
if declaration.is_a?(String)
|
222
|
+
parts = declaration.split(":")
|
223
|
+
["plugins", T.must(parts[0]), T.must(parts[1])]
|
224
|
+
else
|
225
|
+
decl_hash = declaration
|
226
|
+
version = decl_hash["version"]
|
227
|
+
return nil if version.nil?
|
154
228
|
|
155
|
-
|
229
|
+
["plugins", T.must(decl_hash["id"]), version]
|
230
|
+
end
|
156
231
|
end
|
157
232
|
|
233
|
+
sig { params(file: Dependabot::DependencyFile).returns(T::Hash[String, T.untyped]) }
|
158
234
|
def parsed_toml_file(file)
|
159
|
-
TomlRB.parse(file.content)
|
235
|
+
T.cast(TomlRB.parse(file.content), T::Hash[String, T.untyped])
|
160
236
|
rescue TomlRB::ParseError, TomlRB::ValueOverwriteError
|
161
237
|
raise Dependabot::DependencyFileNotParseable, file.path
|
162
238
|
end
|
163
239
|
|
240
|
+
sig { params(key: String).returns(Regexp) }
|
164
241
|
def map_value_regex(key)
|
165
242
|
/(?:^|\s|,|\()#{Regexp.quote(key)}(\s*=|:)\s*['"](?<value>[^'"]+)['"]/
|
166
243
|
end
|
167
244
|
|
245
|
+
sig { params(buildfile: Dependabot::DependencyFile).returns(DependencySet) }
|
168
246
|
def buildfile_dependencies(buildfile)
|
169
247
|
dependency_set = DependencySet.new
|
170
248
|
|
@@ -176,6 +254,7 @@ module Dependabot
|
|
176
254
|
dependency_set
|
177
255
|
end
|
178
256
|
|
257
|
+
sig { params(buildfile: Dependabot::DependencyFile).returns(DependencySet) }
|
179
258
|
def shortform_buildfile_dependencies(buildfile)
|
180
259
|
dependency_set = DependencySet.new
|
181
260
|
|
@@ -193,6 +272,7 @@ module Dependabot
|
|
193
272
|
dependency_set
|
194
273
|
end
|
195
274
|
|
275
|
+
sig { params(buildfile: Dependabot::DependencyFile).returns(DependencySet) }
|
196
276
|
def keyword_arg_buildfile_dependencies(buildfile)
|
197
277
|
dependency_set = DependencySet.new
|
198
278
|
|
@@ -211,10 +291,11 @@ module Dependabot
|
|
211
291
|
dependency_set
|
212
292
|
end
|
213
293
|
|
294
|
+
sig { params(buildfile: Dependabot::DependencyFile).returns(DependencySet) }
|
214
295
|
def dependency_set_dependencies(buildfile)
|
215
296
|
dependency_set = DependencySet.new
|
216
297
|
|
217
|
-
dependency_set_blocks = []
|
298
|
+
dependency_set_blocks = T.let([], T::Array[T::Hash[Symbol, String]])
|
218
299
|
|
219
300
|
prepared_content(buildfile).scan(DEPENDENCY_SET_DECLARATION_REGEX) do
|
220
301
|
mch = T.must(Regexp.last_match)
|
@@ -226,12 +307,13 @@ module Dependabot
|
|
226
307
|
end
|
227
308
|
|
228
309
|
dependency_set_blocks.each do |blk|
|
229
|
-
|
230
|
-
|
310
|
+
arguments = T.must(blk[:arguments])
|
311
|
+
group = argument_from_string(arguments, "group")
|
312
|
+
version = argument_from_string(arguments, "version")
|
231
313
|
|
232
314
|
next unless group && version
|
233
315
|
|
234
|
-
blk[:block].scan(DEPENDENCY_SET_ENTRY_REGEX).flatten.each do |name|
|
316
|
+
T.must(blk[:block]).scan(DEPENDENCY_SET_ENTRY_REGEX).flatten.each do |name|
|
235
317
|
dep = dependency_from(
|
236
318
|
details_hash: { group: group, name: name, version: version },
|
237
319
|
buildfile: buildfile,
|
@@ -244,15 +326,17 @@ module Dependabot
|
|
244
326
|
dependency_set
|
245
327
|
end
|
246
328
|
|
329
|
+
sig { params(buildfile: Dependabot::DependencyFile).returns(DependencySet) }
|
247
330
|
def plugin_dependencies(buildfile)
|
248
331
|
dependency_set = DependencySet.new
|
249
332
|
|
250
|
-
plugin_blocks = []
|
333
|
+
plugin_blocks = T.let([], T::Array[String])
|
251
334
|
|
252
335
|
prepared_content(buildfile).scan(PLUGIN_BLOCK_DECLARATION_REGEX) do
|
253
336
|
mch = T.must(Regexp.last_match)
|
337
|
+
post_match_str = mch.post_match
|
254
338
|
plugin_blocks <<
|
255
|
-
|
339
|
+
T.must(post_match_str.slice(0..closing_bracket_index(mch.post_match)))
|
256
340
|
end
|
257
341
|
|
258
342
|
plugin_blocks.each do |blk|
|
@@ -272,14 +356,19 @@ module Dependabot
|
|
272
356
|
dependency_set
|
273
357
|
end
|
274
358
|
|
359
|
+
sig { params(version: T.nilable(String)).returns(T.nilable(String)) }
|
275
360
|
def format_plugin_version(version)
|
361
|
+
return nil unless version
|
362
|
+
|
276
363
|
quoted?(version) ? unquote(version) : "$#{version}"
|
277
364
|
end
|
278
365
|
|
366
|
+
sig { params(line: String).returns(T::Array[String]) }
|
279
367
|
def extra_groups(line)
|
280
368
|
line.match?(/kotlin(\s+#{PLUGIN_ID_REGEX}|\(#{PLUGIN_ID_REGEX}\))/o) ? ["kotlin"] : []
|
281
369
|
end
|
282
370
|
|
371
|
+
sig { params(string: String, arg_name: String).returns(T.nilable(String)) }
|
283
372
|
def argument_from_string(string, arg_name)
|
284
373
|
string
|
285
374
|
.match(map_value_regex(arg_name))
|
@@ -287,11 +376,20 @@ module Dependabot
|
|
287
376
|
&.fetch("value")
|
288
377
|
end
|
289
378
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
379
|
+
sig do
|
380
|
+
params(
|
381
|
+
details_hash: T::Hash[Symbol, T.any(String, T::Array[String])],
|
382
|
+
buildfile: Dependabot::DependencyFile,
|
383
|
+
in_dependency_set: T::Boolean
|
384
|
+
).returns(T.nilable(Dependabot::Dependency))
|
385
|
+
end
|
386
|
+
def dependency_from(details_hash:, buildfile:, in_dependency_set: false) # rubocop:disable Metrics/PerceivedComplexity
|
387
|
+
group = evaluated_value(T.cast(details_hash[:group], T.nilable(String)), buildfile)
|
388
|
+
name = evaluated_value(T.cast(details_hash[:name], T.nilable(String)), buildfile)
|
389
|
+
version = evaluated_value(T.cast(details_hash[:version], T.nilable(String)), buildfile)
|
390
|
+
extra_groups = T.cast(details_hash[:extra_groups], T.nilable(T::Array[String])) || []
|
391
|
+
|
392
|
+
return nil unless group && name && version
|
295
393
|
|
296
394
|
dependency_name =
|
297
395
|
if group == "plugins" then name
|
@@ -325,8 +423,15 @@ module Dependabot
|
|
325
423
|
)
|
326
424
|
end
|
327
425
|
|
426
|
+
sig do
|
427
|
+
params(
|
428
|
+
group: String,
|
429
|
+
name: String,
|
430
|
+
version: String
|
431
|
+
).returns(T.nilable(T::Hash[Symbol, T.nilable(String)]))
|
432
|
+
end
|
328
433
|
def source_from(group, name, version)
|
329
|
-
return nil unless group
|
434
|
+
return nil unless group.start_with?("com.github") && version.match?(/\A[0-9a-f]{40}\Z/)
|
330
435
|
|
331
436
|
account = group.sub("com.github.", "")
|
332
437
|
|
@@ -338,30 +443,37 @@ module Dependabot
|
|
338
443
|
}
|
339
444
|
end
|
340
445
|
|
446
|
+
sig do
|
447
|
+
params(
|
448
|
+
details_hash: T::Hash[Symbol, T.any(String, T::Array[String])],
|
449
|
+
in_dependency_set: T::Boolean
|
450
|
+
).returns(T.nilable(T::Hash[Symbol, T.any(String, T::Hash[Symbol, String])]))
|
451
|
+
end
|
341
452
|
def dependency_metadata(details_hash, in_dependency_set)
|
342
453
|
version_property_name =
|
343
|
-
details_hash[:version]
|
344
|
-
|
345
|
-
|
454
|
+
T.cast(details_hash[:version], String)
|
455
|
+
.match(PROPERTY_REGEX)
|
456
|
+
&.named_captures&.fetch("property_name")
|
346
457
|
|
347
458
|
return unless version_property_name || in_dependency_set
|
348
459
|
|
349
|
-
metadata = {}
|
460
|
+
metadata = T.let({}, T::Hash[Symbol, T.any(String, T::Hash[Symbol, String])])
|
350
461
|
metadata[:property_name] = version_property_name if version_property_name
|
351
462
|
if in_dependency_set
|
352
|
-
metadata[:dependency_set] = {
|
463
|
+
metadata[:dependency_set] = T.let({
|
353
464
|
group: details_hash[:group],
|
354
465
|
version: details_hash[:version]
|
355
|
-
}
|
466
|
+
}, T::Hash[Symbol, String])
|
356
467
|
end
|
357
468
|
metadata
|
358
469
|
end
|
359
470
|
|
471
|
+
sig { params(value: T.nilable(String), buildfile: Dependabot::DependencyFile).returns(T.nilable(String)) }
|
360
472
|
def evaluated_value(value, buildfile)
|
361
|
-
return value unless value
|
473
|
+
return value unless value&.scan(PROPERTY_REGEX)&.count == 1
|
362
474
|
|
363
|
-
property_name = value.match(PROPERTY_REGEX)
|
364
|
-
|
475
|
+
property_name = T.must(T.must(value).match(PROPERTY_REGEX)
|
476
|
+
&.named_captures&.fetch("property_name"))
|
365
477
|
property_value = property_value_finder.property_value(
|
366
478
|
property_name: property_name,
|
367
479
|
callsite_buildfile: buildfile
|
@@ -369,32 +481,37 @@ module Dependabot
|
|
369
481
|
|
370
482
|
return value unless property_value
|
371
483
|
|
372
|
-
value.gsub(PROPERTY_REGEX, property_value)
|
484
|
+
T.must(value).gsub(PROPERTY_REGEX, property_value)
|
373
485
|
end
|
374
486
|
|
487
|
+
sig { returns(PropertyValueFinder) }
|
375
488
|
def property_value_finder
|
376
|
-
@property_value_finder ||=
|
377
|
-
PropertyValueFinder.new(dependency_files: dependency_files)
|
489
|
+
@property_value_finder ||= T.let(
|
490
|
+
PropertyValueFinder.new(dependency_files: dependency_files),
|
491
|
+
T.nilable(PropertyValueFinder)
|
492
|
+
)
|
378
493
|
end
|
379
494
|
|
495
|
+
sig { params(buildfile: Dependabot::DependencyFile).returns(String) }
|
380
496
|
def prepared_content(buildfile)
|
381
497
|
# Remove any comments
|
382
498
|
prepared_content =
|
383
|
-
buildfile.content
|
384
|
-
|
385
|
-
|
499
|
+
T.must(buildfile.content)
|
500
|
+
.gsub(%r{(?<=^|\s)//.*$}, "\n")
|
501
|
+
.gsub(%r{(?<=^|\s)/\*.*?\*/}m, "")
|
386
502
|
|
387
503
|
# Remove the dependencyVerification section added by Gradle Witness
|
388
504
|
# (TODO: Support updating this in the FileUpdater)
|
389
505
|
prepared_content.dup.scan(/dependencyVerification\s*{/) do
|
390
506
|
mtch = T.must(Regexp.last_match)
|
391
507
|
block = mtch.post_match[0..closing_bracket_index(mtch.post_match)]
|
392
|
-
prepared_content.gsub!(block, "")
|
508
|
+
prepared_content.gsub!(T.must(block), "")
|
393
509
|
end
|
394
510
|
|
395
511
|
prepared_content
|
396
512
|
end
|
397
513
|
|
514
|
+
sig { params(string: String).returns(Integer) }
|
398
515
|
def closing_bracket_index(string)
|
399
516
|
closes_required = 1
|
400
517
|
|
@@ -407,42 +524,57 @@ module Dependabot
|
|
407
524
|
0
|
408
525
|
end
|
409
526
|
|
527
|
+
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
410
528
|
def buildfiles
|
411
|
-
@buildfiles ||=
|
412
|
-
f
|
413
|
-
|
529
|
+
@buildfiles ||= T.let(
|
530
|
+
dependency_files.select do |f|
|
531
|
+
f.name.end_with?("build.gradle", "build.gradle.kts", "settings.gradle", "settings.gradle.kts")
|
532
|
+
end,
|
533
|
+
T.nilable(T::Array[Dependabot::DependencyFile])
|
534
|
+
)
|
414
535
|
end
|
415
536
|
|
537
|
+
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
416
538
|
def version_catalog_file
|
417
|
-
@version_catalog_file ||=
|
418
|
-
f
|
419
|
-
|
539
|
+
@version_catalog_file ||= T.let(
|
540
|
+
dependency_files.select do |f|
|
541
|
+
f.name.end_with?("libs.versions.toml")
|
542
|
+
end,
|
543
|
+
T.nilable(T::Array[Dependabot::DependencyFile])
|
544
|
+
)
|
420
545
|
end
|
421
546
|
|
547
|
+
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
422
548
|
def script_plugin_files
|
423
|
-
@script_plugin_files ||=
|
549
|
+
@script_plugin_files ||= T.let(
|
424
550
|
buildfiles.flat_map do |buildfile|
|
425
551
|
FileParser.find_includes(buildfile, dependency_files)
|
426
552
|
end
|
427
|
-
.uniq
|
553
|
+
.uniq,
|
554
|
+
T.nilable(T::Array[Dependabot::DependencyFile])
|
555
|
+
)
|
428
556
|
end
|
429
557
|
|
558
|
+
sig { override.void }
|
430
559
|
def check_required_files
|
431
560
|
raise "No build.gradle or build.gradle.kts!" if dependency_files.empty?
|
432
561
|
end
|
433
562
|
|
563
|
+
sig { returns(T.nilable(Dependabot::DependencyFile)) }
|
434
564
|
def original_file
|
435
565
|
dependency_files.find do |f|
|
436
566
|
SUPPORTED_BUILD_FILE_NAMES.include?(f.name)
|
437
567
|
end
|
438
568
|
end
|
439
569
|
|
570
|
+
sig { params(string: String).returns(T::Boolean) }
|
440
571
|
def quoted?(string)
|
441
|
-
string
|
572
|
+
string.match?(/^['"].*['"]$/) || false
|
442
573
|
end
|
443
574
|
|
575
|
+
sig { params(string: String).returns(String) }
|
444
576
|
def unquote(string)
|
445
|
-
string[1..-2]
|
577
|
+
T.must(string[1..-2])
|
446
578
|
end
|
447
579
|
end
|
448
580
|
end
|
@@ -31,13 +31,10 @@ module Dependabot
|
|
31
31
|
callsite_buildfile:,
|
32
32
|
previous_value:,
|
33
33
|
updated_value:)
|
34
|
-
declaration_details = T.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
),
|
39
|
-
T::Hash[Symbol, String]
|
40
|
-
)
|
34
|
+
declaration_details = T.must(property_value_finder.property_details(
|
35
|
+
property_name: property_name,
|
36
|
+
callsite_buildfile: callsite_buildfile
|
37
|
+
))
|
41
38
|
declaration_string = declaration_details.fetch(:declaration_string)
|
42
39
|
filename = declaration_details.fetch(:file)
|
43
40
|
|
@@ -238,7 +238,7 @@ module Dependabot
|
|
238
238
|
result = string.dup
|
239
239
|
|
240
240
|
string.scan(Gradle::FileParser::PROPERTY_REGEX) do
|
241
|
-
prop_name = T.must(Regexp.last_match).named_captures.fetch("property_name")
|
241
|
+
prop_name = T.must(T.must(Regexp.last_match).named_captures.fetch("property_name"))
|
242
242
|
property_value = T.let(
|
243
243
|
property_value_finder.property_value(property_name: prop_name, callsite_buildfile: buildfile),
|
244
244
|
T.nilable(String)
|
@@ -44,10 +44,10 @@ module Dependabot
|
|
44
44
|
sig { returns(Dependabot::Dependency) }
|
45
45
|
attr_reader :dependency
|
46
46
|
|
47
|
-
sig { returns(T::Array[
|
47
|
+
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
48
48
|
attr_reader :dependency_files
|
49
49
|
|
50
|
-
sig { returns(T::Array[
|
50
|
+
sig { returns(T::Array[Dependabot::Credential]) }
|
51
51
|
attr_reader :credentials
|
52
52
|
|
53
53
|
sig { returns(T.nilable(T::Array[String])) }
|
@@ -137,11 +137,9 @@ module Dependabot
|
|
137
137
|
return @repositories if @repositories
|
138
138
|
|
139
139
|
details = if plugin?
|
140
|
-
|
141
|
-
credentials_repository_details
|
140
|
+
plugin_repository_details + credentials_repository_details
|
142
141
|
else
|
143
|
-
dependency_repository_details +
|
144
|
-
credentials_repository_details
|
142
|
+
dependency_repository_details + credentials_repository_details
|
145
143
|
end
|
146
144
|
|
147
145
|
@repositories =
|
@@ -153,7 +151,7 @@ module Dependabot
|
|
153
151
|
end
|
154
152
|
end
|
155
153
|
|
156
|
-
sig { returns(T.
|
154
|
+
sig { returns(T.nilable(T::Array[T::Hash[String, T.untyped]])) }
|
157
155
|
def google_version_details
|
158
156
|
url = Gradle::FileParser::RepositoriesFinder::GOOGLE_MAVEN_REPO
|
159
157
|
group_id, artifact_id = group_and_artifact_ids
|
@@ -205,7 +203,7 @@ module Dependabot
|
|
205
203
|
|
206
204
|
sig { params(repository_details: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
|
207
205
|
def release_info_metadata(repository_details)
|
208
|
-
@release_info_metadata ||= T.let({}, T.nilable(T::Hash[
|
206
|
+
@release_info_metadata ||= T.let({}, T.nilable(T::Hash[Integer, T.untyped]))
|
209
207
|
@release_info_metadata[repository_details.hash] ||=
|
210
208
|
begin
|
211
209
|
response = Dependabot::RegistryClient.get(
|
@@ -225,7 +223,7 @@ module Dependabot
|
|
225
223
|
end
|
226
224
|
end
|
227
225
|
|
228
|
-
sig { returns(T
|
226
|
+
sig { returns(T::Array[T::Hash[String, String]]) }
|
229
227
|
def repository_urls
|
230
228
|
plugin? ? plugin_repository_details : dependency_repository_details
|
231
229
|
end
|
@@ -239,7 +237,7 @@ module Dependabot
|
|
239
237
|
T.must(@forbidden_urls) << repository_url
|
240
238
|
end
|
241
239
|
|
242
|
-
sig { returns(T::Array[T
|
240
|
+
sig { returns(T::Array[T::Hash[String, String]]) }
|
243
241
|
def credentials_repository_details
|
244
242
|
credentials
|
245
243
|
.select { |cred| cred["type"] == "maven_repository" }
|
@@ -251,7 +249,7 @@ module Dependabot
|
|
251
249
|
end
|
252
250
|
end
|
253
251
|
|
254
|
-
sig { returns(T::Array[T
|
252
|
+
sig { returns(T::Array[T::Hash[String, String]]) }
|
255
253
|
def dependency_repository_details
|
256
254
|
requirement_files =
|
257
255
|
dependency.requirements
|
@@ -270,7 +268,7 @@ module Dependabot
|
|
270
268
|
end.uniq
|
271
269
|
end
|
272
270
|
|
273
|
-
sig { returns(T
|
271
|
+
sig { returns(T::Array[T::Hash[String, String]]) }
|
274
272
|
def plugin_repository_details
|
275
273
|
[{
|
276
274
|
"url" => Gradle::FileParser::RepositoriesFinder::GRADLE_PLUGINS_REPO,
|
@@ -299,7 +297,7 @@ module Dependabot
|
|
299
297
|
current_type == version_type
|
300
298
|
end
|
301
299
|
|
302
|
-
sig { returns(T::
|
300
|
+
sig { returns(T.nilable(Dependabot::DependencyFile)) }
|
303
301
|
def pom
|
304
302
|
filename = T.must(dependency.requirements.first).fetch(:file)
|
305
303
|
dependency_files.find { |f| f.name == filename }
|
@@ -29,7 +29,7 @@ module Dependabot
|
|
29
29
|
params(
|
30
30
|
requirements: T::Array[T::Hash[Symbol, T.untyped]],
|
31
31
|
latest_version: T.nilable(T.any(Version, String)),
|
32
|
-
source_url: String,
|
32
|
+
source_url: T.nilable(String),
|
33
33
|
properties_to_update: T::Array[String]
|
34
34
|
)
|
35
35
|
.void
|
@@ -71,7 +71,7 @@ module Dependabot
|
|
71
71
|
sig { returns(T.nilable(Version)) }
|
72
72
|
attr_reader :latest_version
|
73
73
|
|
74
|
-
sig { returns(String) }
|
74
|
+
sig { returns(T.nilable(String)) }
|
75
75
|
attr_reader :source_url
|
76
76
|
|
77
77
|
sig { returns(T::Array[String]) }
|