fix(qa): validate dense fixture geometry
This commit is contained in:
1 parent
358d6469cf
commit
2d5edf4651
8 files changed
+389
-39
No files matched your search
@@ -11,6 +11,7 @@ import {
|
||||
assertSafeReportPath,
|
||||
readSafeReportFile,
|
||||
validateResolvedArtifactPath,
|
||||
validateResolvedReproductionEvidencePath,
|
||||
writeSafeReportFile,
|
||||
} from "./report-path-integrity.mts";
|
||||
|
||||
@@ -46,7 +47,8 @@ describe("release-v2 QA report path integrity", () => {
|
||||
|
||||
it("rejects an artifact symlink that ultimately escapes its packet directory", async () => {
|
||||
const root = await temporaryDirectory("artifact-escape");
|
||||
const packetDirectory = path.join(root, ".screenshots", "release-v2", "preflight-01");
|
||||
const releaseArtifactDirectory = path.join(root, ".screenshots", "release-v2");
|
||||
const packetDirectory = path.join(releaseArtifactDirectory, "preflight-01");
|
||||
const outsideArtifact = path.join(root, "outside.png");
|
||||
const linkedArtifact = path.join(packetDirectory, "escape.png");
|
||||
await mkdir(packetDirectory, { recursive: true });
|
||||
@@ -56,6 +58,13 @@ describe("release-v2 QA report path integrity", () => {
|
||||
await expect(
|
||||
validateResolvedArtifactPath(packetDirectory, linkedArtifact, "preflight-01: artifact"),
|
||||
).resolves.toContain("resolves outside");
|
||||
await expect(
|
||||
validateResolvedReproductionEvidencePath(
|
||||
releaseArtifactDirectory,
|
||||
linkedArtifact,
|
||||
"preflight-01: reproduction evidence",
|
||||
),
|
||||
).resolves.toContain("resolves outside");
|
||||
});
|
||||
|
||||
it("accepts a resolved regular artifact inside the packet directory", async () => {
|
||||
@@ -68,9 +77,28 @@ describe("release-v2 QA report path integrity", () => {
|
||||
await expect(validateResolvedArtifactPath(packetDirectory, artifact, "preflight-01: artifact")).resolves.toBeNull();
|
||||
});
|
||||
|
||||
it("accepts independent reproduction evidence from another release-v2 agent directory", async () => {
|
||||
const root = await temporaryDirectory("reproduction-artifact-valid");
|
||||
const releaseArtifactDirectory = path.join(root, ".screenshots", "release-v2");
|
||||
const packetDirectory = path.join(releaseArtifactDirectory, "board-03");
|
||||
const reproductionDirectory = path.join(releaseArtifactDirectory, "repro-board03-remove-358d-b");
|
||||
const artifact = path.join(reproductionDirectory, "remove-confirmation.png");
|
||||
await mkdir(packetDirectory, { recursive: true });
|
||||
await mkdir(reproductionDirectory, { recursive: true });
|
||||
await writeFile(artifact, "valid");
|
||||
|
||||
await expect(
|
||||
validateResolvedReproductionEvidencePath(releaseArtifactDirectory, artifact, "board-03: reproduction evidence"),
|
||||
).resolves.toBeNull();
|
||||
await expect(
|
||||
validateResolvedArtifactPath(packetDirectory, artifact, "board-03: finding evidence"),
|
||||
).resolves.toContain("packet's absolute artifact directory");
|
||||
});
|
||||
|
||||
it("rejects an artifact directory and an in-directory artifact symlink", async () => {
|
||||
const root = await temporaryDirectory("artifact-not-file");
|
||||
const packetDirectory = path.join(root, ".screenshots", "release-v2", "preflight-01");
|
||||
const releaseArtifactDirectory = path.join(root, ".screenshots", "release-v2");
|
||||
const packetDirectory = path.join(releaseArtifactDirectory, "preflight-01");
|
||||
const artifactDirectory = path.join(packetDirectory, "looks-like-evidence.png");
|
||||
const realArtifact = path.join(packetDirectory, "real.png");
|
||||
const linkedArtifact = path.join(packetDirectory, "linked.png");
|
||||
@@ -84,11 +112,46 @@ describe("release-v2 QA report path integrity", () => {
|
||||
await expect(
|
||||
validateResolvedArtifactPath(packetDirectory, linkedArtifact, "preflight-01: artifact"),
|
||||
).resolves.toContain("symlink");
|
||||
await expect(
|
||||
validateResolvedReproductionEvidencePath(
|
||||
releaseArtifactDirectory,
|
||||
artifactDirectory,
|
||||
"preflight-01: reproduction evidence",
|
||||
),
|
||||
).resolves.toContain("regular file");
|
||||
await expect(
|
||||
validateResolvedReproductionEvidencePath(
|
||||
releaseArtifactDirectory,
|
||||
linkedArtifact,
|
||||
"preflight-01: reproduction evidence",
|
||||
),
|
||||
).resolves.toContain("symlink");
|
||||
});
|
||||
|
||||
it("rejects relative, escaping, and missing independent reproduction evidence paths", async () => {
|
||||
const root = await temporaryDirectory("reproduction-artifact-unsafe");
|
||||
const releaseArtifactDirectory = path.join(root, ".screenshots", "release-v2");
|
||||
const reproductionDirectory = path.join(releaseArtifactDirectory, "reproducer-01");
|
||||
const outsideArtifact = path.join(root, "outside.png");
|
||||
const missingArtifact = path.join(reproductionDirectory, "missing.png");
|
||||
await mkdir(reproductionDirectory, { recursive: true });
|
||||
await writeFile(outsideArtifact, "outside");
|
||||
|
||||
for (const artifact of ["relative.png", outsideArtifact, missingArtifact]) {
|
||||
await expect(
|
||||
validateResolvedReproductionEvidencePath(
|
||||
releaseArtifactDirectory,
|
||||
artifact,
|
||||
"preflight-01: reproduction evidence",
|
||||
),
|
||||
).resolves.not.toBeNull();
|
||||
}
|
||||
});
|
||||
|
||||
it.runIf(process.platform !== "win32")("rejects a FIFO artifact", async () => {
|
||||
const root = await temporaryDirectory("artifact-fifo");
|
||||
const packetDirectory = path.join(root, ".screenshots", "release-v2", "preflight-01");
|
||||
const releaseArtifactDirectory = path.join(root, ".screenshots", "release-v2");
|
||||
const packetDirectory = path.join(releaseArtifactDirectory, "preflight-01");
|
||||
const fifoArtifact = path.join(packetDirectory, "capture.pipe");
|
||||
await mkdir(packetDirectory, { recursive: true });
|
||||
const result = spawnSync("mkfifo", [fifoArtifact]);
|
||||
@@ -97,11 +160,19 @@ describe("release-v2 QA report path integrity", () => {
|
||||
await expect(
|
||||
validateResolvedArtifactPath(packetDirectory, fifoArtifact, "preflight-01: artifact"),
|
||||
).resolves.toContain("regular file");
|
||||
await expect(
|
||||
validateResolvedReproductionEvidencePath(
|
||||
releaseArtifactDirectory,
|
||||
fifoArtifact,
|
||||
"preflight-01: reproduction evidence",
|
||||
),
|
||||
).resolves.toContain("regular file");
|
||||
});
|
||||
|
||||
it.runIf(process.platform !== "win32")("rejects a socket artifact", async () => {
|
||||
const root = await temporaryDirectory("artifact-socket");
|
||||
const packetDirectory = path.join(root, ".screenshots", "release-v2", "preflight-01");
|
||||
const releaseArtifactDirectory = path.join(root, ".screenshots", "release-v2");
|
||||
const packetDirectory = path.join(releaseArtifactDirectory, "preflight-01");
|
||||
const socketArtifact = path.join(packetDirectory, "capture.sock");
|
||||
await mkdir(packetDirectory, { recursive: true });
|
||||
const server = createServer();
|
||||
@@ -113,6 +184,13 @@ describe("release-v2 QA report path integrity", () => {
|
||||
await expect(
|
||||
validateResolvedArtifactPath(packetDirectory, socketArtifact, "preflight-01: artifact"),
|
||||
).resolves.toContain("regular file");
|
||||
await expect(
|
||||
validateResolvedReproductionEvidencePath(
|
||||
releaseArtifactDirectory,
|
||||
socketArtifact,
|
||||
"preflight-01: reproduction evidence",
|
||||
),
|
||||
).resolves.toContain("regular file");
|
||||
} finally {
|
||||
await new Promise<void>((resolve, reject) => server.close((error) => (error ? reject(error) : resolve())));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user