Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -3,7 +3,9 @@ import {
|
||||
ALLOWED_LICENSES,
|
||||
BLOCKED_LICENSE_PATTERNS,
|
||||
classifyLicense,
|
||||
hasLicenseViolations,
|
||||
isReviewed,
|
||||
parsePnpmLicenseReport,
|
||||
parseLicenseField,
|
||||
splitSpdxExpression,
|
||||
} from "./verify-licenses.mjs";
|
||||
@@ -33,6 +35,28 @@ describe("parseLicenseField", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("parsePnpmLicenseReport", () => {
|
||||
it("flattens every installed production version and deduplicates workspace paths", () => {
|
||||
expect(
|
||||
parsePnpmLicenseReport({
|
||||
MIT: [
|
||||
{ name: "alpha", versions: ["1.0.0", "2.0.0"], paths: ["/a", "/b"], license: "MIT" },
|
||||
{ name: "alpha", versions: ["1.0.0"], paths: ["/c"], license: "MIT" },
|
||||
],
|
||||
"LGPL-3.0": [{ name: "beta", versions: ["3.0.0"], paths: ["/d"], license: "LGPL-3.0" }],
|
||||
}),
|
||||
).toEqual([
|
||||
{ name: "alpha", version: "1.0.0", license: "MIT" },
|
||||
{ name: "alpha", version: "2.0.0", license: "MIT" },
|
||||
{ name: "beta", version: "3.0.0", license: "LGPL-3.0" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("rejects malformed inventory roots instead of silently passing", () => {
|
||||
expect(() => parsePnpmLicenseReport([])).toThrow("must be an object");
|
||||
});
|
||||
});
|
||||
|
||||
describe("splitSpdxExpression", () => {
|
||||
it("returns single-atom expressions untouched", () => {
|
||||
expect(splitSpdxExpression("MIT")).toEqual(["MIT"]);
|
||||
@@ -61,6 +85,16 @@ describe("classifyLicense — allowlist", () => {
|
||||
it("treats an OR expression with one allowed atom as allowed", () => {
|
||||
expect(classifyLicense("(MIT OR FooLicense-1.0)")).toBe("allowed");
|
||||
});
|
||||
|
||||
it("allows a permissive SPDX choice even when another choice is copyleft", () => {
|
||||
expect(classifyLicense("(MIT OR GPL-3.0-or-later)")).toBe("allowed");
|
||||
expect(classifyLicense("(BSD-3-Clause OR GPL-2.0)")).toBe("allowed");
|
||||
});
|
||||
|
||||
it("requires every branch of an SPDX AND expression", () => {
|
||||
expect(classifyLicense("MIT AND ISC")).toBe("allowed");
|
||||
expect(classifyLicense("MIT AND Commons-Clause")).toBe("blocked");
|
||||
});
|
||||
});
|
||||
|
||||
describe("classifyLicense — blocklist", () => {
|
||||
@@ -75,8 +109,8 @@ describe("classifyLicense — blocklist", () => {
|
||||
expect(classifyLicense(lic)).toBe("blocked");
|
||||
});
|
||||
|
||||
it("blocks an OR expression that contains a blocked atom", () => {
|
||||
expect(classifyLicense("(MIT OR GPL-3.0)")).toBe("blocked");
|
||||
it("blocks an OR expression when every available choice is blocked", () => {
|
||||
expect(classifyLicense("(GPL-3.0 OR AGPL-3.0)")).toBe("blocked");
|
||||
});
|
||||
|
||||
it("uses the configured pattern list, not the hardcoded one", () => {
|
||||
@@ -123,6 +157,14 @@ describe("baseline allowlist", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("license gate result", () => {
|
||||
it("fails closed for unknown as well as explicitly blocked licenses", () => {
|
||||
expect(hasLicenseViolations({ blocked: [], unknown: [] })).toBe(false);
|
||||
expect(hasLicenseViolations({ blocked: [{ name: "copyleft" }], unknown: [] })).toBe(true);
|
||||
expect(hasLicenseViolations({ blocked: [], unknown: [{ name: "missing-metadata" }] })).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("BLOCKED_LICENSE_PATTERNS export", () => {
|
||||
it("contains the headline copyleft families", () => {
|
||||
const blob = BLOCKED_LICENSE_PATTERNS.map(String).join("|");
|
||||
|
||||
Reference in new issue
Block a user