Skip to content

Commit f3f1a45

Browse files
committed
fix(sandbox): validate required opts in pdf drawImage to prevent silent origin placement
1 parent 9e38939 commit f3f1a45

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

apps/sim/sandbox-tasks/pdf-generate.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ export const pdfGenerateTask = defineSandboxTask<SandboxTaskInput>({
7575
* Example: await drawImage(page, 'abc123', { x: 50, y: 700, width: 200, height: 100 });
7676
*/
7777
globalThis.drawImage = async function drawImage(page, fileId, opts) {
78+
if (!opts || opts.x == null || opts.y == null || opts.width == null || opts.height == null) {
79+
throw new Error('drawImage: opts must include x, y, width, and height (in points)');
80+
}
7881
const dataUri = await globalThis.getFileBase64(fileId);
7982
const img = await globalThis.embedImage(dataUri);
80-
page.drawImage(img, opts || {});
83+
page.drawImage(img, opts);
8184
};
8285
`,
8386
finalize: `

0 commit comments

Comments
 (0)