Skip to content

Conversation

@Napalys
Copy link
Contributor

@Napalys Napalys commented Sep 15, 2025

Added modeling for the following promisification related packages:

@github-actions github-actions bot added the JS label Sep 15, 2025
@Napalys Napalys marked this pull request as ready for review September 16, 2025 06:10
@Napalys Napalys requested a review from a team as a code owner September 16, 2025 06:10
Copilot AI review requested due to automatic review settings September 16, 2025 06:10
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 enhances the JavaScript analysis by adding comprehensive modeling for promisification libraries and improving data flow through promisified functions.

  • Added support for seven new promisification libraries including @gar/promisify, es6-promisify, util.promisify, thenify-all, call-me-maybe, @google-cloud/promisify, and util-promisify
  • Enhanced data flow tracking to handle promisified user-defined functions
  • Added API graph support for promisified object member access

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
javascript/ql/test/query-tests/Security/CWE-078/CommandInjection/promisification.js Test file demonstrating command injection vulnerabilities through various promisification libraries
javascript/ql/test/query-tests/Security/CWE-078/CommandInjection/CommandInjection.expected Expected test results for the new promisification test cases
javascript/ql/lib/semmle/javascript/dataflow/PromisifyFlow.qll New module providing data flow steps for promisified user-defined function calls
javascript/ql/lib/semmle/javascript/dataflow/DataFlow.qll Imports the new PromisifyFlow module
javascript/ql/lib/semmle/javascript/Promises.qll Extended PromisifyCall and PromisifyAllCall classes to support new libraries
javascript/ql/lib/semmle/javascript/ApiGraphs.qll Added handling for promisified object member access in API graphs
javascript/ql/lib/ext/call-me-maybe.model.yml New model file for the call-me-maybe library
javascript/ql/lib/change-notes/2025-09-15-promisifications.md Release notes documenting the new promisification features

Comment on lines +28 to +29
const promisify2 = require('util.promisify-all');
const promisifiedCp = promisify2(cp);
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

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

[nitpick] The variable name 'promisify2' is inconsistent with the naming pattern used elsewhere in the file. Consider using 'promisifyAll' to match the library's functionality and improve clarity.

Suggested change
const promisify2 = require('util.promisify-all');
const promisifiedCp = promisify2(cp);
const promisifyAll = require('util.promisify-all');
const promisifiedCp = promisifyAll(cp);

Copilot uses AI. Check for mistakes.
const code = req.body; // $ Source
cpThenifyAll.exec(code); // $ Alert
cpThenifyAll.execSync(code); // $ Alert
cpThenifyAll.execFile(code); // $ SPURIOUS: Alert - not promisified, as it is not listed in `thenifyAll`, but it should fine to flag it
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

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

The comment contains a grammatical error. 'but it should fine to flag it' should be 'but it should be fine to flag it'.

Suggested change
cpThenifyAll.execFile(code); // $ SPURIOUS: Alert - not promisified, as it is not listed in `thenifyAll`, but it should fine to flag it
cpThenifyAll.execFile(code); // $ SPURIOUS: Alert - not promisified, as it is not listed in `thenifyAll`, but it should be fine to flag it

Copilot uses AI. Check for mistakes.
app.post('/eval', async (req, res) => {
const maybe = require('call-me-maybe');
const code = req.body; // $ Source

Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

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

There is unnecessary trailing whitespace on line 115. This should be removed for consistency with the rest of the codebase.

Suggested change

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@asgerf asgerf left a comment

Choose a reason for hiding this comment

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

One minor comments otherwise looks good to merge

exists(
DataFlow::SourceNode promisifiedObj, DataFlow::SourceNode originalObj, string member
|
promisifiedObj instanceof Promisify::PromisifyAllCall and
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just set the type of promisifiedObj to Promisify::PromifiyAllCall?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair 😄 Fixed 49ccb8c

@Napalys Napalys requested a review from asgerf September 16, 2025 11:14
@Napalys Napalys merged commit 97a11de into github:main Sep 16, 2025
15 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