dependabot-nuget 0.211.0 → 0.213.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: 5c52ee5a1c0902c360140b7425a5050a8c97cb0f7ceb90870056032368ca00c6
4
- data.tar.gz: 1a8307c23e5bfa43387ded3b49598ffa2ca1900b42237d66a0f87398849678be
3
+ metadata.gz: a5f084f252deef0d960dff54bc9d3bbef2c21b38f6853f19a3ea5229f239660f
4
+ data.tar.gz: 8fd0eac3457d63ba3132ea4d9955e041439303310cb6a8b6f89fce60ade5faf7
5
5
  SHA512:
6
- metadata.gz: d43d2e4e65c71954a87088c02d3f54534f07568bb3f0c0d385e778fbf3f4632b81c10495934b99f06699dd57076d614e5e67b048ffb4a6ebaaf5bfb4de0857e5
7
- data.tar.gz: 9e76485ddba6429ea2808bc09627221a61934dc0240ad7e84c44f14906d439506e3c50bf02daea054aa6ab2d903ece49e827bebd9272ba9042945f05c062ad08
6
+ metadata.gz: 24446f402afc0c8f466cc1d74c6d03386a7436b297f04ad166a95fa69d741dfd195b8778c3edfdbf2d6baccb64d3a1ace47fc54de88b73bef3dc71b8579a8e46
7
+ data.tar.gz: d19f127b8a9a8890fc60be39912e6b30669b0fb371813f6b0547841740ce3061caea3fae953c10d29e849503f8807fdd322ca6ac0c41a670b6233b906b0bba71
@@ -73,11 +73,11 @@ module Dependabot
73
73
  [*project_files.map { |f| File.dirname(f.name) }, "."].uniq
74
74
 
75
75
  @packages_config_files ||=
76
- candidate_paths.map do |dir|
76
+ candidate_paths.filter_map do |dir|
77
77
  file = repo_contents(dir: dir).
78
78
  find { |f| f.name.casecmp("packages.config").zero? }
79
79
  fetch_file_from_host(File.join(dir, file.name)) if file
80
- end.compact
80
+ end
81
81
  end
82
82
 
83
83
  # rubocop:disable Metrics/PerceivedComplexity
@@ -157,7 +157,7 @@ module Dependabot
157
157
  project_paths
158
158
  end
159
159
 
160
- paths.map do |path|
160
+ paths.filter_map do |path|
161
161
  fetch_file_from_host(path)
162
162
  rescue Dependabot::DependencyFileNotFound => e
163
163
  @missing_sln_project_file_errors ||= []
@@ -165,7 +165,7 @@ module Dependabot
165
165
  # Don't worry about missing files too much for now (at least
166
166
  # until we start resolving properties)
167
167
  nil
168
- end.compact
168
+ end
169
169
  end
170
170
  end
171
171
 
@@ -209,12 +209,12 @@ module Dependabot
209
209
  [*project_files.map { |f| File.dirname(f.name) }, "."].uniq
210
210
 
211
211
  @nuget_config_files ||=
212
- candidate_paths.map do |dir|
212
+ candidate_paths.filter_map do |dir|
213
213
  file = repo_contents(dir: dir).
214
214
  find { |f| f.name.casecmp("nuget.config").zero? }
215
215
  file = fetch_file_from_host(File.join(dir, file.name)) if file
216
216
  file&.tap { |f| f.support_file = true }
217
- end.compact
217
+ end
218
218
  end
219
219
 
220
220
  def global_json
@@ -33,7 +33,7 @@ module Dependabot
33
33
  requirements: [{
34
34
  requirement: version,
35
35
  file: global_json.name,
36
- groups: [],
36
+ groups: ["dependencies"],
37
37
  source: nil
38
38
  }]
39
39
  )
@@ -61,7 +61,7 @@ module Dependabot
61
61
  def dependency_type(dependency_node)
62
62
  val = dependency_node.attribute("developmentDependency")&.value&.strip ||
63
63
  dependency_node.at_xpath("./developmentDependency")&.content&.strip
64
- val.to_s.downcase == "true" ? "devDependencies" : "dependencies"
64
+ val.to_s.casecmp("true").zero? ? "devDependencies" : "dependencies"
65
65
  end
66
66
  end
67
67
  end
@@ -14,15 +14,15 @@ module Dependabot
14
14
  require "dependabot/file_parsers/base/dependency_set"
15
15
  require_relative "property_value_finder"
16
16
 
17
- DEPENDENCY_SELECTOR = "ItemGroup > PackageReference, "\
18
- "ItemGroup > GlobalPackageReference, "\
19
- "ItemGroup > PackageVersion, "\
20
- "ItemGroup > Dependency, "\
17
+ DEPENDENCY_SELECTOR = "ItemGroup > PackageReference, " \
18
+ "ItemGroup > GlobalPackageReference, " \
19
+ "ItemGroup > PackageVersion, " \
20
+ "ItemGroup > Dependency, " \
21
21
  "ItemGroup > DevelopmentDependency"
22
22
 
23
- PROJECT_SDK_REGEX = %r{^([^/]+)/(\d+(?:[.]\d+(?:[.]\d+)?)?(?:[+-].*)?)$}.freeze
24
- PROPERTY_REGEX = /\$\((?<property>.*?)\)/.freeze
25
- ITEM_REGEX = /\@\((?<property>.*?)\)/.freeze
23
+ PROJECT_SDK_REGEX = %r{^([^/]+)/(\d+(?:[.]\d+(?:[.]\d+)?)?(?:[+-].*)?)$}
24
+ PROPERTY_REGEX = /\$\((?<property>.*?)\)/
25
+ ITEM_REGEX = /\@\((?<property>.*?)\)/
26
26
 
27
27
  def initialize(dependency_files:)
28
28
  @dependency_files = dependency_files
@@ -10,7 +10,7 @@ module Dependabot
10
10
  module Nuget
11
11
  class FileParser
12
12
  class PropertyValueFinder
13
- PROPERTY_REGEX = /\$\((?<property>.*?)\)/.freeze
13
+ PROPERTY_REGEX = /\$\((?<property>.*?)\)/
14
14
 
15
15
  def initialize(dependency_files:)
16
16
  @dependency_files = dependency_files
@@ -47,7 +47,7 @@ module Dependabot
47
47
  find_property_in_packages_props(property: property_name)
48
48
 
49
49
  return unless node_details
50
- return node_details unless node_details[:value] =~ PROPERTY_REGEX
50
+ return node_details unless PROPERTY_REGEX.match?(node_details[:value])
51
51
 
52
52
  check_next_level_of_stack(node_details, stack)
53
53
  end
@@ -91,8 +91,7 @@ module Dependabot
91
91
  ]
92
92
 
93
93
  file = import_paths.
94
- map { |p| dependency_files.find { |f| f.name == p } }.
95
- compact.
94
+ filter_map { |p| dependency_files.find { |f| f.name == p } }.
96
95
  find { |f| deep_find_prop_node(property: property, file: f) }
97
96
 
98
97
  return unless file
@@ -9,7 +9,7 @@ module Dependabot
9
9
  class PackagesConfigDeclarationFinder
10
10
  DECLARATION_REGEX =
11
11
  %r{<package [^>]*?/>|
12
- <package [^>]*?[^/]>.*?</package>}mx.freeze
12
+ <package [^>]*?[^/]>.*?</package>}mx
13
13
 
14
14
  attr_reader :dependency_name, :declaring_requirement,
15
15
  :packages_config
@@ -19,18 +19,18 @@ module Dependabot
19
19
  <Dependency [^>]*?[^/]>.*?</Dependency>|
20
20
  <DevelopmentDependency [^>]*?/>|
21
21
  <DevelopmentDependency [^>]*?[^/]>.*?</DevelopmentDependency>
22
- }mx.freeze
22
+ }mx
23
23
  SDK_IMPORT_REGEX =
24
24
  / <Import [^>]*?Sdk="[^"]*?"[^>]*?Version="[^"]*?"[^>]*?>
25
25
  | <Import [^>]*?Version="[^"]*?"[^>]*?Sdk="[^"]*?"[^>]*?>
26
- /mx.freeze
26
+ /mx
27
27
  SDK_PROJECT_REGEX =
28
28
  / <Project [^>]*?Sdk="[^"]*?"[^>]*?>
29
- /mx.freeze
29
+ /mx
30
30
  SDK_SDK_REGEX =
31
31
  / <Sdk [^>]*?Name="[^"]*?"[^>]*?Version="[^"]*?"[^>]*?>
32
32
  | <Sdk [^>]*?Version="[^"]*?"[^>]*?Name="[^"]*?"[^>]*?>
33
- /mx.freeze
33
+ /mx
34
34
 
35
35
  attr_reader :dependency_name, :declaring_requirement,
36
36
  :dependency_files
@@ -63,7 +63,7 @@ module Dependabot
63
63
 
64
64
  def extract_source_repo(body)
65
65
  JSON.parse(body).fetch("data", []).each do |search_result|
66
- next unless search_result["id"].downcase == dependency.name.downcase
66
+ next unless search_result["id"].casecmp(dependency.name).zero?
67
67
 
68
68
  if search_result.key?("projectUrl")
69
69
  source = Source.from_url(search_result.fetch("projectUrl"))
@@ -121,21 +121,7 @@ module Dependabot
121
121
  source = dependency.requirements.
122
122
  find { |r| r&.fetch(:source) }&.fetch(:source)
123
123
 
124
- if source&.key?(:nuspec_url)
125
- source.fetch(:nuspec_url) ||
126
- "https://api.nuget.org/v3-flatcontainer/"\
127
- "#{dependency.name.downcase}/#{dependency.version}/"\
128
- "#{dependency.name.downcase}.nuspec"
129
- elsif source&.key?(:nuspec_url)
130
- source.fetch("nuspec_url") ||
131
- "https://api.nuget.org/v3-flatcontainer/"\
132
- "#{dependency.name.downcase}/#{dependency.version}/"\
133
- "#{dependency.name.downcase}.nuspec"
134
- else
135
- "https://api.nuget.org/v3-flatcontainer/"\
136
- "#{dependency.name.downcase}/#{dependency.version}/"\
137
- "#{dependency.name.downcase}.nuspec"
138
- end
124
+ return source.fetch(:nuspec_url) if source&.key?(:nuspec_url)
139
125
  end
140
126
 
141
127
  def dependency_source_url
@@ -21,7 +21,7 @@ module Dependabot
21
21
  [matches[1] || "=", Nuget::Version.new(matches[2])]
22
22
  end
23
23
 
24
- # For consistency with other langauges, we define a requirements array.
24
+ # For consistency with other languages, we define a requirements array.
25
25
  # Dotnet doesn't have an `OR` separator for requirements, so it always
26
26
  # contains a single element.
27
27
  def self.requirements_array(requirement_string)
@@ -11,6 +11,7 @@ module Dependabot
11
11
  class UpdateChecker
12
12
  class RepositoryFinder
13
13
  DEFAULT_REPOSITORY_URL = "https://api.nuget.org/v3/index.json"
14
+ DEFAULT_REPOSITORY_API_KEY = "nuget.org"
14
15
 
15
16
  def initialize(dependency:, credentials:, config_files: [])
16
17
  @dependency = dependency
@@ -30,7 +31,7 @@ module Dependabot
30
31
  @find_dependency_urls ||=
31
32
  known_repositories.flat_map do |details|
32
33
  if details.fetch(:url) == DEFAULT_REPOSITORY_URL
33
- # Save a request for the default URL, since we already how
34
+ # Save a request for the default URL, since we already know how
34
35
  # it addresses packages
35
36
  next default_repository_details
36
37
  end
@@ -151,27 +152,26 @@ module Dependabot
151
152
  def repos_from_config_file(config_file)
152
153
  doc = Nokogiri::XML(config_file.content)
153
154
  doc.remove_namespaces!
154
- sources =
155
- doc.css("configuration > packageSources > add").map do |node|
156
- {
157
- key:
158
- node.attribute("key")&.value&.strip ||
159
- node.at_xpath("./key")&.content&.strip,
160
- url:
161
- node.attribute("value")&.value&.strip ||
162
- node.at_xpath("./value")&.content&.strip
163
- }
155
+ # analogous to having a root config with the default repository
156
+ base_sources = [{ url: DEFAULT_REPOSITORY_URL, key: "nuget.org" }]
157
+
158
+ sources = []
159
+ doc.css("configuration > packageSources").children.each do |node|
160
+ if node.name == "clear"
161
+ sources.clear
162
+ base_sources.clear
163
+ else
164
+ key = node.attribute("key")&.value&.strip || node.at_xpath("./key")&.content&.strip
165
+ url = node.attribute("value")&.value&.strip || node.at_xpath("./value")&.content&.strip
166
+ sources << { url: url, key: key }
164
167
  end
165
-
168
+ end
169
+ sources += base_sources # TODO: quirky overwrite behavior
166
170
  disabled_sources = disabled_sources(doc)
167
171
  sources.reject! do |s|
168
172
  disabled_sources.include?(s[:key])
169
173
  end
170
174
 
171
- unless doc.css("configuration > packageSources > clear").any?
172
- sources << { url: DEFAULT_REPOSITORY_URL, key: nil }
173
- end
174
-
175
175
  sources.reject! do |s|
176
176
  known_urls = credential_repositories.map { |cr| cr.fetch(:url) }
177
177
  known_urls.include?(s.fetch(:url))
@@ -191,10 +191,10 @@ module Dependabot
191
191
  def default_repository_details
192
192
  {
193
193
  repository_url: DEFAULT_REPOSITORY_URL,
194
- versions_url: "https://api.nuget.org/v3-flatcontainer/"\
195
- "#{dependency.name.downcase}/index.json",
196
- search_url: "https://azuresearch-usnc.nuget.org/query"\
197
- "?q=#{dependency.name.downcase}&prerelease=true&semVerLevel=2.0.0",
194
+ versions_url: "https://api.nuget.org/v3-flatcontainer/" \
195
+ "#{dependency.name.downcase}/index.json",
196
+ search_url: "https://azuresearch-usnc.nuget.org/query" \
197
+ "?q=#{dependency.name.downcase}&prerelease=true&semVerLevel=2.0.0",
198
198
  auth_header: {},
199
199
  repository_type: "v3"
200
200
  }
@@ -202,7 +202,7 @@ module Dependabot
202
202
 
203
203
  # rubocop:disable Metrics/PerceivedComplexity
204
204
  def disabled_sources(doc)
205
- doc.css("configuration > disabledPackageSources > add").map do |node|
205
+ doc.css("configuration > disabledPackageSources > add").filter_map do |node|
206
206
  value = node.attribute("value")&.value ||
207
207
  node.at_xpath("./value")&.content
208
208
 
@@ -222,7 +222,7 @@ module Dependabot
222
222
  next source_details[:token] = nil if key.match?(/^\d/)
223
223
 
224
224
  tag = key.gsub(" ", "_x0020_")
225
- creds_nodes = doc.css("configuration > packageSourceCredentials "\
225
+ creds_nodes = doc.css("configuration > packageSourceCredentials " \
226
226
  "> #{tag} > add")
227
227
 
228
228
  username =
@@ -38,7 +38,7 @@ module Dependabot
38
38
  # replace anything that looks like a version with the new
39
39
  # version
40
40
  req[:requirement].sub(
41
- /#{Nuget::Version::VERSION_PATTERN}/,
41
+ /#{Nuget::Version::VERSION_PATTERN}/o,
42
42
  latest_version.to_s
43
43
  )
44
44
  end
@@ -15,7 +15,7 @@ module Dependabot
15
15
  class VersionFinder
16
16
  require_relative "repository_finder"
17
17
 
18
- NUGET_RANGE_REGEX = /[\(\[].*,.*[\)\]]/.freeze
18
+ NUGET_RANGE_REGEX = /[\(\[].*,.*[\)\]]/
19
19
 
20
20
  def initialize(dependency:, dependency_files:, credentials:,
21
21
  ignored_versions:, raise_on_ignored: false,
@@ -127,7 +127,7 @@ module Dependabot
127
127
  doc = Nokogiri::XML(body)
128
128
  doc.remove_namespaces!
129
129
 
130
- doc.xpath("/feed/entry").map do |entry|
130
+ doc.xpath("/feed/entry").filter_map do |entry|
131
131
  listed = entry.at_xpath("./properties/Listed")&.content&.strip
132
132
  next if listed&.casecmp("false")&.zero?
133
133
 
@@ -136,7 +136,7 @@ module Dependabot
136
136
  repo_url: listing.fetch("listing_details").
137
137
  fetch(:repository_url)
138
138
  )
139
- end.compact
139
+ end
140
140
  end
141
141
  end
142
142
 
@@ -172,7 +172,7 @@ module Dependabot
172
172
 
173
173
  dependency.requirements.any? do |req|
174
174
  reqs = parse_requirement_string(req.fetch(:requirement) || "")
175
- return true if reqs.any? { |r| r == "*-*" }
175
+ return true if reqs.any?("*-*")
176
176
  next unless reqs.any? { |r| r.include?("-") }
177
177
 
178
178
  requirement_class.
@@ -193,12 +193,12 @@ module Dependabot
193
193
  @v3_nuget_listings ||=
194
194
  dependency_urls.
195
195
  select { |details| details.fetch(:repository_type) == "v3" }.
196
- map do |url_details|
196
+ filter_map do |url_details|
197
197
  versions = versions_for_v3_repository(url_details)
198
198
  next unless versions
199
199
 
200
200
  { "versions" => versions, "listing_details" => url_details }
201
- end.compact
201
+ end
202
202
  end
203
203
 
204
204
  def v2_nuget_listings
@@ -208,14 +208,14 @@ module Dependabot
208
208
  dependency_urls.
209
209
  select { |details| details.fetch(:repository_type) == "v2" }.
210
210
  flat_map { |url_details| fetch_paginated_v2_nuget_listings(url_details) }.
211
- map do |url_details, response|
211
+ filter_map do |url_details, response|
212
212
  next unless response.status == 200
213
213
 
214
214
  {
215
215
  "xml_body" => response.body,
216
216
  "listing_details" => url_details
217
217
  }
218
- end.compact
218
+ end
219
219
  end
220
220
 
221
221
  def fetch_paginated_v2_nuget_listings(url_details, results = {})
@@ -11,7 +11,7 @@ module Dependabot
11
11
  module Nuget
12
12
  class Version < Gem::Version
13
13
  VERSION_PATTERN = Gem::Version::VERSION_PATTERN + '(\+[0-9a-zA-Z\-.]+)?'
14
- ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})?\s*\z/.freeze
14
+ ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})?\s*\z/
15
15
 
16
16
  def self.correct?(version)
17
17
  return false if version.nil?
@@ -15,4 +15,11 @@ Dependabot::PullRequestCreator::Labeler.
15
15
  register_label_details("nuget", name: ".NET", colour: "7121c6")
16
16
 
17
17
  require "dependabot/dependency"
18
- Dependabot::Dependency.register_production_check("nuget", ->(_) { true })
18
+ Dependabot::Dependency.register_production_check(
19
+ "nuget",
20
+ lambda do |groups|
21
+ return true if groups.empty?
22
+
23
+ groups.include?("dependencies")
24
+ end
25
+ )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-nuget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.211.0
4
+ version: 0.213.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-08-23 00:00:00.000000000 Z
11
+ date: 2022-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,42 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.211.0
19
+ version: 0.213.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.211.0
27
- - !ruby/object:Gem::Dependency
28
- name: debase
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '='
32
- - !ruby/object:Gem::Version
33
- version: 0.2.3
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '='
39
- - !ruby/object:Gem::Version
40
- version: 0.2.3
41
- - !ruby/object:Gem::Dependency
42
- name: debase-ruby_core_source
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '='
46
- - !ruby/object:Gem::Version
47
- version: 0.10.16
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '='
53
- - !ruby/object:Gem::Version
54
- version: 0.10.16
26
+ version: 0.213.0
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: debug
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +58,14 @@ dependencies:
86
58
  requirements:
87
59
  - - "~>"
88
60
  - !ruby/object:Gem::Version
89
- version: 3.11.1
61
+ version: 3.13.0
90
62
  type: :development
91
63
  prerelease: false
92
64
  version_requirements: !ruby/object:Gem::Requirement
93
65
  requirements:
94
66
  - - "~>"
95
67
  - !ruby/object:Gem::Version
96
- version: 3.11.1
68
+ version: 3.13.0
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: rake
99
71
  requirement: !ruby/object:Gem::Requirement
@@ -142,28 +114,28 @@ dependencies:
142
114
  requirements:
143
115
  - - "~>"
144
116
  - !ruby/object:Gem::Version
145
- version: 1.35.1
117
+ version: 1.37.1
146
118
  type: :development
147
119
  prerelease: false
148
120
  version_requirements: !ruby/object:Gem::Requirement
149
121
  requirements:
150
122
  - - "~>"
151
123
  - !ruby/object:Gem::Version
152
- version: 1.35.1
124
+ version: 1.37.1
153
125
  - !ruby/object:Gem::Dependency
154
- name: ruby-debug-ide
126
+ name: rubocop-performance
155
127
  requirement: !ruby/object:Gem::Requirement
156
128
  requirements:
157
129
  - - "~>"
158
130
  - !ruby/object:Gem::Version
159
- version: 0.7.3
131
+ version: 1.15.0
160
132
  type: :development
161
133
  prerelease: false
162
134
  version_requirements: !ruby/object:Gem::Requirement
163
135
  requirements:
164
136
  - - "~>"
165
137
  - !ruby/object:Gem::Version
166
- version: 0.7.3
138
+ version: 1.15.0
167
139
  - !ruby/object:Gem::Dependency
168
140
  name: simplecov
169
141
  requirement: !ruby/object:Gem::Requirement
@@ -274,14 +246,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
274
246
  requirements:
275
247
  - - ">="
276
248
  - !ruby/object:Gem::Version
277
- version: 2.7.0
249
+ version: 3.1.0
278
250
  required_rubygems_version: !ruby/object:Gem::Requirement
279
251
  requirements:
280
252
  - - ">="
281
253
  - !ruby/object:Gem::Version
282
- version: 2.7.0
254
+ version: 3.1.0
283
255
  requirements: []
284
- rubygems_version: 3.1.6
256
+ rubygems_version: 3.3.7
285
257
  signing_key:
286
258
  specification_version: 4
287
259
  summary: ".NET (NuGet) support for dependabot"