-
Notifications
You must be signed in to change notification settings - Fork 8
adds the extracted @gadgetinc/core package #899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
for (const validationError of invalidRecordError.validationErrors) { | ||
if (invalidRecordError.modelApiIdentifier) { | ||
result[invalidRecordError.modelApiIdentifier] ??= {}; | ||
result[invalidRecordError.modelApiIdentifier][validationError.apiIdentifier] = { message: validationError.message }; |
Check warning
Code scanning / CodeQL
Prototype-polluting assignment Medium
library input
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 days ago
To fix this, we should prevent dangerous values ('__proto__'
, 'constructor'
, 'prototype'
) from ever being used as keys on plain objects. The best way, without changing existing functionality, is to add a check when assigning to result[invalidRecordError.modelApiIdentifier]
(line 733) and, optionally, result[validationError.apiIdentifier]
(line 735), to ensure that neither key is one of the dangerous reserved names. If encountered, we should skip that assignment and possibly log or collect as a separate error. This fix should be implemented directly in the loop in the formatErrorMessages
function. No extra dependencies are required; the fix is a conditional check.
-
Copy modified lines R732-R739 -
Copy modified lines R741-R744
@@ -729,10 +729,19 @@ | ||
const invalidRecordError = error as InvalidRecordError; | ||
for (const validationError of invalidRecordError.validationErrors) { | ||
if (invalidRecordError.modelApiIdentifier) { | ||
result[invalidRecordError.modelApiIdentifier] ??= {}; | ||
result[invalidRecordError.modelApiIdentifier][validationError.apiIdentifier] = { message: validationError.message }; | ||
const key = invalidRecordError.modelApiIdentifier; | ||
if (key !== "__proto__" && key !== "constructor" && key !== "prototype") { | ||
result[key] ??= {}; | ||
const fieldKey = validationError.apiIdentifier; | ||
if (fieldKey !== "__proto__" && fieldKey !== "constructor" && fieldKey !== "prototype") { | ||
result[key][fieldKey] = { message: validationError.message }; | ||
} | ||
} | ||
} else { | ||
result[validationError.apiIdentifier] = { message: validationError.message }; | ||
const key = validationError.apiIdentifier; | ||
if (key !== "__proto__" && key !== "constructor" && key !== "prototype") { | ||
result[key] = { message: validationError.message }; | ||
} | ||
} | ||
} | ||
} else { |
398b20f
to
73ecbd2
Compare
73ecbd2
to
e716377
Compare
... a description that explains what, why, and how ...
PR Checklist