fix(HTTP Request Node): Fix prototype pollution vulnerability (#15463)

This commit is contained in:
Elias Meire
2025-05-20 15:39:33 +02:00
committed by GitHub
parent 8d1170e3dd
commit 1ffc33dcc6
6 changed files with 65 additions and 9 deletions

View File

@@ -9,6 +9,8 @@ import {
randomInt,
randomString,
hasKey,
isSafeObjectProperty,
setSafeObjectProperty,
} from '@/utils';
describe('isObjectEmpty', () => {
@@ -366,3 +368,29 @@ describe('hasKey', () => {
}
});
});
describe('isSafeObjectProperty', () => {
it.each([
['__proto__', false],
['prototype', false],
['constructor', false],
['getPrototypeOf', false],
['safeKey', true],
['anotherKey', true],
['toString', true],
])('should return %s for key "%s"', (key, expected) => {
expect(isSafeObjectProperty(key)).toBe(expected);
});
});
describe('setSafeObjectProperty', () => {
it.each([
['safeKey', 123, { safeKey: 123 }],
['__proto__', 456, {}],
['constructor', 'test', {}],
])('should set property "%s" safely', (key, value, expected) => {
const obj: Record<string, unknown> = {};
setSafeObjectProperty(obj, key, value);
expect(obj).toEqual(expected);
});
});