dependabot-gradle 0.129.1 → 0.130.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: 24cc176b8c4a45f3f4302043bde409d11ee8723d55c924a163f40ff527b60e95
4
- data.tar.gz: e19cc15af72b9076b71acef04ce771a4b66a785bf761a61087d335b78af0c851
3
+ metadata.gz: 30806d65eba9550d4c72c1837957c402d24c4dfd28f2f72cbfc202e3e5abc3eb
4
+ data.tar.gz: f24664394a6464e90ccf6efb0a861f751ec0f4cfade7b0db14baf921c7e3afbc
5
5
  SHA512:
6
- metadata.gz: 5f124e90638168272dda7b9c3f5c8f44401eebc902abf9ad9cdf939667e4c31c7f129ef822a887402441f6eb1629a1e86c03e4de35f61da60ab8798c7d087d94
7
- data.tar.gz: 6986d7fa375c43171da2f3502c35c85f97791c511c16c29490492a0d5bfc365ef34bfc2d49e82769b8e5a295ccdcd84adcf2a3d70158c6ead2b2dc3069f5c5d4
6
+ metadata.gz: e62b649fadd3355e2ce0e7b7921a2198b908ad2682ba5f9097cdcb3c5968b2ba9102a7951c22cab9fd209c94dbc69139ecd4524a1aaab8d7190913814ed3d685
7
+ data.tar.gz: 208d5ef9f5d52a24c5f0d59d60ad76b2a651f89695bbe65be92180c935967e4d462c7d5e647b6809ca4053511580aaa4355830ee8003f360445d65dbebf90ae7
@@ -31,6 +31,7 @@ module Dependabot
31
31
  fetched_files << buildfile
32
32
  fetched_files += subproject_buildfiles
33
33
  fetched_files += dependency_script_plugins
34
+ check_required_files_present
34
35
  fetched_files
35
36
  end
36
37
 
@@ -38,7 +39,7 @@ module Dependabot
38
39
  @buildfile ||= begin
39
40
  file = supported_build_file
40
41
  @buildfile_name ||= file.name if file
41
- fetch_file_from_host(file.name) if file
42
+ file
42
43
  end
43
44
  end
44
45
 
@@ -58,7 +59,10 @@ module Dependabot
58
59
  end.compact
59
60
  end
60
61
 
62
+ # rubocop:disable Metrics/PerceivedComplexity
61
63
  def dependency_script_plugins
64
+ return [] unless buildfile
65
+
62
66
  dependency_plugin_paths =
63
67
  buildfile.content.
64
68
  scan(/apply from:\s+['"]([^'"]+)['"]/).flatten.
@@ -77,6 +81,15 @@ module Dependabot
77
81
  raise
78
82
  end.compact
79
83
  end
84
+ # rubocop:enable Metrics/PerceivedComplexity
85
+
86
+ def check_required_files_present
87
+ return if buildfile
88
+
89
+ path = Pathname.new(File.join(directory, "build.gradle")).cleanpath.to_path
90
+ path += "(.kts)?"
91
+ raise Dependabot::DependencyFileNotFound, path
92
+ end
80
93
 
81
94
  def file_exists_in_submodule?(path)
82
95
  fetch_file_from_host(path, fetch_submodules: true)
@@ -86,12 +99,7 @@ module Dependabot
86
99
  end
87
100
 
88
101
  def settings_file
89
- @settings_file ||= begin
90
- file = supported_settings_file
91
- fetch_file_from_host(file.name) if file
92
- rescue Dependabot::DependencyFileNotFound
93
- nil
94
- end
102
+ @settings_file ||= supported_settings_file
95
103
  end
96
104
 
97
105
  def supported_build_file
@@ -6,9 +6,6 @@ module Dependabot
6
6
  module Gradle
7
7
  class FileFetcher
8
8
  class SettingsFileParser
9
- INCLUDE_ARGS_REGEX =
10
- /(?:^|\s)include(?:\(|\s)(\s*[^\s,\)]+(?:,\s*[^\s,\)]+)*)/.freeze
11
-
12
9
  def initialize(settings_file:)
13
10
  @settings_file = settings_file
14
11
  end
@@ -49,7 +46,7 @@ module Dependabot
49
46
 
50
47
  def function_regex(function_name)
51
48
  /
52
- (?:^|\s)#{Regexp.quote(function_name)}(?:\(|\s)
49
+ (?:^|\s)#{Regexp.quote(function_name)}(?:\s*\(|\s)
53
50
  (?<args>\s*[^\s,\)]+(?:,\s*[^\s,\)]+)*)
54
51
  /mx
55
52
  end
@@ -36,8 +36,6 @@ module Dependabot
36
36
  /(?:^|\s)dependencySet\((?<arguments>[^\)]+)\)\s*\{/.freeze
37
37
  DEPENDENCY_SET_ENTRY_REGEX = /entry\s+['"](?<name>#{PART})['"]/.freeze
38
38
  PLUGIN_BLOCK_DECLARATION_REGEX = /(?:^|\s)plugins\s*\{/.freeze
39
- PLUGIN_BLOCK_ENTRY_REGEX =
40
- /id\s+"(?<id>#{PART})"\s+version\s+"(?<version>#{VSN_PART})"/.freeze
41
39
  PLUGIN_ID_REGEX = /['"](?<id>#{PART})['"]/.freeze
42
40
 
43
41
  def parse
@@ -149,14 +147,14 @@ module Dependabot
149
147
 
150
148
  plugin_blocks.each do |blk|
151
149
  blk.lines.each do |line|
152
- name_regex = /id(\s+#{PLUGIN_ID_REGEX}|\(#{PLUGIN_ID_REGEX}\))/
150
+ name_regex = /(id|kotlin)(\s+#{PLUGIN_ID_REGEX}|\(#{PLUGIN_ID_REGEX}\))/
153
151
  name = line.match(name_regex)&.named_captures&.fetch("id")
154
152
  version_regex = /version\s+['"](?<version>#{VSN_PART})['"]/
155
153
  version = line.match(version_regex)&.named_captures&.
156
154
  fetch("version")
157
155
  next unless name && version
158
156
 
159
- details = { name: name, group: "plugins", version: version }
157
+ details = { name: name, group: "plugins", extra_groups: extra_groups(line), version: version }
160
158
  dep = dependency_from(details_hash: details, buildfile: buildfile)
161
159
  dependency_set << dep if dep
162
160
  end
@@ -165,6 +163,10 @@ module Dependabot
165
163
  dependency_set
166
164
  end
167
165
 
166
+ def extra_groups(line)
167
+ line.match(/kotlin(\s+#{PLUGIN_ID_REGEX}|\(#{PLUGIN_ID_REGEX}\))/) ? ["kotlin"] : []
168
+ end
169
+
168
170
  def argument_from_string(string, arg_name)
169
171
  string.
170
172
  match(map_value_regex(arg_name))&.
@@ -176,13 +178,14 @@ module Dependabot
176
178
  group = evaluated_value(details_hash[:group], buildfile)
177
179
  name = evaluated_value(details_hash[:name], buildfile)
178
180
  version = evaluated_value(details_hash[:version], buildfile)
181
+ extra_groups = details_hash[:extra_groups] || []
179
182
 
180
183
  dependency_name =
181
184
  if group == "plugins" then name
182
185
  else "#{group}:#{name}"
183
186
  end
184
187
  groups =
185
- if group == "plugins" then ["plugins"]
188
+ if group == "plugins" then ["plugins"] + extra_groups
186
189
  else []
187
190
  end
188
191
  source =
@@ -140,7 +140,7 @@ module Dependabot
140
140
  next false unless line.include?(dependency.name.split(":").last)
141
141
  else
142
142
  name_regex_value = /['"]#{Regexp.quote(dependency.name)}['"]/
143
- name_regex = /id(\s+#{name_regex_value}|\(#{name_regex_value}\))/
143
+ name_regex = /(id|kotlin)(\s+#{name_regex_value}|\(#{name_regex_value}\))/
144
144
  next false unless line.match?(name_regex)
145
145
  end
146
146
 
@@ -11,6 +11,7 @@ module Dependabot
11
11
  class MetadataFinder < Dependabot::MetadataFinders::Base
12
12
  DOT_SEPARATOR_REGEX = %r{\.(?!\d+([.\/_\-]|$)+)}.freeze
13
13
  PROPERTY_REGEX = /\$\{(?<property>.*?)\}/.freeze
14
+ KOTLIN_PLUGIN_REPO_PREFIX = "org.jetbrains.kotlin"
14
15
 
15
16
  private
16
17
 
@@ -101,7 +102,8 @@ module Dependabot
101
102
  return @dependency_pom_file unless @dependency_pom_file.nil?
102
103
 
103
104
  artifact_id =
104
- if plugin? then "#{dependency.name}.gradle.plugin"
105
+ if kotlin_plugin? then "#{KOTLIN_PLUGIN_REPO_PREFIX}.#{dependency.name}.gradle.plugin"
106
+ elsif plugin? then "#{dependency.name}.gradle.plugin"
105
107
  else dependency.name.split(":").last
106
108
  end
107
109
 
@@ -150,7 +152,10 @@ module Dependabot
150
152
 
151
153
  def maven_repo_dependency_url
152
154
  group_id, artifact_id =
153
- if plugin? then [dependency.name, "#{dependency.name}.gradle.plugin"]
155
+ if kotlin_plugin?
156
+ ["#{KOTLIN_PLUGIN_REPO_PREFIX}.#{dependency.name}",
157
+ "#{KOTLIN_PLUGIN_REPO_PREFIX}.#{dependency.name}.gradle.plugin"]
158
+ elsif plugin? then [dependency.name, "#{dependency.name}.gradle.plugin"]
154
159
  else dependency.name.split(":")
155
160
  end
156
161
 
@@ -158,7 +163,11 @@ module Dependabot
158
163
  end
159
164
 
160
165
  def plugin?
161
- dependency.requirements.any? { |r| r.fetch(:groups) == ["plugins"] }
166
+ dependency.requirements.any? { |r| r.fetch(:groups).include? "plugins" }
167
+ end
168
+
169
+ def kotlin_plugin?
170
+ plugin? && dependency.requirements.any? { |r| r.fetch(:groups).include? "kotlin" }
162
171
  end
163
172
 
164
173
  def auth_details
@@ -13,6 +13,7 @@ module Dependabot
13
13
  class VersionFinder
14
14
  GOOGLE_MAVEN_REPO = "https://maven.google.com"
15
15
  GRADLE_PLUGINS_REPO = "https://plugins.gradle.org/m2"
16
+ KOTLIN_PLUGIN_REPO_PREFIX = "org.jetbrains.kotlin"
16
17
  TYPE_SUFFICES = %w(jre android java).freeze
17
18
 
18
19
  GRADLE_RANGE_REGEX = /[\(\[].*,.*[\)\]]/.freeze
@@ -295,6 +296,7 @@ module Dependabot
295
296
 
296
297
  def dependency_metadata_url(repository_url)
297
298
  group_id, artifact_id = group_and_artifact_ids
299
+ group_id = "#{KOTLIN_PLUGIN_REPO_PREFIX}.#{group_id}" if kotlin_plugin?
298
300
 
299
301
  "#{repository_url}/"\
300
302
  "#{group_id.tr('.', '/')}/"\
@@ -303,7 +305,9 @@ module Dependabot
303
305
  end
304
306
 
305
307
  def group_and_artifact_ids
306
- if plugin?
308
+ if kotlin_plugin?
309
+ [dependency.name, "#{KOTLIN_PLUGIN_REPO_PREFIX}.#{dependency.name}.gradle.plugin"]
310
+ elsif plugin?
307
311
  [dependency.name, "#{dependency.name}.gradle.plugin"]
308
312
  else
309
313
  dependency.name.split(":")
@@ -311,7 +315,11 @@ module Dependabot
311
315
  end
312
316
 
313
317
  def plugin?
314
- dependency.requirements.any? { |r| r.fetch(:groups) == ["plugins"] }
318
+ dependency.requirements.any? { |r| r.fetch(:groups).include? "plugins" }
319
+ end
320
+
321
+ def kotlin_plugin?
322
+ plugin? && dependency.requirements.any? { |r| r.fetch(:groups).include? "kotlin" }
315
323
  end
316
324
 
317
325
  def central_repo_urls
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.129.1
4
+ version: 0.130.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-21 00:00:00.000000000 Z
11
+ date: 2021-01-13 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.129.1
19
+ version: 0.130.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.129.1
26
+ version: 0.130.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: byebug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -100,28 +100,28 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.6.0
103
+ version: 1.8.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.6.0
110
+ version: 1.8.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.20.0
117
+ version: 0.21.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.20.0
124
+ version: 0.21.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: simplecov-console
127
127
  requirement: !ruby/object:Gem::Requirement