Skip to content

JS: Call graph improvements #15823

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
merged 6 commits into from
Mar 8, 2024
Merged

Conversation

asgerf
Copy link
Contributor

@asgerf asgerf commented Mar 6, 2024

Does two things:

  • Loosens the restriction for when to track objects with methods. Previously the object had to be an allocation site, now it can be any SourceNode other than this inside a constructor (functions stored on that are instead seen as instance methods).
  • Improves detection of function-style classes, by looking for functions that are invoked with new.

The tracking of objects affects the call graph directly, and also contributes to the impliedReceiverStep, which causes the host object to flow into this in the body of method:

bar().foo = function() { 
  this; // <- value of bar() now flows here
}

Evaluation shows neutral performance and about 24k new call edges and a few new alerts. The alerts I've looked at are due new TP call edges.

@github-actions github-actions bot added the JS label Mar 6, 2024
@asgerf asgerf marked this pull request as ready for review March 7, 2024 12:36
@asgerf asgerf requested a review from a team as a code owner March 7, 2024 12:36
RasmusWL
RasmusWL previously approved these changes Mar 8, 2024
Copy link
Member

@RasmusWL RasmusWL left a comment

Choose a reason for hiding this comment

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

After talking this PR through offline, I think it looks reasonable. I have a minor suggestion for wording of a comment, but that can be considered more of a nitpick 😊

…hs.qll

Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
@asgerf asgerf merged commit 7c35309 into github:main Mar 8, 2024
RasmusWL added a commit to RasmusWL/codeql that referenced this pull request Mar 12, 2024
RasmusWL added a commit to RasmusWL/codeql that referenced this pull request Mar 12, 2024
RasmusWL added a commit to RasmusWL/codeql that referenced this pull request Mar 15, 2024
RasmusWL added a commit to RasmusWL/codeql that referenced this pull request Mar 15, 2024
RasmusWL added a commit to RasmusWL/codeql that referenced this pull request Mar 18, 2024
RasmusWL added a commit to RasmusWL/codeql that referenced this pull request Mar 18, 2024
RasmusWL added a commit that referenced this pull request Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants