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

Escaping parameters #25

Open
fgheorghe opened this issue Dec 2, 2019 · 3 comments
Open

Escaping parameters #25

fgheorghe opened this issue Dec 2, 2019 · 3 comments

Comments

@fgheorghe
Copy link

fgheorghe commented Dec 2, 2019

Hi all

Apologies if this is not the right place to ask this, but I am wondering if there is straightforward way of adding parameter escaping for .quey()? Much like with other SQL implementations, Athena queries can also suffer from SQL injection, and as such, was wondering if athena-express should natively support bound parameters? Something like .query(sql, params), where sql = "SELECT * FROM table WHERE column = [?|:paramName]" and params is either an array of params to replace ? or an object with keys for param names (i.e.: {paramName: 'paramValue' }.

Edit: at the moment I am using https://www.npmjs.com/package/sqlstring, happy to issue a PR with native parameters support.

Regards,
Flaviu

@ghdna
Copy link
Owner

ghdna commented Dec 15, 2019

Sure, please issue a PR with support and I'll look at it.

@fgheorghe
Copy link
Author

Great - will work on it later this week. Regards!

@fgheorghe
Copy link
Author

fgheorghe commented Jan 10, 2020

@ghdna sorry for the delay on this one, holidays got in the way.

Please find below a draft pull request:
#31

I need to test it a bit more in the following days to make sure everything works fine. But the idea is to use a .query() second optional parameter or a query object key (described in the draft PR).

Adds a dependency on SqlString.

Please let me know what you think about the PR.

Edit: I will update code documentation to reflect the availability of named bound parameters as well as array bound params.

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

No branches or pull requests

2 participants