Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS: New query: missing await #2525

Merged
merged 9 commits into from
Jan 8, 2020

Conversation

asgerf
Copy link
Contributor

@asgerf asgerf commented Dec 12, 2019

Adds a query to flag cases where a promise was used, but where the intention most likely to use the result of the promise instead.

Null checks are particularly interesting here. async functions never return null, and so a null check will silently fail.

We use the call graph and static types to recognize promises, although I'm not sure how much use we get from the static types are here, as we probably only flag what the type checker would have flagged anyway. As seen here it gets noisy if we assume something of a promise type is non-nullable, so we can't use them to flag null checks.

Contains a drive-by change to getImmediatePredecessor to make it step through phi nodes whose operands are all refinements of the same value. I couldn't resist calling such nodes rephinement nodes.

Still need to run an evaluation, especially of the second commit.

@asgerf asgerf added JS WIP This is a work-in-progress, do not merge yet! labels Dec 12, 2019
Copy link
Collaborator

@max-schaefer max-schaefer left a comment

Choose a reason for hiding this comment

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

Nice idea! A few initial thoughts.

max-schaefer
max-schaefer previously approved these changes Jan 7, 2020
javascript/ql/src/Expressions/MissingAwait.qhelp Outdated Show resolved Hide resolved
Co-Authored-By: Max Schaefer <54907921+max-schaefer@users.noreply.github.com>
@asgerf
Copy link
Contributor Author

asgerf commented Jan 8, 2020

Evaluation looks ok - there is a slight cost of the change to getImmediatePredecessor and some new (boring) results from the range analysis as a result.

@asgerf asgerf marked this pull request as ready for review January 8, 2020 10:28
@asgerf asgerf requested review from mchammer01 and a team as code owners January 8, 2020 10:28
@asgerf asgerf removed the WIP This is a work-in-progress, do not merge yet! label Jan 8, 2020
@max-schaefer max-schaefer merged commit 308da07 into github:master Jan 8, 2020
@max-schaefer
Copy link
Collaborator

@mchammer01: apologies, I merged this without realising that you hadn't reviewed the query help yet. The preview is still available here.

@mchammer01
Copy link
Contributor

I'll take a look when I can (have been having back-to-back meetings all week and wasn't in yesterday).

@mchammer01
Copy link
Contributor

@asgerf - this LGTM but you need to add this new query to the change-notes/1.24/analysis-javascript.md file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants