Skip to content

JS: Improve support for NodeJS pipe callbacks - #22808

Open
MathiasVP wants to merge 18 commits into
github:mainfrom
MathiasVP:js-better-nodejs-callback-support-cleaned-up
Open

MathiasVP wants to merge 18 commits into
github:mainfrom
MathiasVP:js-better-nodejs-callback-support-cleaned-up

Conversation

@MathiasVP

Copy link
Copy Markdown
Contributor

The gist of these changes is to add modeling for:

class PipedDestination extends Writable {
  write(chunk) {
    sink(chunk);
    return true;
  }
}

Readable.from([source()]).pipe(new PipedDestination());

This is done in f083ced. However, Copilot kept informing me of other, related, APIs that should also have modeling. And thus comes the flurry of subsequent commits that add more modeling 😰

I've done my best to babysit Copilot so that the code looks reasonable, and the commits are somewhat reviewable.

DCA looks uneventful (after some join order fixes in a couple of queries)

@MathiasVP
MathiasVP requested a review from a team as a code owner October 12, 2026 11:57
Copilot AI balanced review requested due to automatic review settings October 12, 2026 11:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The extensive call-graph and synthesized-node modeling warrants final human validation for precision and performance.

0 open findings

What changed in this PR

Improves JavaScript data-flow modeling for Node.js stream pipelines and their callbacks.

Changes:

  • Models chunks from Readable.from through pipe, write, _write, and _transform.
  • Preserves piped file-stream data as filesystem-read sources.
  • Adds extensive stream-flow tests and query join-order hints.
File Description
javascript/​ql/​lib/​semmle/​javascript/​frameworks/​NodeJSLib.qll Adds stream pipeline and callback modeling.
javascript/​ql/​lib/​semmle/​javascript/​security/​dataflow/​ReflectedXssCustomizations.qll Adds optimizer binding hints.
javascript/​ql/​lib/​semmle/​javascript/​security/​dataflow/​UnsafeJQueryPluginCustomizations.qll Adds optimizer binding hints.
javascript/​ql/​lib/​change-notes/​2026-10-12-nodejs-stream-pipe.md Documents improved stream modeling.
javascript/​ql/​test/​library-tests/​frameworks/​NodeJSLib/​StreamPipeDataFlow.ql Defines stream flow assertions.
javascript/​ql/​test/​library-tests/​frameworks/​NodeJSLib/​StreamPipeDataFlow.expected Provides generated test expectations.
javascript/​ql/​test/​library-tests/​frameworks/​NodeJSLib/​stream-pipe.js Exercises stream and transform scenarios.
javascript/​ql/​test/​library-tests/​frameworks/​Concepts/​file-access.js Tests piped filesystem reads.
javascript/​ql/​test/​library-tests/​frameworks/​Concepts/​tests.expected Updates generated concept expectations.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@MathiasVP

MathiasVP commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Gee, thanks a lot for this in-depth review, Copilot.

This branch has not been deployed

No deployments
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