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

[v4] fix(sqlite): properly catch errors #11877

Merged
merged 6 commits into from Feb 21, 2020
Merged

[v4] fix(sqlite): properly catch errors #11877

merged 6 commits into from Feb 21, 2020

Conversation

papb
Copy link
Member

@papb papb commented Jan 25, 2020

See #11862

See vulnerability report at https://www.npmjs.com/advisories/1142

PR to v3 here: #11878

@codecov
Copy link

codecov bot commented Jan 25, 2020

Codecov Report

Merging #11877 into v4 will decrease coverage by 6.99%.
The diff coverage is 100%.

@papb papb added the P1: important For issues and PRs. label Jan 31, 2020
@sushantdhiman
Copy link
Contributor

Will need a test for this

});
return Vulnerability.sync({ force: true }).then(() => {
return expect(
Vulnerability.create({ name: 'SELECT tbl_name FROM sqlite_master' })
Copy link
Contributor

Choose a reason for hiding this comment

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

It should not be rejected.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, ideally it should work fine instead of being rejected. But fixing that would take a lot more time which I don't have at the moment. This is caused by bad design from v3 and v4. The goal of this PR is just to prevent the Denial of Service vulnerability, since currently the process crashes, which is much worse than simply rejecting.

If you think this is really worth fixing, I would like to suggest that you merge this PR anyway and leave this matter to another time...

Copy link
Contributor

Choose a reason for hiding this comment

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

What error is being rejected here currently? Test could be more verbose, it can assert what error is thrown etc

Copy link
Member Author

Choose a reason for hiding this comment

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

@sushantdhiman Hmmm, the error is TypeError: Cannot read property 'map' of undefined. I don't think it makes sense to assert for this error specifically, because as you said, the correct behavior is to not reject. However, this made me thing that instead of asserting for rejection it would be probably more appropriate to assert for settlement (either fulfillment or rejection). I will make this change.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have made the changes, please take a look at the modified test with comments :)

test/integration/dialects/sqlite/issue-11862.js Outdated Show resolved Hide resolved
@papb
Copy link
Member Author

papb commented Feb 13, 2020

The test has passed now!

https://travis-ci.org/sequelize/sequelize/jobs/649907880#L917

@sushantdhiman sushantdhiman merged commit 8931bf6 into v4 Feb 21, 2020
@sushantdhiman sushantdhiman deleted the fix-11862 branch February 21, 2020 04:39
@sushantdhiman
Copy link
Contributor

🎉 This PR is included in version 4.44.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@createthis
Copy link

I've asked NPM to update the advisory as it appears the advisory is still complaining for 4.44.4.

@papb
Copy link
Member Author

papb commented Mar 3, 2020

@createthis Thanks! Please keep us updated.

@createthis
Copy link

npm has updated the advisory.

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

Successfully merging this pull request may close these issues.

None yet

3 participants