-
Notifications
You must be signed in to change notification settings - Fork 1.7k
JS: Barrier guard improvements #2251
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
Merged
semmle-qlci
merged 4 commits into
github:master
from
asger-semmle:barrier-guard-improvements
Nov 7, 2019
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e2b0ec5
JS: Handle multiple and/or operators in SanitizerFunction
asger-semmle d615842
JS: Generalize SanitizerFunction to data flow configs and flow labels
asger-semmle f48d16f
JS: Support barrier guards that are reflective calls
asger-semmle c373be0
JS: Update TaintBarriers test
asger-semmle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think I've previously had the same issue as the one you are solving here.
Could there be an idea in changing
DataFlow::Node::asExpr()
to include reflective calls, or lift this method toDataFlow::Node
?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.
In any case
getExpr
might not be the most descriptive name.asExprInclReflectiveCalls
? (But that name feels too long, feel free to ignore).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 think that leads to a recursion mess, and also a mess of contepts. I would prefer the second option:
But a good name escapes me.
asUnderlyingExpr
is my best suggestion.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.
My main gripe with using
asExpr()
is that two data flow nodes can suddenly map to the same expression, which brings along its own set of new pitfalls. But maybe we should do it anyway? It's essentially the same issue as parameter nodes not having AST nodes.The general solution is to take the thing you know is an expression (
getTest()
), map that to a data-flow node, and follow up withgetImmediatePredecessor
,getAPredecessor
, orgetALocalSource
. The third version I mentioned in the PR description usedgetImmediatePredecessor
but I backed it out again, because it required more work for that generalization to actually work beyond reflective calls.@erik-krogh Can you find out what it was? It might help us figure out which solution works best.
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.
From looking around I can't immediately find an instance of me solving the issue, but I think that is because I ended up not solving it.
The issue definitely exists in
UseOfReturnlessFunction
, which has no explicit handling of reflective calls, andDataFlow::CallNode::asExpr()
is thereforenone()
.As a consequence,
UseOfReturnlessFunction
has an FP on the last line in this example: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.
How about
DataFlow::Node::getEnclosingExpr()
orgetEnclosingAstNode()
? This would map reflective calls to theCallExpr
, parameter nodes to theParameter
, andValueNode
to the AST node.(To elaborate on my previous point, extending
asExpr()
andflow()
can lead to unfortunate cases where code likeexpr.flow().(CallNode).getArgument(0)
returns the first two arguments.)Anyways, I think it's a bit out of scope for this PR, but I'm happy to continue the discussion here. Ping @max-schaefer.
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'm currently doing a dist-compare on an implementation of
DataFlow::Node::getEnclosingExpr()
.The evaluation is on
UseOfReturnlessFunction
, where i changed someasExpr()
togetEnclosingExpr()
, which definitely removes some false positives.If the results are good I'll land it in a PR.