Skip to content

Conversation

@asgerf
Copy link
Contributor

@asgerf asgerf commented Sep 5, 2025

Adds support for Promise.try and Array.prototype.with

@github-actions github-actions bot added the JS label Sep 5, 2025
@asgerf asgerf changed the title JS: Add support for Promise.try JS: Support Promise.try and Array.prototype.with Sep 10, 2025
@asgerf asgerf marked this pull request as ready for review September 16, 2025 11:54
@asgerf asgerf requested a review from a team as a code owner September 16, 2025 11:54
Copilot AI review requested due to automatic review settings September 16, 2025 11:54
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 adds support for data flow tracking through two JavaScript methods: Promise.try and Array.prototype.with. These are modern JavaScript features that enable better promise handling and immutable array operations respectively.

  • Implements flow summaries for Promise.try to track data flow through promise creation and execution
  • Implements flow summaries for Array.prototype.with to track data flow through immutable array updates
  • Adds comprehensive test cases to verify data flow behavior for both methods

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
javascript/ql/test/library-tests/TripleDot/promise-try.js Test cases for Promise.try data flow tracking
javascript/ql/test/library-tests/TripleDot/array-with.js Test cases for Array.prototype.with data flow tracking
javascript/ql/src/change-notes/2025-09-16-promise-try-array-with.md Release notes documenting the new features
javascript/ql/lib/semmle/javascript/internal/flow_summaries/Promises.qll Flow summary implementation for Promise.try
javascript/ql/lib/semmle/javascript/internal/flow_summaries/FlowSummaryUtil.qll Utility function to generate argument positions
javascript/ql/lib/semmle/javascript/internal/flow_summaries/Arrays.qll Flow summary implementation for Array.prototype.with

Comment on lines +384 to +387
exists(int i | i = getAnArgumentPosition() |
input = "Argument[" + (i + 1) + "]" and
output = "Argument[0].Parameter[" + i + "]"
)
Copy link
Contributor

@Napalys Napalys Sep 16, 2025

Choose a reason for hiding this comment

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

Just a quick question for my understanding. We would not have flow if a lambda would have more then 10 arguments?
Also what happens if we have ...args(arbitrary number of arguments), will it work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct on both accounts

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 great 👍 , I have just a small question so I would understand better.

@asgerf asgerf merged commit 7670a2b into github:main Sep 16, 2025
16 checks passed
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