Skip to content

Commit

Permalink
feat(core): fix insecure operators bypass (lint fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
minenwerfer committed Oct 21, 2024
1 parent 33b5ae5 commit 93cf504
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/core/tests/traverseDocument.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,12 @@ test('moves multiple files', async () => {

test('forbids MongoDB operators unless explicitly allowed', async () => {
const { error: shouldFail1 } = await traverseDocument({ name: { $eq: 'terry' } }, description, { allowOperators: false })
const { error: shouldFail2 } = await traverseDocument({ name: { something: 1, $eq: 'terry' } }, description, { allowOperators: false })
const { error: shouldFail2 } = await traverseDocument({
name: {
something: 1,
$eq: 'terry',
},
}, description, { allowOperators: false })
const { error: shouldFail3 } = await traverseDocument({ inexistent: { $eq: 'terry' } }, description, { allowOperators: false })

const { result: shouldSucceed } = await traverseDocument({ name: { $eq: 'terry' } }, description, { allowOperators: true })
Expand All @@ -314,7 +319,12 @@ test('forbids MongoDB operators unless explicitly allowed', async () => {

test('forbids insecure operators', async () => {
const { error: shoudFail1 } = await traverseDocument({ name: { $regex: 'terry' } }, description, { allowOperators: true })
const { error: shoudFail2 } = await traverseDocument({ name: { something: 1, $regex: 'terry' } }, description, { allowOperators: true })
const { error: shoudFail2 } = await traverseDocument({
name: {
something: 1,
$regex: 'terry',
},
}, description, { allowOperators: true })
const { error: shoudFail3 } = await traverseDocument({ inexistent: { $regex: 'terry' } }, description, { allowOperators: true })

assert(shoudFail1)
Expand Down

0 comments on commit 93cf504

Please sign in to comment.