Class: Homebrew::DevCmd::AdvisoryMatch::Emitter Private

Inherits:
Object
  • Object
show all
Defined in:
dev-cmd/advisory-match.rb

Overview

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.

--output and text mode write per-record and only accumulate counts; --json accumulates the array (single-formula / PR-bot use, so bounded).

Direct Known Subclasses

CountEmitter, DirEmitter, JsonEmitter

Instance Method Summary collapse

Instance Method Details

#alias_protected?(_record_id) ⇒ Boolean

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:

Returns:

  • (Boolean)


604
# File 'dev-cmd/advisory-match.rb', line 604

def alias_protected?(_record_id) = false

#emit(record, revalidated: false, initial_introduction: false) ⇒ 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.

This method returns an undefined value.

Parameters:

  • record (Hash{Symbol => T.untyped})
  • revalidated (Boolean) (defaults to: false)
  • initial_introduction (Boolean) (defaults to: false)


685
# File 'dev-cmd/advisory-match.rb', line 685

def emit(record, revalidated: false, initial_introduction: false); end

#finish ⇒ 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.

This method returns an undefined value.



688
# File 'dev-cmd/advisory-match.rb', line 688

def finish; end

#fixed_boundary_valid?(_record_id, _boundary) ⇒ Boolean

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:

Returns:

  • (Boolean)


668
# File 'dev-cmd/advisory-match.rb', line 668

def fixed_boundary_valid?(_record_id, _boundary) = true

#history_required?(_record_id) ⇒ Boolean

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:

Returns:

  • (Boolean)


665
# File 'dev-cmd/advisory-match.rb', line 665

def history_required?(_record_id) = true

#prepare_aliases(_formula_name, _groups) ⇒ 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.

Parameters:

Returns:



601
# File 'dev-cmd/advisory-match.rb', line 601

def prepare_aliases(_formula_name, _groups) = []

#range_basis(record) ⇒ Hash{String => T.untyped}

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.

Keep every strategy and runtime subject. Ignore version values and resource labels, but retain checkability and separate copies of the same resource package: either can change the aggregate history.

Parameters:

  • record (Hash{T.untyped => T.untyped})

Returns:



610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
# File 'dev-cmd/advisory-match.rb', line 610

def range_basis(record)
  record = JSON.parse(JSON.generate(record))
  affected = record["affected"]
  return {} unless affected.is_a?(Array)
  return {} unless affected.one?

  entry = affected.fetch(0)
  return {} unless entry.is_a?(Hash)

  ecosystem_specific = entry["ecosystem_specific"]
  ecosystem_specific = {} unless ecosystem_specific.is_a?(Hash)

  database_specific = record["database_specific"]
  evidence = Array(database_specific["upstream_evidence"]) if database_specific.is_a?(Hash)
  evidence = Array(evidence).grep(Hash)
  subjects = evidence.group_by { |row| row["resource"] }.map do |resource, rows|
    identities = rows.filter_map do |row|
      identity = subject_identity(row)
      next if identity.empty?

      [row["strategy"].to_s, identity, row["subject_version"].nil? ? "unknown" : "versioned"]
    end
    [resource ? "resource" : "primary", identities.uniq.sort]
  end
  basis = { "subjects" => subjects.sort }
  resource_purl = ecosystem_specific["resource_purl"]
  if resource_purl.is_a?(String)
    resource = evidence.find { |row| row["resource"] && row["key"] == resource_purl }
    basis["resource_purl"] = resource ? subject_identity(resource) : [unversioned_key(resource_purl)]
  end
  upstream_fixed_in = ecosystem_specific["upstream_fixed_in"]
  basis["upstream_fixed_in"] = upstream_fixed_in if upstream_fixed_in.is_a?(String)
  basis
end

#range_basis_changed?(_record) ⇒ Boolean

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:

Returns:

  • (Boolean)


662
# File 'dev-cmd/advisory-match.rb', line 662

def range_basis_changed?(_record) = false

#record_history_unavailable(_formula_name) ⇒ 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.

This method returns an undefined value.

Parameters:



674
# File 'dev-cmd/advisory-match.rb', line 674

def record_history_unavailable(_formula_name); end

#record_history_walk ⇒ 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.

This method returns an undefined value.



671
# File 'dev-cmd/advisory-match.rb', line 671

def record_history_walk; end

#reintroduction_boundary_valid?(_record_id, _boundary) ⇒ Boolean

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:

Returns:

  • (Boolean)


680
# File 'dev-cmd/advisory-match.rb', line 680

def reintroduction_boundary_valid?(_record_id, _boundary) = true

#reviewed_range_state(_record_id) ⇒ 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.

Parameters:

Returns:



677
# File 'dev-cmd/advisory-match.rb', line 677

def reviewed_range_state(_record_id); end

#subject_identity(evidence) ⇒ 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.

Parameters:

Returns:



646
647
648
649
650
651
652
653
# File 'dev-cmd/advisory-match.rb', line 646

def subject_identity(evidence)
  ecosystem = evidence["ecosystem"]
  name = evidence["name"]
  return [ecosystem, name] if ecosystem.is_a?(String) && name.is_a?(String)

  key = evidence["key"]
  key.is_a?(String) ? [unversioned_key(key)] : []
end

#unversioned_key(key) ⇒ 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.

Parameters:

Returns:



656
657
658
659
# File 'dev-cmd/advisory-match.rb', line 656

def unversioned_key(key)
  key = key.delete_prefix("upstream:")
  key.start_with?("pkg:") ? key.sub(%r{@[^/@]*\z}, "") : key
end