Class: Homebrew::DevCmd::AdvisoryMatch::Emitter Private
- 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
Instance Method Summary collapse
- #alias_protected?(_record_id) ⇒ Boolean private
- #emit(record, revalidated: false, initial_introduction: false) ⇒ void private
- #finish ⇒ void private
- #fixed_boundary_valid?(_record_id, _boundary) ⇒ Boolean private
- #history_required?(_record_id) ⇒ Boolean private
- #prepare_aliases(_formula_name, _groups) ⇒ Array<String> private
-
#range_basis(record) ⇒ Hash{String => T.untyped}
private
Keep every strategy and runtime subject.
- #range_basis_changed?(_record) ⇒ Boolean private
- #record_history_unavailable(_formula_name) ⇒ void private
- #record_history_walk ⇒ void private
- #reintroduction_boundary_valid?(_record_id, _boundary) ⇒ Boolean private
- #reviewed_range_state(_record_id) ⇒ Symbol? private
- #subject_identity(evidence) ⇒ Array<String> private
- #unversioned_key(key) ⇒ String private
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.
594 |
# File 'dev-cmd/advisory-match.rb', line 594 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.
675 |
# File 'dev-cmd/advisory-match.rb', line 675 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.
678 |
# File 'dev-cmd/advisory-match.rb', line 678 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.
658 |
# File 'dev-cmd/advisory-match.rb', line 658 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.
655 |
# File 'dev-cmd/advisory-match.rb', line 655 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.
591 |
# File 'dev-cmd/advisory-match.rb', line 591 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.
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 |
# File 'dev-cmd/advisory-match.rb', line 600 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.
652 |
# File 'dev-cmd/advisory-match.rb', line 652 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.
664 |
# File 'dev-cmd/advisory-match.rb', line 664 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.
661 |
# File 'dev-cmd/advisory-match.rb', line 661 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.
670 |
# File 'dev-cmd/advisory-match.rb', line 670 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.
667 |
# File 'dev-cmd/advisory-match.rb', line 667 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.
636 637 638 639 640 641 642 643 |
# File 'dev-cmd/advisory-match.rb', line 636 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.
646 647 648 649 |
# File 'dev-cmd/advisory-match.rb', line 646 def unversioned_key(key) key = key.delete_prefix("upstream:") key.start_with?("pkg:") ? key.sub(%r{@[^/@]*\z}, "") : key end |