Skip to content

JS: Add ModuleImportNode::Range#945

Merged
semmle-qlci merged 3 commits intogithub:masterfrom
asger-semmle:extensible-module-import
Feb 26, 2019
Merged

JS: Add ModuleImportNode::Range#945
semmle-qlci merged 3 commits intogithub:masterfrom
asger-semmle:extensible-module-import

Conversation

@asger-semmle
Copy link
Contributor

Will conflict with #934 which is undergoing a long evaluation. Will evaluate this after rebasing on that.

Would very much appreciate it if this could make it into 1.20, which is why I'm opening this ASAP.

@asger-semmle asger-semmle requested a review from a team as a code owner February 15, 2019 14:00
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

LGTM modulo the missing evaluation, and some very minor docstring comments.
I assume the big diff is just due to moving code around.


module ModuleImportNode {
/**
* Data flow node that refers to an imported module.
Copy link

Choose a reason for hiding this comment

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

Missing A?

A data flow node that refers to an imported module.

* Gets a (default) import of the module with the given path, such as `require("fs")`
* or `import * as fs from "fs"`.
*
* This predicate can be customized by subclassing `ModuleImportNode::Range`.
Copy link

Choose a reason for hiding this comment

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

Do we use "customized" like this anywhere else?
You can only add ModuleImportNodes to this predicate when subclassing ModuleImportNode::Range, so "customize" seems like a stretch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to "extended"

@ghost ghost added the JS label Feb 20, 2019
/**
* Data flow node that refers to an imported module.
*/
abstract class Range extends DataFlow::SourceNode {

Choose a reason for hiding this comment

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

Do we need this to extend DataFlow::SourceNode itself, or could it extend DataFlow::SourceNode::Range instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extending SourceNode::Range will add more dependencies, which could lead to negative recursion or performance issues. I believe there was only a one-way dependency between ModuleImportNode and SourceNode previously so it seems safer to keep it that way.

@xiemaisi
Copy link

LGTM, modulo minor comments. I don't think this needs an evaluation, but if you want to do a quick sanity check I won't stand in your way.

@asger-semmle asger-semmle force-pushed the extensible-module-import branch from 7dd02c1 to 707886f Compare February 25, 2019 11:41
@asger-semmle
Copy link
Contributor Author

Evaluation with just Xss.ql looks fine. I also checked the profile viewer and they look identical.

@semmle-qlci semmle-qlci merged commit 00d490e into github:master Feb 26, 2019
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.

3 participants