-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
chore(web connector): unify sendable schema with klesia #220
Conversation
Here's the code health analysis summary for commits Analysis Summary
|
} | ||
state.accounts[network][address] = { | ||
state.accounts[networkId][address] = { |
Check warning
Code scanning / CodeQL
Prototype-polluting assignment Medium
library input
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 2 months ago
To fix the prototype pollution issue, we need to ensure that networkId
cannot be set to special property names like __proto__
, constructor
, or prototype
. One effective way to do this is to validate the networkId
before using it as a key in the state.accounts
object. If the networkId
is invalid, we can either throw an error or handle it appropriately.
We will add a validation function to check for these special property names and use this function before any assignment to state.accounts[networkId]
.
-
Copy modified lines R10-R13 -
Copy modified line R28 -
Copy modified lines R45-R49 -
Copy modified lines R59-R63 -
Copy modified line R71 -
Copy modified lines R83-R85
@@ -9,2 +9,6 @@ | ||
|
||
const isValidKey = (key) => { | ||
return key !== '__proto__' && key !== 'constructor' && key !== 'prototype'; | ||
}; | ||
|
||
export const initialAccountStoreState: AccountState = { | ||
@@ -23,3 +27,3 @@ | ||
produce((state) => { | ||
if (!state.accounts[networkId]?.[address]) { | ||
if (isValidKey(networkId) && !state.accounts[networkId]?.[address]) { | ||
if (!state.accounts[networkId]) { | ||
@@ -40,5 +44,7 @@ | ||
produce((state) => { | ||
state.accounts[network][address] = { | ||
...account, | ||
accountInfo, | ||
if (isValidKey(network)) { | ||
state.accounts[network][address] = { | ||
...account, | ||
accountInfo, | ||
} | ||
} | ||
@@ -52,5 +58,7 @@ | ||
produce((state) => { | ||
state.accounts[network][address] = { | ||
...account, | ||
transactions, | ||
if (isValidKey(network)) { | ||
state.accounts[network][address] = { | ||
...account, | ||
transactions, | ||
} | ||
} | ||
@@ -62,3 +70,3 @@ | ||
produce((state) => { | ||
if (!state.accounts?.[network]?.[address]) { | ||
if (isValidKey(network) && !state.accounts?.[network]?.[address]) { | ||
state.accounts[network] = state.accounts[network] || {} | ||
@@ -74,3 +82,5 @@ | ||
produce((state) => { | ||
delete state.accounts[network][address] | ||
if (isValidKey(network)) { | ||
delete state.accounts[network][address] | ||
} | ||
}), |
Describe changes
Ticket or discussion link
Review checklist
Screenshots