Harden issue artifact metadata
This commit is contained in:
@@ -16,4 +16,26 @@ describe("attachmentArtifactWorkProductMetadataSchema", () => {
|
||||
expect(parsed.contentType).toBe("video/mp4");
|
||||
expect(parsed.downloadPath).toContain("download=1");
|
||||
});
|
||||
|
||||
it("rejects off-route or scriptable paths", () => {
|
||||
const parsed = attachmentArtifactWorkProductMetadataSchema.safeParse({
|
||||
attachmentId: "11111111-1111-4111-8111-111111111111",
|
||||
contentType: "video/mp4",
|
||||
byteSize: 1234,
|
||||
contentPath: "https://evil.example/video.mp4",
|
||||
openPath: "javascript:alert(1)",
|
||||
downloadPath: "/api/attachments/11111111-1111-4111-8111-111111111111/content",
|
||||
originalFilename: "demo.mp4",
|
||||
});
|
||||
|
||||
expect(parsed.success).toBe(false);
|
||||
if (parsed.success) {
|
||||
throw new Error("Expected invalid attachment artifact metadata");
|
||||
}
|
||||
expect(parsed.error.issues.map((issue) => issue.path.join("."))).toEqual([
|
||||
"contentPath",
|
||||
"openPath",
|
||||
"downloadPath",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user