-
Notifications
You must be signed in to change notification settings - Fork 3
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
Spicerack #1612
base: main
Are you sure you want to change the base?
Spicerack #1612
Conversation
lib/index.js
Outdated
preppedData.assets[normalizedAssetType][normalizedAssetName][ext] = | ||
this.getStaticPath(path); | ||
}); | ||
preppedData.assets[normalizedAssetType][normalizedAssetName][ext] = |
Check warning
Code scanning / CodeQL
Prototype-polluting assignment Medium
library input
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 22 days ago
To fix the problem, we need to ensure that the assetName
and assetType
values cannot be used to modify Object.prototype
. This can be achieved by adding checks to prevent these values from being __proto__
, constructor
, or prototype
. Additionally, we can use a Map
object to store the assets, which is resilient to prototype pollution.
- Add checks to ensure
assetName
andassetType
are not__proto__
,constructor
, orprototype
. - Use a
Map
object to store the assets instead of a plain object.
-
Copy modified line R309 -
Copy modified lines R358-R362 -
Copy modified line R365 -
Copy modified line R376
@@ -308,3 +308,3 @@ | ||
const preppedData = { | ||
assets: {}, | ||
assets: new Map(), | ||
additionalData: [], | ||
@@ -357,7 +357,10 @@ | ||
|
||
if (!preppedData.assets[normalizedAssetType]) { | ||
preppedData.assets[normalizedAssetType] = {}; | ||
if (normalizedAssetName === '__proto__' || normalizedAssetName === 'constructor' || normalizedAssetName === 'prototype') { | ||
throw new Error(`Invalid assetName: ${normalizedAssetName}`); | ||
} | ||
if (!preppedData.assets.has(normalizedAssetType)) { | ||
preppedData.assets.set(normalizedAssetType, new Map()); | ||
} | ||
|
||
preppedData.assets[normalizedAssetType][normalizedAssetName] = {}; | ||
preppedData.assets.get(normalizedAssetType).set(normalizedAssetName, new Map()); | ||
|
||
@@ -372,4 +375,3 @@ | ||
|
||
preppedData.assets[normalizedAssetType][normalizedAssetName][ext] = | ||
this.getStaticPath(path); | ||
preppedData.assets.get(normalizedAssetType).get(normalizedAssetName).set(ext, this.getStaticPath(path)); | ||
}); |
# Conflicts: # lib/index.js
No description provided.