repositories / pi-ext
pi-ext
bugabingas pi extensions
owned by bugabinga
extensions/leaks/__tests__/validation-batches.test.ts
RawFile outline
- root line 5
- tests line 6
- batches line 8
- leaks validation batch wrapper line 21
- maps every V0-V9 batch to executable test files line 22
- keeps detector batches backed by positive and negative controls line 32
- records regex fuzz evidence for runtime regex safety line 47
- records demo corpus evidence without fixture values line 56
import { existsSync, readFileSync } from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
const root = path.resolve(import.meta.dirname, "..");
const tests = path.join(root, "__tests__");
const batches = new Map([
["V0 scope", ["ledger.test.ts"]],
["V1 provider boundary", ["harness.test.ts"]],
["V2 placeholders", ["placeholders.test.ts", "selector.test.ts"]],
["V3 settings", ["settings.test.ts", "regex-fuzz.test.ts"]],
["V4 built-ins", ["detectors.test.ts", "demo-corpus.test.ts"]],
["V5 learned values", ["dotenv.test.ts", "demo-corpus.test.ts"]],
["V6 component parsers", ["structures.test.ts", "demo-corpus.test.ts"]],
["V7 false positives", ["false-positives.test.ts", "demo-corpus.test.ts"]],
["V8 UX", ["ux.test.ts"]],
["V9 performance/failure", ["performance.test.ts", "regex-fuzz.test.ts"]],
]);
describe("leaks validation batch wrapper", () => {
it("maps every V0-V9 batch to executable test files", () => {
for (const [batch, files] of batches) {
expect(files.length, batch).toBeGreaterThan(0);
for (const file of files)
expect(existsSync(path.join(tests, file)), `${batch} ${file}`).toBe(
true,
);
}
});
it("keeps detector batches backed by positive and negative controls", () => {
const detectorText = readFileSync(
path.join(tests, "detectors.test.ts"),
"utf8",
);
const falsePositiveText = readFileSync(
path.join(tests, "false-positives.test.ts"),
"utf8",
);
expect(detectorText).toContain("positives");
expect(detectorText).toContain("negatives");
expect(falsePositiveText).toContain("negatives");
expect(falsePositiveText).toContain("custom regex override");
});
it("records regex fuzz evidence for runtime regex safety", () => {
const fuzzText = readFileSync(
path.join(tests, "regex-fuzz.test.ts"),
"utf8",
);
expect(fuzzText).toContain("runtimeRegexFuzzTargets");
expect(fuzzText).toContain("adversarial");
});
it("records demo corpus evidence without fixture values", () => {
const demoText = readFileSync(
path.join(tests, "demo-corpus.test.ts"),
"utf8",
);
expect(demoText).toContain("demo-secrets");
expect(demoText).toContain("fixtureClass");
expect(demoText).toContain("redactionCount");
});
});