Skip to content

Commit 49734e6

Browse files
Potential fix for code scanning alert no. 55: Prototype-polluting assignment
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 7fcb60d commit 49734e6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/wrap/src/transforms/WrapQuery.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,18 @@ export default class WrapQuery<TContext = Record<string, any>>
8787
const path = [...this.path];
8888
while (path.length > 1) {
8989
const next = path.shift()!;
90+
if (next === '__proto__' || next === 'constructor' || next === 'prototype') {
91+
throw new Error('Invalid path key');
92+
}
9093
if (data[next]) {
9194
data = data[next];
9295
}
9396
}
94-
data[path[0]!] = this.extractor(data[path[0]!]);
97+
const lastKey = path[0]!;
98+
if (lastKey === '__proto__' || lastKey === 'constructor' || lastKey === 'prototype') {
99+
throw new Error('Invalid path key');
100+
}
101+
data[lastKey] = this.extractor(data[lastKey]);
95102
}
96103

97104
return {

0 commit comments

Comments
 (0)