Class: Homebrew::Vulns::Match::Hit Private

Inherits:
Object
  • Object
show all
Defined in:
vulns/match.rb

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vulnerability:, evidence:) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Raises:

  • (ArgumentError)


186
187
188
189
190
191
192
193
194
# File 'vulns/match.rb', line 186

def initialize(vulnerability:, evidence:)
  raise ArgumentError, "Hit requires at least one Evidence" if evidence.empty?

  @vulnerability = vulnerability
  resolved_evidence = evidence.map { |e| e.with_source(vulnerability) }
                              .sort_by { |e| -STRATEGY_PRECISION.fetch(e.strategy) }
                              .freeze
  @evidence = T.let(resolved_evidence, T::Array[Evidence])
end

Instance Attribute Details

#evidence ⇒ Array<Evidence> (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



183
184
185
# File 'vulns/match.rb', line 183

def evidence
  @evidence
end

#vulnerability ⇒ Vulnerability (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



180
181
182
# File 'vulns/match.rb', line 180

def vulnerability
  @vulnerability
end

Instance Method Details

#canonical_id ⇒ String

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



212
213
214
# File 'vulns/match.rb', line 212

def canonical_id
  vulnerability.cve_ids.min || vulnerability.id
end

#identifiers ⇒ Array<String>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



217
218
219
# File 'vulns/match.rb', line 217

def identifiers
  (vulnerability.identifiers + evidence.flat_map { |item| item.source_record&.identifiers || [] }).uniq
end

#primary_evidence ⇒ Evidence

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



197
198
199
# File 'vulns/match.rb', line 197

def primary_evidence
  evidence.fetch(0)
end

#resource ⇒ String?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



207
208
209
# File 'vulns/match.rb', line 207

def resource
  primary_evidence.resource
end

#strategy ⇒ Symbol

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



202
203
204
# File 'vulns/match.rb', line 202

def strategy
  primary_evidence.strategy
end