Skip to content

Conversation

@asgerf
Copy link
Contributor

@asgerf asgerf commented Oct 6, 2025

Restricts the flow of use/def nodes in API graphs to not follow argument-passing edges for receivers of method calls.

When tracking a use-node, the intent is to track an object that was created in external code (usually an imported library). Such objects will generally not have methods that were defined in the current codebase, except in subclassing scenarios which is modelled by other means (not by argument-passing).

This fixes a performance issue observed in some codebases.

@github-actions github-actions bot added the JS label Oct 6, 2025
@asgerf asgerf marked this pull request as ready for review October 7, 2025 10:28
@asgerf asgerf requested a review from a team as a code owner October 7, 2025 10:28
Copilot AI review requested due to automatic review settings October 7, 2025 10:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR restricts receiver-flow in API graphs to improve performance by preventing flow tracking from following argument-passing edges for receivers of method calls. The change recognizes that external library objects typically don't have methods defined in the current codebase, making such tracking unnecessary except in subclassing scenarios which are handled separately.

Key changes:

  • Introduces a new CallReceiverStep type to distinguish receiver argument-passing from regular argument-passing
  • Blocks API graph tracking through receiver steps to prevent unnecessary flow analysis
  • Adds test case to verify the new behavior with explicit receiver binding

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
javascript/ql/lib/semmle/javascript/dataflow/internal/StepSummary.qll Introduces CallReceiverStep type and logic to detect method dispatch receivers
javascript/ql/lib/semmle/javascript/dataflow/TypeTracking.qll Updates type tracking to handle the new CallReceiverStep
javascript/ql/lib/semmle/javascript/ApiGraphs.qll Blocks API graph tracking through receiver steps
javascript/ql/test/ApiGraphs/explicit-this/tst.js Test case demonstrating explicit receiver binding scenario
javascript/ql/test/ApiGraphs/explicit-this/package.json Package configuration for test case
javascript/ql/test/ApiGraphs/explicit-this/VerifyAssertions.ql Test query to verify assertions

@asgerf asgerf added the no-change-note-required This PR does not need a change note label Oct 7, 2025
Copy link
Contributor

@Napalys Napalys left a comment

Choose a reason for hiding this comment

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

Looks good to me. 👍

@asgerf asgerf merged commit 10c9b74 into github:main Oct 8, 2025
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JS no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants