Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly catch the error when insertMany fails to initialize the document #8365

Merged
merged 2 commits into from Nov 23, 2019

Conversation

Fonger
Copy link
Contributor

@Fonger Fonger commented Nov 20, 2019

Summary

Fix #8363. Correctly catch the error with callback when insertMany fails to initialize the document.
This can prevent DOS attack when inserting user-provided data.

This fix handles it like Model.create([...]) does.

Note: I've tested Model.bulkWrite() insertOne()/replaceOne() and I can confirm that it's not affected by this bug because $handleCallbackError wrap the entire bulkWrite callback handler and it catches the error during castBulkWrite().

However, in Model.insertMany(), parallelLimit() individual callbacks are not wrapped in that general handler (although $__insertMany is) so we need this fix.

Examples

See the test case

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

insertMany() make node process to CRASH Unable to catch()
2 participants