Skip to content

JS: Improve support for NodeJS pipe callbacks - #22765

Draft
MathiasVP wants to merge 20 commits into
github:mainfrom
MathiasVP:js-better-nodejs-callback-support
Draft

MathiasVP wants to merge 20 commits into
github:mainfrom
MathiasVP:js-better-nodejs-callback-support

Conversation

@MathiasVP

Copy link
Copy Markdown
Contributor

Somewhat vibe-coded, but I think it looks reasonable (after lots of cleanup).

@MathiasVP MathiasVP added the JS label Oct 6, 2026
@MathiasVP
MathiasVP force-pushed the js-better-nodejs-callback-support branch from 28aa544 to 620f2a8 Compare October 7, 2026 10:25
@MathiasVP
MathiasVP marked this pull request as ready for review October 7, 2026 10:30
@MathiasVP
MathiasVP requested a review from a team as a code owner October 7, 2026 10:30
Copilot AI balanced review requested due to automatic review settings October 7, 2026 10:30

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.

Copilot review overview

🟡 Changes recommended

Standard writable hooks and several supported stream inputs or filesystem variants are not modeled correctly.

Review effort: Balanced
Findings: 5 Medium severity

Open (5)
What changed in this PR

Adds Node.js stream data-flow modeling for Readable.from() and piped destinations.

Changes:

  • Models readable stream factories, fluent methods, and implicit pipe writes.
  • Adds stream pipe flow tests.
  • Documents the analysis improvement.
File Description
NodeJSLib.qll Adds stream and pipe flow modeling.
StreamPipeDataFlow.ql Defines inline flow assertions.
StreamPipeDataFlow.expected Stores expected test results.
stream-pipe.js Provides stream flow test cases.
2026-10-07-nodejs-stream-pipe.md Adds the change note.

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

Comment thread javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll Outdated
Comment thread javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll Outdated
Comment thread javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll Outdated
Comment thread javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll
Comment thread javascript/ql/test/library-tests/frameworks/NodeJSLib/StreamPipeDataFlow.ql Outdated
@MathiasVP
MathiasVP marked this pull request as draft October 7, 2026 10:42
@MathiasVP
MathiasVP force-pushed the js-better-nodejs-callback-support branch from 620f2a8 to 18c8abc Compare October 7, 2026 15:20
@MathiasVP
MathiasVP requested a balanced review from Copilot October 7, 2026 15:20

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.

🟡 Changes recommended

Constructor-option callbacks remain unsupported, and some previously recognized file-stream reads can lose their data node.

2 open findings
5 resolved since last review

🧠 Review effort: Balanced

Comment thread javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll Outdated
Comment thread javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll Outdated
Comment thread javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll Fixed
@MathiasVP
MathiasVP force-pushed the js-better-nodejs-callback-support branch from 18c8abc to 7e88967 Compare October 7, 2026 17:43
@MathiasVP
MathiasVP requested a balanced review from Copilot October 7, 2026 17:43

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.

🟡 Changes recommended

Chained pipes are recognized but do not propagate transformed chunks to downstream destinations.

2 open findings
2 resolved since last review

🧠 Review effort: Balanced

Comment thread javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll
Comment thread javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll
@MathiasVP
MathiasVP force-pushed the js-better-nodejs-callback-support branch from 7e88967 to 4b0d118 Compare October 7, 2026 18:25
@MathiasVP
MathiasVP requested a balanced review from Copilot October 7, 2026 18:25

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.

🟡 Changes recommended

Readable.from(Map) entries currently lose key and value flow before reaching pipe callbacks.

1 open finding
2 resolved since last review

🧠 Review effort: Balanced

Comment thread javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll

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

Override detection can suppress valid stream hooks for imported, conditional, or later-assigned callbacks.

0 open findings

1 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Conditional or late overrides incorrectly suppress native write hooks

javascript/​ql/​lib/​semmle/​javascript/​frameworks/​NodeJSLib.qll:910

This existential assignment check suppresses the native implementation hook even when the assignment is conditional, unreachable, or occurs after the pipe call. In those executions the inherited write still invokes _write/_transform, so the new model loses real flow. Only suppress the hook for an override known to be active at this call; otherwise model both targets conservatively.

This issue also appears on line 940 of the same file.

🧠 Review effort: Balanced

@MathiasVP
MathiasVP force-pushed the js-better-nodejs-callback-support branch from fd1da79 to 9c48dd2 Compare October 7, 2026 19:25
@MathiasVP
MathiasVP requested a balanced review from Copilot October 7, 2026 19:25

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.

🟡 Changes recommended

Stream recognition misses PassThrough flows and incorrectly treats every pipe destination as readable.

3 open findings

🧠 Review effort: Balanced

private predicate streamConstructor(EarlyStageNode node) {
exists(EarlyStageNode base |
base = getAStreamModuleNode() and
memberRead(base, ["Readable", "Duplex", "Transform"], node)
Comment thread javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll
---
category: minorAnalysis
---
* Improved Node.js modeling of `Readable.from(...)` and related methods.
@MathiasVP
MathiasVP force-pushed the js-better-nodejs-callback-support branch from 9c48dd2 to 90dc38c Compare October 8, 2026 14:12
@MathiasVP
MathiasVP requested a balanced review from Copilot October 8, 2026 14:13

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.

🟡 Changes recommended

Definite instance method overrides currently produce impossible flows through bypassed stream hooks.

4 open findings

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll

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.

3 participants