Class: Homebrew::Vulns::Vulnerability Private
- Includes:
- Utils::Output::Mixin
- Defined in:
- vulns/vulnerability.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.
Wraps a single OSV vulnerability record. See https://ossf.github.io/osv-schema/ for the field definitions.
Defined Under Namespace
Classes: Interval, RangeStatus, Uncomparable
Instance Attribute Summary collapse
- #affected ⇒ Array<Hash{String => T.untyped}> readonly private
- #aliases ⇒ Array<String> readonly private
- #details ⇒ String? readonly private
- #id ⇒ String readonly private
- #references ⇒ Array<Hash{String => T.untyped}> readonly private
- #related ⇒ Array<String> readonly private
- #severity ⇒ Symbol? readonly private
- #severity_entries ⇒ Array<Hash{String => T.untyped}> readonly private
- #summary ⇒ String? readonly private
- #upstream ⇒ Array<String> readonly private
Class Method Summary collapse
Instance Method Summary collapse
- #advisory_url ⇒ String? private
- #affected_entries_for(ecosystem, name) ⇒ Array<Hash{String => T.untyped}> private
- #affected_entry_relevant?(aff, repo_url) ⇒ Boolean private
-
#affects_version?(version) ⇒ Boolean
private
OSV has already matched this record against the queried version.
- #comparator_for(range_type) ⇒ T.proc.params(a: String, b: String).returns(Integer) private
- #cve_ids ⇒ Array<String> private
- #extract_severity(data) ⇒ Symbol? private
- #fix_available?(version, repo_url = nil) ⇒ Boolean private
- #fix_available_of_type?(version, repo_url, fix_type) ⇒ Boolean private
- #fix_urls ⇒ Array<String> private
- #fixed_versions ⇒ Array<String> private
-
#identifiers ⇒ Array<String>
private
Only
idandaliasesname this vulnerability. - #in_interval?(target, lower, upper, upper_inclusive, cmp) ⇒ Boolean private
- #in_interval_permissive?(target, interval) ⇒ Boolean private
- #in_interval_strict?(target, interval) ⇒ Boolean? private
- #in_semver_range?(target, events) ⇒ Boolean private
- #initialize(data) ⇒ void constructor private
- #intervals(events) ⇒ Array<Interval> private
- #non_semver_fix_available_of_type?(target, range, fix_type) ⇒ Boolean private
- #normalize_severity(value) ⇒ Symbol? private
- #normalize_version(version) ⇒ String private
- #patch_fix_available?(version, repo_url = nil) ⇒ Boolean private
-
#range_status(ecosystem, name, version) ⇒ RangeStatus?
private
Evaluates
versionagainst everyaffected[]entry whosepackagematches{ecosystem, name}(an advisory can carry several disjoint entries for the same package, e.g. GHSA-jfh8-c2jp-5v3q's three log4j-core ranges), honouring rangetype:. - #released_fix_available?(version, repo_url = nil) ⇒ Boolean private
- #same_boundary?(left, right, cmp) ⇒ Boolean private
- #semver_compare!(left, right) ⇒ Integer private
- #severity_display ⇒ String private
- #severity_level ⇒ Integer private
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Constructor Details
#initialize(data) ⇒ 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.
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'vulns/vulnerability.rb', line 54 def initialize(data) @id = T.let(data.fetch("id"), String) @summary = T.let(data["summary"], T.nilable(String)) @details = T.let(data["details"], T.nilable(String)) @aliases = T.let(Array(data["aliases"]), T::Array[String]) @upstream = T.let(Array(data["upstream"]), T::Array[String]) @related = T.let(Array(data["related"]), T::Array[String]) @references = T.let(Array(data["references"]), T::Array[T::Hash[String, T.untyped]]) @affected = T.let(Array(data["affected"]), T::Array[T::Hash[String, T.untyped]]) @severity_entries = T.let(Array(data["severity"]), T::Array[T::Hash[String, T.untyped]]) @severity = T.let(extract_severity(data), T.nilable(Symbol)) end |
Instance Attribute Details
#affected ⇒ Array<Hash{String => T.untyped}> (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.
51 52 53 |
# File 'vulns/vulnerability.rb', line 51 def affected @affected end |
#aliases ⇒ Array<String> (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.
48 49 50 |
# File 'vulns/vulnerability.rb', line 48 def aliases @aliases end |
#details ⇒ String? (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.
42 43 44 |
# File 'vulns/vulnerability.rb', line 42 def details @details end |
#id ⇒ String (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.
39 40 41 |
# File 'vulns/vulnerability.rb', line 39 def id @id end |
#references ⇒ Array<Hash{String => T.untyped}> (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.
51 52 53 |
# File 'vulns/vulnerability.rb', line 51 def references @references end |
#related ⇒ Array<String> (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.
48 49 50 |
# File 'vulns/vulnerability.rb', line 48 def @related end |
#severity ⇒ Symbol? (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.
45 46 47 |
# File 'vulns/vulnerability.rb', line 45 def severity @severity end |
#severity_entries ⇒ Array<Hash{String => T.untyped}> (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.
51 52 53 |
# File 'vulns/vulnerability.rb', line 51 def severity_entries @severity_entries end |
#summary ⇒ String? (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.
42 43 44 |
# File 'vulns/vulnerability.rb', line 42 def summary @summary end |
#upstream ⇒ Array<String> (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.
48 49 50 |
# File 'vulns/vulnerability.rb', line 48 def upstream @upstream end |
Class Method Details
.from_osv_list(list) ⇒ Array<Vulnerability>
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.
68 69 70 |
# File 'vulns/vulnerability.rb', line 68 def self.from_osv_list(list) list.map { |data| new(data) } end |
Instance Method Details
#advisory_url ⇒ 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.
101 102 103 |
# File 'vulns/vulnerability.rb', line 101 def advisory_url references.find { |r| r["type"] == "ADVISORY" }&.dig("url") end |
#affected_entries_for(ecosystem, name) ⇒ Array<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.
220 221 222 223 224 225 |
# File 'vulns/vulnerability.rb', line 220 def affected_entries_for(ecosystem, name) affected.select do |aff| pkg = aff["package"] pkg.is_a?(Hash) && pkg["ecosystem"] == ecosystem && pkg["name"] == name end end |
#affected_entry_relevant?(aff, repo_url) ⇒ 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.
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
# File 'vulns/vulnerability.rb', line 430 def affected_entry_relevant?(aff, repo_url) return true if repo_url.nil? git_ranges = Array(aff["ranges"]).select { |r| r["type"] == "GIT" } if git_ranges.any? normalized_repo = repo_url.downcase.chomp("/").delete_suffix(".git").chomp("/") return git_ranges.any? do |r| range_repo = r["repo"].to_s.downcase.chomp("/").delete_suffix(".git").chomp("/") range_repo.empty? || range_repo == normalized_repo end end # For entries without GIT ranges (e.g. SEMVER ranges or version lists), # check that the package ecosystem is GIT or unspecified. ecosystem = aff.dig("package", "ecosystem") ecosystem.blank? || ecosystem == "GIT" end |
#affects_version?(version) ⇒ 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.
OSV has already matched this record against the queried version. This
method only overrides that with false when every affected entry can
be evaluated locally (explicit versions list or SEMVER range) and
none of them contains the target. Any uncheckable range or comparison
failure keeps the match.
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'vulns/vulnerability.rb', line 259 def affects_version?(version) return true if affected.empty? target = normalize_version(version) checkable = T.let(false, T::Boolean) affected.each do |aff| versions = Array(aff["versions"]) if versions.any? checkable = true return true if versions.any? { |v| normalize_version(v.to_s) == target } end Array(aff["ranges"]).each do |range| return true if range["type"] != "SEMVER" checkable = true return true if in_semver_range?(target, Array(range["events"])) end end !checkable end |
#comparator_for(range_type) ⇒ T.proc.params(a: String, b: String).returns(Integer)
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.
228 229 230 231 232 233 234 |
# File 'vulns/vulnerability.rb', line 228 def comparator_for(range_type) if range_type == "SEMVER" ->(a, b) { Semver.compare(a, b) || raise(Uncomparable) } else ->(a, b) { Version.new(a) <=> Version.new(b) || raise(Uncomparable) } end end |
#cve_ids ⇒ 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.
96 97 98 |
# File 'vulns/vulnerability.rb', line 96 def cve_ids identifiers.select { |i| i.start_with?("CVE-") } end |
#extract_severity(data) ⇒ 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.
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'vulns/vulnerability.rb', line 284 def extract_severity(data) Array(data["severity"]) .select { |s| CVSS_TYPE_PRIORITY.key?(s["type"]) } .sort_by { |s| -CVSS_TYPE_PRIORITY.fetch(s["type"]) } .each do |s| sev = CVSS.severity(s["score"].to_s) return sev if sev end top = normalize_severity(data.dig("database_specific", "severity")) return top if top affected.each do |aff| eco = normalize_severity(aff.dig("ecosystem_specific", "severity")) return eco if eco db = normalize_severity(aff.dig("database_specific", "severity")) return db if db end nil end |
#fix_available?(version, repo_url = nil) ⇒ 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.
449 450 451 |
# File 'vulns/vulnerability.rb', line 449 def fix_available?(version, repo_url = nil) fix_available_of_type?(version, repo_url, :any) end |
#fix_available_of_type?(version, repo_url, fix_type) ⇒ 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.
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
# File 'vulns/vulnerability.rb', line 464 def fix_available_of_type?(version, repo_url, fix_type) return false if affected.empty? target = normalize_version(version) affected.each do |aff| next unless affected_entry_relevant?(aff, repo_url) version_matched = false ranges = Array(aff["ranges"]) semver_ranges, non_semver_ranges = ranges.partition { |r| r["type"] == "SEMVER" } versions = Array(aff["versions"]) version_matched = true if versions.any? { |v| normalize_version(v.to_s) == target } version_matched = true if non_semver_ranges.any? matched_semver_range = T.let(false, T::Boolean) fix_found = T.let(false, T::Boolean) semver_ranges.each do |range| intervals(Array(range["events"])).each do |interval| result = in_interval_strict?(target, interval) next if result.nil? next unless result matched_semver_range = true fix = interval.fix next if fix.blank? fix_found = true if fix_type != :patch end end version_matched ||= matched_semver_range next unless version_matched return true if fix_found non_semver_ranges.each do |range| return true if non_semver_fix_available_of_type?(target, range, fix_type) end end false end |
#fix_urls ⇒ 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.
106 107 108 |
# File 'vulns/vulnerability.rb', line 106 def fix_urls references.select { |r| r["type"] == "FIX" }.filter_map { |r| r["url"] } end |
#fixed_versions ⇒ 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.
111 112 113 114 115 116 117 |
# File 'vulns/vulnerability.rb', line 111 def fixed_versions affected.flat_map do |aff| Array(aff["ranges"]).flat_map do |range| Array(range["events"]).filter_map { |e| e["fixed"] } end end.uniq 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.
Only id and aliases name this vulnerability. upstream is a
directed reference (a distro advisory pointing at one-or-more source
CVEs) and related links to different vulnerabilities; neither is safe
to treat as an identity of this record. Match follows upstream
explicitly and re-attributes the hit to each CVE it names.
91 92 93 |
# File 'vulns/vulnerability.rb', line 91 def identifiers [id, *aliases].uniq end |
#in_interval?(target, lower, upper, upper_inclusive, cmp) ⇒ 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.
241 242 243 244 245 246 247 248 249 250 251 |
# File 'vulns/vulnerability.rb', line 241 def in_interval?(target, lower, upper, upper_inclusive, cmp) above = lower.nil? || cmp.call(target, lower) >= 0 below = if upper.nil? true elsif upper_inclusive cmp.call(target, upper) <= 0 else cmp.call(target, upper).negative? end above && below end |
#in_interval_permissive?(target, interval) ⇒ 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.
350 351 352 353 354 355 |
# File 'vulns/vulnerability.rb', line 350 def in_interval_permissive?(target, interval) in_interval_strict?(target, interval) != false rescue => e odebug "Failed to check #{target} against interval #{interval.inspect} for #{id}: #{e}" true end |
#in_interval_strict?(target, interval) ⇒ 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.
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'vulns/vulnerability.rb', line 333 def in_interval_strict?(target, interval) lower = interval.lower upper = interval.upper above = lower.nil? || semver_compare!(target, lower) >= 0 below = if upper.nil? true elsif interval.upper_inclusive semver_compare!(target, upper) <= 0 else semver_compare!(target, upper).negative? end above && below rescue Uncomparable nil end |
#in_semver_range?(target, events) ⇒ 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.
326 327 328 329 330 |
# File 'vulns/vulnerability.rb', line 326 def in_semver_range?(target, events) return false if events.empty? intervals(events).any? { |interval| in_interval_permissive?(target, interval) } end |
#intervals(events) ⇒ Array<Interval>
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.
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File 'vulns/vulnerability.rb', line 366 def intervals(events) result = [] lower = T.let(nil, T.nilable(String)) events.each do |event| if (intro = event["introduced"]) result << Interval.new(lower: lower, upper: nil, upper_inclusive: false, fix: nil) if lower intro = normalize_version(intro.to_s) lower = (intro == "0") ? nil : intro elsif (fixed = event["fixed"]) fixed_norm = normalize_version(fixed.to_s) result << Interval.new(lower: lower, upper: fixed_norm, upper_inclusive: false, fix: fixed_norm) lower = nil elsif (last = event["last_affected"]) last_norm = normalize_version(last.to_s) result << Interval.new(lower: lower, upper: last_norm, upper_inclusive: true, fix: nil) lower = nil elsif (limit = event["limit"]) limit = limit.to_s upper = (limit == "*") ? nil : normalize_version(limit) result << Interval.new(lower: lower, upper: upper, upper_inclusive: false, fix: nil) lower = nil end end result << Interval.new(lower: lower, upper: nil, upper_inclusive: false, fix: nil) if lower || result.empty? result end |
#non_semver_fix_available_of_type?(target, range, fix_type) ⇒ 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.
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'vulns/vulnerability.rb', line 395 def non_semver_fix_available_of_type?(target, range, fix_type) events = Array(range["events"]) return false if events.empty? is_git = range["type"] == "GIT" range_intervals = intervals(events) uncomparable_seen = T.let(false, T::Boolean) range_intervals.each do |interval| result = in_interval_strict?(target, interval) if result.nil? uncomparable_seen = true next end next unless result fix = interval.fix return false if fix.blank? return (fix_type == :patch && is_git) || (fix_type == :released && !is_git) || fix_type == :any end return false unless uncomparable_seen last_event = events.last return false if last_event.nil? return false unless last_event.key?("fixed") fix = last_event["fixed"].to_s return false if fix.blank? (fix_type == :patch && is_git) || (fix_type == :released && !is_git) || fix_type == :any end |
#normalize_severity(value) ⇒ 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.
308 309 310 311 312 313 314 315 |
# File 'vulns/vulnerability.rb', line 308 def normalize_severity(value) case value&.downcase when "critical" then :critical when "high" then :high when "medium", "moderate" then :medium when "low" then :low end end |
#normalize_version(version) ⇒ 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.
318 319 320 |
# File 'vulns/vulnerability.rb', line 318 def normalize_version(version) version.sub(/\Av/i, "") end |
#patch_fix_available?(version, repo_url = nil) ⇒ 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.
459 460 461 |
# File 'vulns/vulnerability.rb', line 459 def patch_fix_available?(version, repo_url = nil) fix_available_of_type?(version, repo_url, :patch) end |
#range_status(ecosystem, name, version) ⇒ RangeStatus?
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.
Evaluates version against every affected[] entry whose package
matches {ecosystem, name} (an advisory can carry several disjoint
entries for the same package, e.g. GHSA-jfh8-c2jp-5v3q's three
log4j-core ranges), honouring range type:
SEMVERranges compare with Semver.ECOSYSTEMranges compare with Version (best-effort; the record's own ecosystem defines the ordering, but callers only invoke this for ecosystems whose versions are broadlyVersion-comparable).GITranges are commit hashes and are skipped as uncomparable.
Returns nil when no entry matches the package or no comparable range
exists in the matching entries, so callers can distinguish
:not_applicable/:fixed from "could not check".
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'vulns/vulnerability.rb', line 149 def range_status(ecosystem, name, version) entries = affected_entries_for(ecosystem, name) return if entries.empty? target = normalize_version(version) checked = T.let(false, T::Boolean) past_terminals = T.let([], T::Array[[String, T.nilable(String), Comparator]]) entries.each do |entry| Array(entry["ranges"]).each do |range| type = range["type"] next if type == "GIT" cmp = comparator_for(type) intervals(Array(range["events"])).each do |interval| inside = in_interval?(target, interval.lower, interval.upper, interval.upper_inclusive, cmp) checked = true if inside return RangeStatus.new(state: :affected, fixed_in: interval.fix).freeze end upper = interval.upper next unless upper rel = cmp.call(target, upper) past = interval.upper_inclusive ? rel.positive? : rel >= 0 past_terminals << [upper, interval.fix, cmp] if past rescue Uncomparable next end end versions = Array(entry["versions"]) next if versions.empty? checked = true if versions.any? { |v| normalize_version(v.to_s) == target } return RangeStatus.new(state: :affected, fixed_in: nil).freeze end end return unless checked # Conflicting entries can end at the same version with `fixed` and # `last_affected`/`limit`. Prefer the non-fix terminal on a tie so # upstream entry ordering cannot turn an inclusive affected boundary # into a reported fix version. `Version` ranks terminals across ranges # of differing types, but each range's own comparator also settles # ties: SemVer ignores build metadata, so `1.0.0+1` and `1.0.0+2` are # one boundary there and `Version` alone would miss the tie. latest_terminal = past_terminals.max_by do |upper, fix, _| [Version.new(upper), fix.nil? ? 1 : 0] end return RangeStatus.new(state: :not_applicable, fixed_in: nil).freeze unless latest_terminal boundary, fixed_in, cmp = latest_terminal shadowed = past_terminals.any? do |other, other_fix, other_cmp| other_fix.nil? && (same_boundary?(boundary, other, cmp) || same_boundary?(boundary, other, other_cmp)) end RangeStatus.new(state: :fixed, fixed_in: (fixed_in unless shadowed)).freeze end |
#released_fix_available?(version, repo_url = nil) ⇒ 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.
454 455 456 |
# File 'vulns/vulnerability.rb', line 454 def released_fix_available?(version, repo_url = nil) fix_available_of_type?(version, repo_url, :released) end |
#same_boundary?(left, right, cmp) ⇒ 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.
213 214 215 216 217 |
# File 'vulns/vulnerability.rb', line 213 def same_boundary?(left, right, cmp) cmp.call(left, right).zero? rescue Uncomparable false end |
#semver_compare!(left, right) ⇒ Integer
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.
358 359 360 |
# File 'vulns/vulnerability.rb', line 358 def semver_compare!(left, right) Semver.compare(left, right) || raise(Uncomparable, "cannot compare #{left.inspect} with #{right.inspect}") end |
#severity_display ⇒ 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.
73 74 75 |
# File 'vulns/vulnerability.rb', line 73 def severity_display severity&.to_s&.upcase || "UNKNOWN" end |
#severity_level ⇒ Integer
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.
78 79 80 81 82 83 |
# File 'vulns/vulnerability.rb', line 78 def severity_level sev = severity return 0 if sev.nil? SEVERITY_LEVEL.fetch(sev, 0) end |