mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-04 19:21:51 +00:00
2c5d47a8cd
Co-authored-by: Hugo P.Brito <hugopbrito@Mac.home>
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
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");
|
|
});
|
|
});
|