Skip to content

JavaScript: Lift call graph library to data flow graph. #15

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
1 commit merged into from
Aug 7, 2018

Conversation

xiemaisi
Copy link

@xiemaisi xiemaisi commented Aug 6, 2018

This PR lifts CallSite from the AST to the data flow graph by adding the relevant API to DataFlow::InvokeNode.

Among other things, this necessitates a change in our handling of spread arguments: InvokeNode.getArgument(i) is now only defined if there isn't a spread argument at or before position i, and similarly for getNumArgument. This is different from InvokeExpr.getArgument, but I think it's almost always what we want.

In addition to AST-based call nodes, we introduce new reflective call nodes representing the reflective call happening at a .call or .apply invocation. I've separated the abstract classes we need to present a unified interface for explicit and reflective calls from the concrete classes we use to classify the various kinds of calls and invocations. In particular, this allows us to keep InvokeNode and its subclasses concrete.

There is a performance overhead (internal link). The source of the slowdown wasn't obvious from the logs, so I tried adding a bit of explicit caching here and there, but none of that made any difference. I still have a few more ideas, but for now perhaps we'll need to merge this as-is to unblock further data flow graph development.

Results are almost unchanged, except for two new TPs that arise from the fact that we now allow ourselves to interpret f.apply as a call to a method apply of f if it exists (previously ReflectiveCallSite overrode getACallee, causing us to always consider it as a reflective call).

@xiemaisi xiemaisi requested a review from a team August 6, 2018 07:31
@xiemaisi xiemaisi force-pushed the js/call-graph-data-flow branch from 6e1bb51 to 9ba3d80 Compare August 6, 2018 07:34
@ghost ghost self-assigned this Aug 6, 2018
nickrolfe pushed a commit to nickrolfe/codeql that referenced this pull request Aug 6, 2018
JavaScript: Add missing query to security suite.
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

This still LGTM, as discussed internally.

@ghost ghost merged commit c06edd3 into github:master Aug 7, 2018
@xiemaisi xiemaisi deleted the js/call-graph-data-flow branch August 7, 2018 10:01
@kamarcum kamarcum unassigned ghost Apr 28, 2020
aibaars pushed a commit that referenced this pull request Oct 14, 2021
smowton pushed a commit to smowton/codeql that referenced this pull request Oct 28, 2021
Kotlin: Populate the compilation_compiling_files table
erik-krogh referenced this pull request in erik-krogh/ql Dec 15, 2021
Resolve inheritable members (fields and member predicates)
erik-krogh referenced this pull request in erik-krogh/ql Dec 15, 2021
Resolve inheritable members (fields and member predicates)
dbartol pushed a commit that referenced this pull request Dec 18, 2024
This pull request was closed.
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.

1 participant