-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { expect, it, } from 'vitest' | ||
import { expect, it } from 'vitest' | ||
|
||
import { getByPath, setByPath } from '../src' | ||
|
||
|
@@ -165,16 +165,20 @@ it('Test for prototype pollution', () => { | |
const object = {} | ||
|
||
// @ts-expect-error - this is not a valid path for the object | ||
expect(() => { setByPath(object, '__proto__.polluted', true) }).toThrowError('__proto__'); | ||
expect(() => { | ||
setByPath(object, '__proto__.polluted', true) | ||
}).toThrowError('__proto__') | ||
|
||
// @ts-expect-error - this is not a valid path for the object | ||
expect(getByPath(object, '__proto__')).toBe(undefined) | ||
|
||
// @ts-expect-error - this is not a valid path for the object | ||
Check failure on line 175 in test/index.test.ts GitHub Actions / tests
|
||
expect(() => { setByPath(object, 'constructor.polluted', true) }).toThrowError('constructor'); | ||
expect(() => { | ||
setByPath(object, 'constructor.polluted', true) | ||
}).toThrowError('constructor') | ||
|
||
// @ts-expect-error - this is not a valid path for the object | ||
expect(getByPath(object, 'constructor')).toBe(undefined); | ||
expect(getByPath(object, 'constructor')).toBe(undefined) | ||
|
||
// @ts-expect-error - this is should not be defined on the object | ||
expect(object.polluted).toBe(undefined) | ||
|
@@ -187,7 +191,6 @@ it('Test for prototype pollution', () => { | |
|
||
expect(object2.constructor.prototype.polluted).toBe(false) | ||
|
||
|
||
// eslint-disable-next-line @typescript-eslint/no-extraneous-class | ||
const testClass = class TestClass { | ||
// eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-empty-function | ||
|
@@ -203,9 +206,12 @@ it('Test for prototype pollution', () => { | |
expect(getByPath(object3, 'constructor')).toBe(undefined) | ||
|
||
// @ts-expect-error - this is not a valid path for the object | ||
Check failure on line 208 in test/index.test.ts GitHub Actions / tests
|
||
expect(() => { setByPath(object3, 'constructor.polluted', true) }).toThrowError('constructor'); | ||
expect(() => { | ||
setByPath(object3, 'constructor.polluted', true) | ||
}).toThrowError('constructor') | ||
|
||
// @ts-expect-error - this is not a valid path for the object | ||
Check failure on line 213 in test/index.test.ts GitHub Actions / tests
|
||
expect(() => { setByPath(object3, '__proto__.polluted', true) }).toThrowError('__proto__'); | ||
|
||
expect(() => { | ||
setByPath(object3, '__proto__.polluted', true) | ||
}).toThrowError('__proto__') | ||
}) |