Skip to content

Commit bc4bf4b

Browse files
committed
fix(frontend-manage): reject non-positive or fractional created-element ids
Align the postMessage payload sanitizer with the server-side confirmedElementSchema bound (z.number().int().positive()): a created question-pool element id is always a positive integer, so the client-side boundary validation now rejects fractional and non-positive ids instead of accepting any finite number.
1 parent d20348b commit bc4bf4b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

apps/frontend-manage/src/components/assistant/manageElementCreatedMessage.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ export function sanitizeManageElementCreatedPayload(
2929

3030
const { id, name } = payload as Record<string, unknown>
3131

32-
if (typeof id !== 'number' || !Number.isFinite(id)) return null
32+
// Mirror the server-side confirmedElementSchema bound
33+
// (z.number().int().positive()): a created element id is always a positive
34+
// integer, so reject fractional or non-positive values at this boundary too.
35+
if (typeof id !== 'number' || !Number.isInteger(id) || id <= 0) return null
3336
if (
3437
typeof name !== 'string' ||
3538
name.length === 0 ||

0 commit comments

Comments
 (0)