-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test case covering the use of
__proto__
as a section name
Closes #40
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const {createTestContext} = require('./__fixtues__/create-test-context'); | ||
|
||
const propertiesReader = require('../'); | ||
|
||
describe('prototype-pollution', () => { | ||
let context; | ||
|
||
beforeEach(async () => { | ||
context = await createTestContext(); | ||
}); | ||
|
||
it('does not pollute global Object.prototype', async () => { | ||
const file = ` | ||
[__proto__] | ||
polluted = polluted | ||
parsed = true | ||
`; | ||
const props = propertiesReader(await context.file('props.ini', file)); | ||
|
||
expect(({}).polluted).toBeUndefined(); | ||
expect(props.path().__proto__.polluted).toBe('polluted'); | ||
expect(props.getRaw('__proto__.polluted')).toBe('polluted'); | ||
expect(props.get('__proto__.polluted')).toBe('polluted'); | ||
expect(props.getRaw('__proto__.parsed')).toBe('true'); | ||
expect(props.get('__proto__.parsed')).toBe(true); | ||
}); | ||
|
||
}); |