Skip to content

Commit 86ea355

Browse files
Potential fix for code scanning alert no. 3: Prototype-polluting assignment (#3845)
* Potential fix for code scanning alert no. 3: Prototype-polluting assignment Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * Change files * Fix build issue --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 61bbb8b commit 86ea355

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Potential fix for code scanning alert no. 3: Prototype-polluting assignment",
4+
"packageName": "@fluentui-react-native/memo-cache",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/framework/memo-cache/src/getCacheEntry.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ export type CacheEntry<T, TGet = any> = {
2222
* @param key - which key of that entry to ensure the value for
2323
*/
2424
function ensureAndReturn(entry: CacheEntry<any>, key: keyof CacheEntry<any>): CacheEntry<any> | { [key: string]: CacheEntry<any> } {
25+
if ((key as string) === '__proto__' || (key as string) === 'constructor' || (key as string) === 'prototype') {
26+
throw new Error('Invalid key');
27+
}
2528
return (entry[key] = entry[key] || {});
2629
}
2730

0 commit comments

Comments
 (0)