Skip to content

Conversation

asgerf
Copy link
Contributor

@asgerf asgerf commented Jun 8, 2020

This makes the array steps for .map, .forEach, and for-of loops work for type tracking by default, which, in combination with #3639 is needed to get call edges in https://github.com/github/codeql-javascript-CVE-coverage/issues/721.

Due to negative recursion, it's not possible to use AdditionalFlowStep in the core type tracking library, since some contributions to that class depend on negatively on type tracking (and positive dependencies would likely cause performance issues).

This therefore introduces an internal class, PreCallGraphStep, whose steps are contributed to both AdditionalFlowStep and AdditionalTypeTrackingStep. This third class is needed since neither class of steps can contribute their contents to the other:

  • The contents of AdditionalFlowSteps can't be included in AdditionalTypeTrackingStep due to negative recursion.
  • The contents of AdditionalTypeTrackingStep should in principle not be included in AdditionalFlowSteps since type tracking steps are generally allowed to be more imprecise.

The new class uses a unit type as base, but since this is an internal class we are free to change this later. For pure data flow steps, there isn't generally a need to categorize the steps so it seems independent of how we handle #3603.

Evaluations:

TODO

@asgerf asgerf added JS Awaiting evaluation Do not merge yet, this PR is waiting for an evaluation to finish labels Jun 8, 2020
erik-krogh
erik-krogh previously approved these changes Jun 8, 2020
Copy link
Contributor

@erik-krogh erik-krogh left a comment

Choose a reason for hiding this comment

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

LGTM.

I think we should refactor PromiseTypeTracking to use the same pattern post-sprint.

@asgerf asgerf removed the Awaiting evaluation Do not merge yet, this PR is waiting for an evaluation to finish label Jun 15, 2020
@asgerf asgerf marked this pull request as ready for review June 15, 2020 19:42
@asgerf asgerf requested a review from a team as a code owner June 15, 2020 19:42
@asgerf
Copy link
Contributor Author

asgerf commented Jun 15, 2020

The evaluation on security/nightly looks fairly safe.

Copy link
Contributor

@erik-krogh erik-krogh left a comment

Choose a reason for hiding this comment

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

Now that #3639 is closed, the name PreCallGraphStep might not be the most descriptive, as the steps are not used in the callgraph. (There is also a few doc-strings that might need updating).

@asgerf
Copy link
Contributor Author

asgerf commented Jun 16, 2020

Type tracking is still mutually recursive with call graph construction, since classes and instances are type-tracked, and they affect the call graph.

Copy link
Contributor

@erik-krogh erik-krogh left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@semmle-qlci semmle-qlci merged commit 07bff64 into github:master Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants