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)


83
84
85
86
87
88
89
90
91
92
# File 'vulns/match.rb', line 83

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

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

Instance Attribute Details

#evidenceArray<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:



80
81
82
# File 'vulns/match.rb', line 80

def evidence
  @evidence
end

#vulnerabilityVulnerability (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:



77
78
79
# File 'vulns/match.rb', line 77

def vulnerability
  @vulnerability
end

Instance Method Details

#canonical_idString

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:



110
111
112
# File 'vulns/match.rb', line 110

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

#identifiersArray<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:



115
116
117
118
119
# File 'vulns/match.rb', line 115

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

#primary_evidenceEvidence

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:



95
96
97
# File 'vulns/match.rb', line 95

def primary_evidence
  evidence.fetch(0)
end

#resourceString?

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:



105
106
107
# File 'vulns/match.rb', line 105

def resource
  primary_evidence.resource
end

#strategySymbol

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:



100
101
102
# File 'vulns/match.rb', line 100

def strategy
  primary_evidence.strategy
end