@@ -7,6 +7,10 @@ import {
|
||||
buildSanitizationReport,
|
||||
createBatchArchive,
|
||||
createBatchReport,
|
||||
createPolicyEvidence,
|
||||
createSafeShareReport,
|
||||
genericOutputName,
|
||||
policyById,
|
||||
serializeReport,
|
||||
type ImageScanResult,
|
||||
type MetadataFinding,
|
||||
@@ -160,6 +164,98 @@ describe("sanitization and batch reports", () => {
|
||||
),
|
||||
).rejects.toThrow(/Archive image count/iu);
|
||||
});
|
||||
|
||||
it("builds a pseudonymized safe-share report and generic names", () => {
|
||||
const source = result({
|
||||
id: "private-id",
|
||||
name: "Alice-at-home.png",
|
||||
sha256: "secret-hash",
|
||||
findings: [sensitive],
|
||||
coverage: {
|
||||
projectScanner: "complete",
|
||||
secondaryScanner: "complete",
|
||||
notes: ["source metadata value"],
|
||||
},
|
||||
});
|
||||
const output = result({ id: "clean", name: "output.png" });
|
||||
const report = buildSanitizationReport(
|
||||
source,
|
||||
output,
|
||||
"Alice-at-home.clean.png",
|
||||
"image/png",
|
||||
20,
|
||||
comparison(true),
|
||||
);
|
||||
const safe = serializeReport(
|
||||
createSafeShareReport(
|
||||
[source],
|
||||
[{ blob: new Blob(), report }],
|
||||
"2026-09-01T00:00:00.000Z",
|
||||
),
|
||||
);
|
||||
expect(safe).toContain('"profile": "safe-share"');
|
||||
expect(safe).toContain("image-001.clean.png");
|
||||
expect(safe).not.toContain("Alice");
|
||||
expect(safe).not.toContain("secret-hash");
|
||||
expect(safe).not.toContain("48.1 N");
|
||||
expect(safe).not.toContain("source metadata value");
|
||||
expect(genericOutputName(9, "jpeg")).toBe("image-010.clean.jpg");
|
||||
});
|
||||
|
||||
it("evaluates reusable policies across cleanable and inspect-only formats", () => {
|
||||
const cleanable = result({ findings: [sensitive] });
|
||||
const unsupported = result({
|
||||
id: "pdf",
|
||||
name: "document.pdf",
|
||||
identity: {
|
||||
claimedType: "application/pdf",
|
||||
extension: "pdf",
|
||||
detectedKind: "pdf",
|
||||
detectedType: "application/pdf",
|
||||
typeMatch: "match",
|
||||
},
|
||||
deepSupported: false,
|
||||
cleanable: false,
|
||||
findings: [sensitive],
|
||||
coverage: {
|
||||
projectScanner: "unsupported",
|
||||
secondaryScanner: "unsupported",
|
||||
notes: [],
|
||||
},
|
||||
});
|
||||
const strict = createPolicyEvidence(
|
||||
[cleanable, unsupported],
|
||||
[],
|
||||
policyById("safe-share"),
|
||||
"2026-09-01T00:00:00.000Z",
|
||||
);
|
||||
expect(strict.files[0]).toMatchObject({
|
||||
decision: "review",
|
||||
availableOperation: "reencode-available",
|
||||
findings: { remove: 1 },
|
||||
});
|
||||
expect(strict.files[1]).toMatchObject({
|
||||
decision: "blocked",
|
||||
availableOperation: "inspect-only",
|
||||
});
|
||||
expect(JSON.stringify(strict)).not.toContain("document.pdf");
|
||||
|
||||
const selective = createPolicyEvidence(
|
||||
[
|
||||
result({
|
||||
findings: [
|
||||
sensitive,
|
||||
{ ...sensitive, id: "author", category: "identity" },
|
||||
],
|
||||
}),
|
||||
],
|
||||
[],
|
||||
policyById("location-only"),
|
||||
);
|
||||
expect(selective.files[0]?.availableOperation).toBe(
|
||||
"policy-not-executable",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function comparison(identical: boolean) {
|
||||
|
||||
Reference in New Issue
Block a user