-
Notifications
You must be signed in to change notification settings - Fork 1.8k
JS: Adding model for .get
function of Map
in Unvalidated Dynamic Method Call
#7828
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
Conversation
javascript/ql/test/query-tests/Security/CWE-754/UnvalidatedDynamicMethodCallGood4.js
Outdated
Show resolved
Hide resolved
app.get('/perform/:action/:payload', function(req, res) { | ||
let action = actions.get(req.params.action); | ||
// GOOD: `action` is either the `play` or the `pause` function from above | ||
if (typeof action === 'function') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be flagged because action
cannot be from proto
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds right, a call to get
on a map shouldn't be able to return something from the prototype.
I've seen a bunch of get implementations that are implemented like function get(x) {return obj[x];}
, but if that's the case, then the query should pick up on the dynamic property read inside the get
function.
.get
function of Map
.get
function of Map
in Unvalidated Dynamic Method Call
.get
function of Map
in Unvalidated Dynamic Method Call.get
function of Map
in Unvalidated Dynamic Method Call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Good work!
Just two comments about the placement of the // OK
comments.
javascript/ql/test/query-tests/Security/CWE-754/UnvalidatedDynamicMethodCallGood4.js
Outdated
Show resolved
Hide resolved
javascript/ql/test/query-tests/Security/CWE-754/UnvalidatedDynamicMethodCallGood3.js
Outdated
Show resolved
Hide resolved
…amicMethodCallGood4.js Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
…amicMethodCallGood3.js Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
And my suggestions made it so the |
Ah, just realized that line numbers changed! Yes, will fix the expected files! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I'll do a small evaluation to check if there is a performance regression (I highly doubt that), and then I'll merge it.
Fixes the first part of #7803
Thanks to @max-schaefer for suggesting the dataflow alternative of enhancement I proposed
Summary of changes -
.get
function ofMap