Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Read each vulnerability's other names and what fixes it
Țugui Dragoș3f9f8e9262d4
diff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swiftindex 38b32bb3..271a4f2c 100644--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift@@ -180,14 +180,37 @@ public struct HomebrewVulnerability: Sendable, Hashable, Identifiable {}}+ /// What OSV.dev says fixes a vulnerability.+ public enum Fix: Sendable, Hashable {+ case versions([String])+ /// OSV.dev names only the commits that fix it, and no version.+ case commits+ case notListed++ /// Reads Homebrew's `fixed_versions`, where the fix of a Git range is a full commit hash (the OSV schema,+ /// `GIT` ranges) and any other entry is a version.+ init(fixedIn entries: [String]) {+ let versions = entries.filter { !Self.isCommit($0) }+ self = if !versions.isEmpty { .versions(versions) } else if entries.isEmpty { .notListed } else { .commits }+ }++ private static func isCommit(_ entry: String) -> Bool {+ (entry.count == 40 || entry.count == 64) && entry.allSatisfy(\.isHexDigit)+ }+ }+public let id: String+ public let aliases: [String]public let severity: Severitypublic let summary: String+ public let fix: Fix- public init(id: String, severity: Severity, summary: String) {+ public init(id: String, aliases: [String] = [], severity: Severity, summary: String, fix: Fix = .notListed) {self.id = id+ self.aliases = aliasesself.severity = severityself.summary = summary+ self.fix = fix}}@@ -892,6 +915,13 @@ public enum Homebrew {let id: Stringlet severity: String?let summary: String?+ let aliases: [String]?+ let fixedVersions: [String]?++ enum CodingKeys: String, CodingKey {+ case id, severity, summary, aliases+ case fixedVersions = "fixed_versions"+ }}let formula: String@@ -928,11 +958,17 @@ public enum Homebrew {.map {HomebrewVulnerability(id: $0.id,+ aliases: $0.aliases ?? [],severity: HomebrewVulnerability.Severity(name: $0.severity ?? ""),- summary: ($0.summary ?? "").trimmingCharacters(in: .whitespacesAndNewlines)+ summary: ($0.summary ?? "").trimmingCharacters(in: .whitespacesAndNewlines),+ fix: HomebrewVulnerability.Fix(fixedIn: $0.fixedVersions ?? []))}- .sorted { $0.severity == $1.severity ? $0.id < $1.id : $0.severity > $1.severity }+ .sorted {+ $0.severity == $1.severity+ ? $0.id.localizedStandardCompare($1.id) == .orderedAscending+ : $0.severity > $1.severity+ })}return HomebrewVulnerabilityReport(diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swiftindex d09523ca..93ee20c8 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift@@ -528,6 +528,40 @@ struct HomebrewTests {#expect(libssh2.vulnerabilities.map(\.severity) == [.medium, .unknown])}+ @Test func readsTheAliasesAndTheFixOfEachVulnerability() throws {+ let commit = String(repeating: "f089acdf", count: 5)+ let longCommit = String(repeating: "d3c1b116", count: 8)+ let json = """+ {"findings": [{"formula": "uv", "version": "0.12.7", "vulnerabilities": [+ {"id": "CVE-2026-1", "severity": "HIGH", "summary": "", "aliases": ["GHSA-2cv4-cqwr-gwf7"], "fixed_versions": ["\(commit)", "0.12.8"]},+ {"id": "CVE-2026-2", "severity": "HIGH", "summary": "", "aliases": [], "fixed_versions": ["\(commit)", "\(longCommit)"]},+ {"id": "CVE-2026-3", "severity": "HIGH", "summary": "", "aliases": [], "fixed_versions": []}+ ], "patched": []}]}+ """++ let report = try JSONDecoder().decode(Homebrew.VulnsReport.self, from: Data(json.utf8)).report+ let vulnerabilities = try #require(report.advisories.first).vulnerabilities++ #expect(vulnerabilities.map(\.aliases) == [["GHSA-2cv4-cqwr-gwf7"], [], []])+ #expect(vulnerabilities.map(\.fix) == [.versions(["0.12.8"]), .commits, .notListed])+ }++ @Test func listsIdentifiersInTheOrderOfTheirNumbers() throws {+ let json = """+ {"findings": [{"formula": "libssh2", "version": "1.11.1", "vulnerabilities": [+ {"id": "OSV-2025-433", "severity": "UNKNOWN"}, {"id": "CVE-2026-66032", "severity": "UNKNOWN"},+ {"id": "OSV-2025-90", "severity": "UNKNOWN"}, {"id": "CVE-2026-7598", "severity": "UNKNOWN"}+ ], "patched": []}]}+ """++ let report = try JSONDecoder().decode(Homebrew.VulnsReport.self, from: Data(json.utf8)).report++ #expect(+ report.advisories.first?.vulnerabilities.map(\.id)+ == ["CVE-2026-7598", "CVE-2026-66032", "OSV-2025-90", "OSV-2025-433"]+ )+ }+/// From 6.0.11 to 6.0.18 the scan answers with a list, and from 6.0.19 with an object that holds one. Both/// shapes are read, so an older Homebrew's answer is not thrown away as a failure.@Test func readsTheScanAnOlderHomebrewWrites() throws {@@ -537,6 +571,8 @@ struct HomebrewTests {#expect(report.advisories.map(\.formula) == ["libssh2"])#expect(report.skipped.isEmpty)+ #expect(report.advisories.first?.vulnerabilities.first?.aliases == [])+ #expect(report.advisories.first?.vulnerabilities.first?.fix == .notListed)}/// The scan keeps a formula whose every vulnerability is patched, with nothing open under it. Listing it