Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Potential fix for code scanning alert no. 3: Prototype-polluting assignment",
"packageName": "@fluentui-react-native/memo-cache",
"email": "[email protected]",
"dependentChangeType": "patch"
}
3 changes: 3 additions & 0 deletions packages/framework/memo-cache/src/getCacheEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export type CacheEntry<T, TGet = any> = {
* @param key - which key of that entry to ensure the value for
*/
function ensureAndReturn(entry: CacheEntry<any>, key: keyof CacheEntry<any>): CacheEntry<any> | { [key: string]: CacheEntry<any> } {
if ((key as string) === '__proto__' || (key as string) === 'constructor' || (key as string) === 'prototype') {
throw new Error('Invalid key');
}
return (entry[key] = entry[key] || {});
}

Expand Down