Class: Dependabot::UpdateCheckers::VulnerabilityAudit

Inherits:
T::ImmutableStruct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/update_checkers/vulnerability_audit.rb

Defined Under Namespace

Classes: BlockingDependency, FixUpdate

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_object(value) ⇒ Object



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/dependabot/update_checkers/vulnerability_audit.rb', line 176

def self.from_object(value)
  hash = ValueParser.object_hash(value, "audit result")
  current_version_provided = hash.key?("current_version")
  target_version_provided = hash.key?("target_version")
  blocking_dependencies_provided = hash.key?("blocking_dependencies")

  new(
    dependency_name: ValueParser.string(hash, "dependency_name"),
    current_version: ValueParser.optional_string(hash, "current_version"),
    current_version_provided: current_version_provided,
    target_version: ValueParser.optional_string(hash, "target_version"),
    target_version_provided: target_version_provided,
    fix_available: ValueParser.boolean(hash, "fix_available"),
    fix_updates: parse_fix_updates(hash["fix_updates"]),
    top_level_ancestors: ValueParser.string_array(hash["top_level_ancestors"], "top_level_ancestors"),
    blocking_dependencies: parse_blocking_dependencies(hash["blocking_dependencies"]),
    blocking_dependencies_provided: blocking_dependencies_provided
  )
end

.unavailable(dependency_name:, explanation: nil, blocking_dependencies: nil, blocking_dependencies_provided: false) ⇒ Object



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/dependabot/update_checkers/vulnerability_audit.rb', line 204

def self.unavailable(
  dependency_name:,
  explanation: nil,
  blocking_dependencies: nil,
  blocking_dependencies_provided: false
)
  new(
    dependency_name: dependency_name,
    fix_available: false,
    fix_updates: [],
    top_level_ancestors: [],
    blocking_dependencies: blocking_dependencies,
    blocking_dependencies_provided: blocking_dependencies_provided,
    explanation: explanation
  )
end

Instance Method Details

#blocking_dependencies_provided?Boolean

Returns:

  • (Boolean)


232
233
234
# File 'lib/dependabot/update_checkers/vulnerability_audit.rb', line 232

def blocking_dependencies_provided?
  blocking_dependencies_provided
end

#current_version_provided?Boolean

Returns:

  • (Boolean)


222
223
224
# File 'lib/dependabot/update_checkers/vulnerability_audit.rb', line 222

def current_version_provided?
  current_version_provided
end

#target_version_provided?Boolean

Returns:

  • (Boolean)


227
228
229
# File 'lib/dependabot/update_checkers/vulnerability_audit.rb', line 227

def target_version_provided?
  target_version_provided
end

#to_hObject



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/dependabot/update_checkers/vulnerability_audit.rb', line 247

def to_h
  result = T.let(
    {
      "dependency_name" => dependency_name,
      "fix_available" => fix_available,
      "fix_updates" => fix_updates.map(&:to_h),
      "top_level_ancestors" => top_level_ancestors
    },
    Conflict
  )
  result["current_version"] = current_version if current_version_provided?
  result["target_version"] = target_version if target_version_provided?
  result["blocking_dependencies"] = blocking_dependencies&.map(&:to_h) if blocking_dependencies_provided?
  result["explanation"] = explanation if explanation
  result
end

#unavailable_with_explanation(message) ⇒ Object



237
238
239
240
241
242
243
244
# File 'lib/dependabot/update_checkers/vulnerability_audit.rb', line 237

def unavailable_with_explanation(message)
  VulnerabilityAudit.unavailable(
    dependency_name: dependency_name,
    explanation: message,
    blocking_dependencies: blocking_dependencies,
    blocking_dependencies_provided: blocking_dependencies_provided?
  )
end