dependabot-vcpkg 0.391.0 → 0.392.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f824b87bbbdcbed88c4168756096993636ff08219dacffd3260a4e5bae932156
4
- data.tar.gz: 7edab2f942a03e18d4601d7a5a6750b82b4ef934a13de4d59e1bcc3448be1b63
3
+ metadata.gz: d9adda37faba7a4ba0d78122d2b340d3abe3b66033c4629341f6ad6027aa23fb
4
+ data.tar.gz: c17e3c6abdb537d697c86d20f9defc2a78384cabcb334f77c7124c09d8f64cb8
5
5
  SHA512:
6
- metadata.gz: 5ecb1115bc51dc7978a6089ac440e9cec32345d4fb2fd6a5b779df2bbd20c2f5e3a8f242076bcc7dcfad59bcecded26efd77b54cda81f52f4a0765ac64503f42
7
- data.tar.gz: 100d4e1033cd53627cde2626964568b4e3961e29e854b3db4d85e4daf7269f6906d441b370aef860c966913030f264b12786e0c0e2f4151e6883907eb693119c
6
+ metadata.gz: 3a6431124969298347d410137b294da0fe3cfa94061fd6f1aeb625f79ebae6a89ab39d4b2c92ee9d0bcb992c987bee812007b824249d44a668f4e75aa66a0f6a
7
+ data.tar.gz: 6dae72dd089b071f0a4494c914d82ee47bb3e0656176846dd9bdb5057f7a81fe936e1fc9c4d55f7a1cfb1634f6b6688a42e05342743804d4f1f899047a48a46e
@@ -63,7 +63,7 @@ module Dependabot
63
63
  parsed_content = JSON.parse(content)
64
64
 
65
65
  dependencies
66
- .filter_map { |dep| [dep, dep.requirements.find { |r| r[:file] == file.name }] }
66
+ .filter_map { |dep| [dep, dep.requirements.find { |requirement| requirement.file == file.name }] }
67
67
  .select { |_, requirement| requirement }
68
68
  .each { |dependency, _| update_dependency_in_content(parsed_content, dependency, file.name) }
69
69
 
@@ -80,7 +80,7 @@ module Dependabot
80
80
  parsed_content = JSON.parse(content)
81
81
 
82
82
  dependencies
83
- .filter_map { |dep| [dep, dep.requirements.find { |r| r[:file] == file.name }] }
83
+ .filter_map { |dep| [dep, dep.requirements.find { |requirement| requirement.file == file.name }] }
84
84
  .select { |_, requirement| requirement }
85
85
  .each { |dependency, _| update_registry_dependency_in_content(parsed_content, dependency, file.name) }
86
86
 
@@ -120,11 +120,9 @@ module Dependabot
120
120
  params(dependency: Dependabot::Dependency, filename: String).returns(T.nilable(Symbol))
121
121
  end
122
122
  def remediation_for(dependency, filename)
123
- requirement = dependency.requirements.find { |r| r[:file] == filename }
124
- metadata = requirement&.dig(:metadata)
125
- return nil unless metadata.is_a?(Hash)
126
-
127
- metadata[:security_remediation]
123
+ dependency.requirements
124
+ .find { |requirement| requirement.file == filename }
125
+ &.metadata_symbol("security_remediation")
128
126
  end
129
127
 
130
128
  sig { params(content: T::Hash[String, T.untyped], dependency: Dependabot::Dependency).void }
@@ -185,7 +183,7 @@ module Dependabot
185
183
  def build_security_baseline
186
184
  commit_sha = dependencies
187
185
  .flat_map(&:requirements)
188
- .filter_map { |requirement| requirement.dig(:metadata, :baseline_commit_sha) }
186
+ .filter_map { |requirement| requirement.metadata_string("baseline_commit_sha") }
189
187
  .first
190
188
  return nil unless commit_sha.is_a?(String)
191
189
 
@@ -245,19 +243,17 @@ module Dependabot
245
243
  .returns(T.nilable(T::Hash[String, String]))
246
244
  end
247
245
  def build_default_registry(dependency, filename)
248
- requirement = dependency.requirements.find { |r| r[:file] == filename }
246
+ requirement = dependency.requirements.find { |candidate| candidate.file == filename }
249
247
  return unless requirement
250
248
 
251
- case requirement[:source]
252
- in { ref: String => baseline }
253
- {
254
- "kind" => "git",
255
- "repository" => VCPKG_DEFAULT_REGISTRY_REPOSITORY,
256
- "baseline" => baseline
257
- }
258
- else
259
- nil
260
- end
249
+ baseline = requirement.source_string("ref")
250
+ return unless baseline
251
+
252
+ {
253
+ "kind" => "git",
254
+ "repository" => VCPKG_DEFAULT_REGISTRY_REPOSITORY,
255
+ "baseline" => baseline
256
+ }
261
257
  end
262
258
 
263
259
  sig { params(content: T::Hash[String, T.untyped], dependency: Dependabot::Dependency, filename: String).void }
@@ -282,16 +278,12 @@ module Dependabot
282
278
  end
283
279
  def update_baseline_field(target, dependency, filename, field_name)
284
280
  # Find the requirement for this specific file
285
- requirement = dependency.requirements.find { |r| r[:file] == filename }
281
+ requirement = dependency.requirements.find { |candidate| candidate.file == filename }
286
282
  return unless requirement
287
283
 
288
284
  # Extract and validate the new baseline
289
- case requirement[:source]
290
- in { ref: String => new_baseline }
291
- target[field_name] = new_baseline
292
- else
293
- # Skip if source doesn't have the expected structure
294
- end
285
+ new_baseline = requirement.source_string("ref")
286
+ target[field_name] = new_baseline if new_baseline
295
287
  end
296
288
 
297
289
  sig do
@@ -307,7 +299,7 @@ module Dependabot
307
299
  registries.find { |r| r.is_a?(Hash) && r["kind"] == "builtin" }
308
300
  else
309
301
  # For git registries, find by repository URL
310
- repository_url = dependency.requirements.first&.dig(:source, :url)
302
+ repository_url = dependency.requirements.first&.source_string("url")
311
303
  registries.find { |r| r.is_a?(Hash) && r["repository"] == repository_url }
312
304
  end
313
305
  end
@@ -1,8 +1,9 @@
1
- # typed: strict
1
+ # typed: strong
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "dependabot/metadata_finders"
5
5
  require "dependabot/metadata_finders/base"
6
+ require "dependabot/vcpkg"
6
7
 
7
8
  module Dependabot
8
9
  module Vcpkg
@@ -29,14 +30,8 @@ module Dependabot
29
30
  sig { override.returns(T.nilable(Dependabot::Source)) }
30
31
  def look_up_source
31
32
  # Check if this is a Git dependency with a specific source
32
- info = dependency.requirements.filter_map { |r| r[:source] }.first
33
-
34
- url =
35
- if info.nil?
36
- VCPKG_DEFAULT_BASELINE_URL
37
- else
38
- info[:url] || info.fetch("url", VCPKG_DEFAULT_BASELINE_URL)
39
- end
33
+ requirement = dependency.requirements.find(&:source_hash)
34
+ url = requirement&.source_string("url") || VCPKG_DEFAULT_BASELINE_URL
40
35
  Source.from_url(url)
41
36
  end
42
37
 
@@ -1,4 +1,4 @@
1
- # typed: strict
1
+ # typed: strong
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "sorbet-runtime"
@@ -253,8 +253,8 @@ module Dependabot
253
253
  def declared_constraint_version
254
254
  return @declared_constraint_version if @declared_constraint_version
255
255
 
256
- constraint = dependency.requirements.filter_map { |req| req[:requirement] }.first
257
- return nil unless constraint.is_a?(String)
256
+ constraint = dependency.requirements.filter_map(&:requirement_string).first
257
+ return nil unless constraint
258
258
 
259
259
  text = constraint.delete_prefix(">=").strip
260
260
  return nil unless Dependabot::Vcpkg::Version.correct?(text)
@@ -1,4 +1,4 @@
1
- # typed: strict
1
+ # typed: strong
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "sorbet-runtime"
@@ -63,27 +63,33 @@ module Dependabot
63
63
  sig { override.returns(T::Array[Dependabot::DependencyRequirement]) }
64
64
  def updated_requirements
65
65
  fix = security_fix
66
- return wrap_requirements(security_updated_requirements(fix)) if fix
66
+ return security_updated_requirements(fix) if fix
67
67
  return dependency.requirements unless latest_version
68
68
 
69
- wrap_requirements(dependency.requirements.map { |requirement| updated_requirement(requirement) })
69
+ dependency.requirements.map { |requirement| updated_requirement(requirement) }
70
70
  end
71
71
 
72
72
  private
73
73
 
74
74
  sig do
75
- params(requirement: T::Hash[Symbol, T.anything]).returns(T::Hash[Symbol, T.anything])
75
+ params(requirement: Dependabot::DependencyRequirement)
76
+ .returns(Dependabot::DependencyRequirement)
76
77
  end
77
78
  def updated_requirement(requirement)
78
- source = T.cast(requirement[:source], T.nilable(T::Hash[Symbol, T.anything]))
79
+ source = requirement.source_hash
79
80
 
80
81
  if source && registry_dependency?
81
82
  # For git dependencies (baselines), update the git ref with the commit SHA
82
- latest_commit_sha = latest_version_finder.latest_release_info&.details&.dig("commit_sha")
83
- requirement.merge(source: source.merge(ref: latest_commit_sha))
84
- elsif source.nil? && requirement[:requirement]
83
+ latest_commit_sha = T.cast(
84
+ latest_version_finder.latest_release_info&.details&.dig("commit_sha"),
85
+ T.nilable(String)
86
+ )
87
+ requirement.source_string("ref")
88
+ updated_source = hash_with_value(source, "ref", latest_commit_sha)
89
+ Dependabot::DependencyRequirement.create(requirement.merge(source: updated_source))
90
+ elsif source.nil? && requirement.requirement
85
91
  # For port dependencies (no source but has requirement), update the version constraint
86
- requirement.merge(requirement: ">=#{latest_version}")
92
+ Dependabot::DependencyRequirement.create(requirement.merge(requirement: ">=#{latest_version}"))
87
93
  else
88
94
  # Keep the original requirement unchanged for other cases
89
95
  requirement
@@ -93,24 +99,49 @@ module Dependabot
93
99
  # Describes the manifest edit that fixes the advisory, so the file updater can apply it
94
100
  # without repeating the resolution.
95
101
  sig do
96
- params(fix: SecurityFixResolver::Fix).returns(T::Array[T::Hash[Symbol, T.anything]])
102
+ params(fix: SecurityFixResolver::Fix)
103
+ .returns(T::Array[Dependabot::DependencyRequirement])
97
104
  end
98
105
  def security_updated_requirements(fix)
99
106
  dependency.requirements.map do |requirement|
100
- metadata = T.cast(requirement[:metadata], T.nilable(T::Hash[Symbol, T.untyped])) || {}
101
- updated = requirement.merge(
102
- metadata: metadata.merge(
103
- security_remediation: fix.kind,
104
- security_version: fix.version.to_s,
105
- baseline_commit_sha: fix.baseline_commit_sha,
106
- baseline_tag: fix.baseline_tag
107
- )
107
+ metadata = T.let(
108
+ requirement.metadata || {},
109
+ Dependabot::DependencyRequirement::ObjectHash
108
110
  )
111
+ metadata = hash_with_value(metadata, "security_remediation", fix.kind)
112
+ metadata = hash_with_value(metadata, "security_version", fix.version.to_s)
113
+ metadata = hash_with_value(metadata, "baseline_commit_sha", fix.baseline_commit_sha)
114
+ metadata = hash_with_value(metadata, "baseline_tag", fix.baseline_tag)
115
+
116
+ updated = Dependabot::DependencyRequirement.create(requirement.merge(metadata: metadata))
117
+ next updated unless fix.kind == :version_constraint
109
118
 
110
- fix.kind == :version_constraint ? updated.merge(requirement: ">=#{fix.version}") : updated
119
+ Dependabot::DependencyRequirement.create(updated.merge(requirement: ">=#{fix.version}"))
111
120
  end
112
121
  end
113
122
 
123
+ sig do
124
+ params(
125
+ details: Dependabot::DependencyRequirement::ObjectHash,
126
+ key: String,
127
+ value: Object
128
+ ).returns(Dependabot::DependencyRequirement::ObjectHash)
129
+ end
130
+ def hash_with_value(details, key, value)
131
+ updated = details.dup
132
+ actual_key = if details.key?(key.to_sym)
133
+ key.to_sym
134
+ elsif details.key?(key)
135
+ key
136
+ elsif details.empty? || details.keys.any?(Symbol)
137
+ key.to_sym
138
+ else
139
+ key
140
+ end
141
+ updated[actual_key] = value
142
+ updated
143
+ end
144
+
114
145
  sig { returns(T.nilable(SecurityFixResolver::Fix)) }
115
146
  def security_fix
116
147
  return @security_fix if @searched_for_security_fix
@@ -134,13 +165,13 @@ module Dependabot
134
165
 
135
166
  sig { returns(T::Boolean) }
136
167
  def registry_dependency?
137
- dependency.source_details(allowed_types: ["git"]) in { type: "git" }
168
+ dependency.source_string("type", allowed_types: ["git"]) == "git"
138
169
  end
139
170
 
140
171
  sig { returns(T::Boolean) }
141
172
  def port_dependency?
142
173
  # A port dependency has no git source but has a requirement constraint
143
- !registry_dependency? && dependency.requirements.any? { |req| req[:requirement] }
174
+ !registry_dependency? && dependency.requirements.any?(&:requirement)
144
175
  end
145
176
 
146
177
  # A port whose version comes solely from the registry baseline.
@@ -149,7 +180,7 @@ module Dependabot
149
180
  return false if registry_dependency?
150
181
  return false unless dependency.numeric_version
151
182
 
152
- dependency.requirements.none? { |requirement| requirement[:requirement] }
183
+ dependency.requirements.none?(&:requirement)
153
184
  end
154
185
 
155
186
  # `latest_version` may be a version vcpkg cannot order against the current one, which is
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-vcpkg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.391.0
4
+ version: 0.392.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.391.0
18
+ version: 0.392.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.391.0
25
+ version: 0.392.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: debug
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -259,7 +259,7 @@ licenses:
259
259
  - MIT
260
260
  metadata:
261
261
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
262
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.391.0
262
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.392.0
263
263
  rdoc_options: []
264
264
  require_paths:
265
265
  - lib