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

Fix MSSQL escaping #3382

Merged
merged 3 commits into from
Oct 6, 2019
Merged

Fix MSSQL escaping #3382

merged 3 commits into from
Oct 6, 2019

Conversation

kibertoad
Copy link
Collaborator

No description provided.

@kibertoad kibertoad requested a review from elhigu August 4, 2019 10:10
@@ -207,7 +207,15 @@ Object.assign(Client_MSSQL.prototype, {
},

wrapIdentifierImpl(value) {
return value !== '*' ? `[${value.replace(/\[/g, '[')}]` : '*';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

.replace(/\[/g, '[')}] path was removed because it doesn't seem to do anything. Please correct me if that's wrong.

.toSQL();
console.log(sql);
expect(sql.sql).to.equal(
'select * from [projects] where "id] = 1 UNION SELECT 1, @@version -- --" = ?'
Copy link
Member

Choose a reason for hiding this comment

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

I would like this to be verified with integration test + to test identifier that has both " and [] chars in it.

Copy link
Member

@elhigu elhigu Aug 16, 2019

Choose a reason for hiding this comment

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

(I had no idea that mssql supports " quoting for identifiers.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

[] are illegal symbols as per MSSQL documentation, apparently, so we don't need to test that. As advised by snyk people, I replaced our escaping logic with the one that sequelize uses, which removes [] in the first place.
And MSSQL does not support arrays.

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.

None yet

2 participants