-
-
Notifications
You must be signed in to change notification settings - Fork 159
feat: add sdk.params
option
#1927
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
|
🦋 Changeset detectedLatest commit: f8b592e The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
if (config.key) { | ||
const field = map.get(config.key)!; | ||
const name = field.map || config.key; | ||
(params[field.in] as Record<string, unknown>)[name] = arg; |
Check warning
Code scanning / CodeQL
Prototype-polluting assignment Medium
library input
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 days ago
To fix the prototype pollution issue, we need to ensure that special property names like __proto__
, constructor
, and prototype
are not used as keys in the params
object. This can be achieved by adding a check before assigning values to the params
object.
The best way to fix the problem without changing existing functionality is to add a validation step to filter out these special property names. This can be done by modifying the code in the buildClientParams
function.
-
Copy modified lines R102-R104 -
Copy modified lines R114-R116 -
Copy modified lines R124-R127 -
Copy modified lines R133-R135
@@ -101,3 +101,5 @@ | ||
const name = field.map || config.key; | ||
(params[field.in] as Record<string, unknown>)[name] = arg; | ||
if (name !== '__proto__' && name !== 'constructor' && name !== 'prototype') { | ||
(params[field.in] as Record<string, unknown>)[name] = arg; | ||
} | ||
} else { | ||
@@ -111,3 +113,5 @@ | ||
const name = field.map || key; | ||
(params[field.in] as Record<string, unknown>)[name] = value; | ||
if (name !== '__proto__' && name !== 'constructor' && name !== 'prototype') { | ||
(params[field.in] as Record<string, unknown>)[name] = value; | ||
} | ||
} else { | ||
@@ -119,5 +123,6 @@ | ||
const [prefix, slot] = extra; | ||
(params[slot] as Record<string, unknown>)[ | ||
key.slice(prefix.length) | ||
] = value; | ||
const name = key.slice(prefix.length); | ||
if (name !== '__proto__' && name !== 'constructor' && name !== 'prototype') { | ||
(params[slot] as Record<string, unknown>)[name] = value; | ||
} | ||
} else { | ||
@@ -127,3 +132,5 @@ | ||
if (allowed) { | ||
(params[slot as Slot] as Record<string, unknown>)[key] = value; | ||
if (key !== '__proto__' && key !== 'constructor' && key !== 'prototype') { | ||
(params[slot as Slot] as Record<string, unknown>)[key] = value; | ||
} | ||
break; |
|
||
if (field) { | ||
const name = field.map || key; | ||
(params[field.in] as Record<string, unknown>)[name] = value; |
Check warning
Code scanning / CodeQL
Prototype-polluting assignment Medium
library input
facb3c6
to
b345d9b
Compare
Related to #926
TODO
headers
toparams
never
(need to useOmitNever
)params
aren't currently used at all, and there's a mismatch with required/optional arguments due to above)