Skip to content

Conversation

asgerf
Copy link
Contributor

@asgerf asgerf commented Dec 17, 2024

Synthesizes a callable for each class, which invokes the class constructor and every
instance method with the same value of this.

This ensures flow between methods in a class when the source originated "within the class",
but not when the flow into the field came from an argument.

For example:

class C {
  constructor(arg) {
    this.x = sourceOfTaint();
    this.y = arg;
  }
  method() {
    sink(this.x); // sourceOfTaint() flows here
    sink(this.y); // but 'arg' does not flow here (only through real call sites)
  }
}

The class harness for a class C can roughly be thought of as the following code:

function classHarness() {
  var c = new C();
  while (true) {
    // call an arbitrary instance methods in the loop
    c.arbitraryInstaceMethod();
  }
}

This is realized with the following data flow graph:

[Call to constructor]
    |
    | post-update for 'this' argument
    V
[Data flow node]   <----------------------+
    |                                     |
    | 'this' argument                     | post-update for 'this' argument
    V                                     |
 [Call to an instance method]  -----------+

Evaluation shows an 85% slowdown in vscode, so more work is needed before this can be merged.

@github-actions github-actions bot added the JS label Dec 17, 2024
@asgerf asgerf added the WIP This is a work-in-progress, do not merge yet! label Dec 17, 2024
@asgerf asgerf deleted the branch github:js/shared-dataflow-branch January 16, 2025 10:29
@asgerf asgerf closed this Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JS WIP This is a work-in-progress, do not merge yet!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant