import { describe, expect, it } from "vitest"; import { getRecommendationLinkLabel } from "./vulnerability-references"; describe("getRecommendationLinkLabel", () => { it("returns View CVE for known CVE hosts", () => { expect( getRecommendationLinkLabel("https://www.cve.org/CVERecord?id=CVE-2026-1"), ).toBe("View CVE"); expect( getRecommendationLinkLabel("https://cve.org/CVERecord?id=CVE-2026-1"), ).toBe("View CVE"); expect( getRecommendationLinkLabel("https://cve.mitre.org/cgi-bin/cvename.cgi"), ).toBe("View CVE"); }); it("returns View in Prowler Hub only for the exact Hub hostname", () => { expect( getRecommendationLinkLabel("https://hub.prowler.com/check/example"), ).toBe("View in Prowler Hub"); expect( getRecommendationLinkLabel("https://hub.prowler.com.evil.com/check"), ).toBe("View Reference"); }); it("returns View Advisory for GitHub Security Advisory URLs", () => { expect( getRecommendationLinkLabel( "https://github.com/advisories/GHSA-abcd-1234-efgh", ), ).toBe("View Advisory"); }); it("returns View Reference for unknown or malformed URLs", () => { expect(getRecommendationLinkLabel("https://example.com/advisory")).toBe( "View Reference", ); expect(getRecommendationLinkLabel("not-a-url")).toBe("View Reference"); }); });