Skip to content

Commit d4ead64

Browse files
committed
JS: Refactor toDataFlowNode
1 parent cc98de5 commit d4ead64

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

javascript/ql/lib/semmle/javascript/dataflow/internal/CallGraphs.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module CallGraph {
1414
Function getAFunctionValue(AnalyzedNode node) {
1515
result = node.getAValue().(AbstractCallable).getFunction()
1616
or
17-
node = NameResolution::trackFunctionValue(result).toDataFlowNode()
17+
node = NameResolution::trackFunctionValue(result).toDataFlowNodeOut()
1818
or
1919
exists(DataFlow::Node pred |
2020
AccessPath::step(pred, node) and

javascript/ql/lib/semmle/javascript/dataflow/internal/FlowSteps.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,13 @@ private module CachedSteps {
336336
// TODO: Ensure name resolution has good enough support for NodeJS and AMD
337337
exists(NameResolution::Node node1, NameResolution::Node node2 |
338338
NameResolution::ValueFlow::resolvedReadStep(node1, node2) and
339-
pred = node1.toDataFlowNode() and
340-
succ = node2.toDataFlowNode()
339+
pred = node1.toDataFlowNodeIn() and
340+
succ = node2.toDataFlowNodeOut()
341341
)
342342
or
343343
exists(Import imprt, Module mod |
344344
imprt.getImportedModule() = mod and
345-
pred = NameResolution::getModuleBulkExport(mod).toDataFlowNode() and
345+
pred = NameResolution::getModuleBulkExport(mod).toDataFlowNodeIn() and
346346
succ = imprt.getImportedModuleNodeStrict()
347347
)
348348
}

javascript/ql/lib/semmle/javascript/internal/NameResolution.qll

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,21 @@ module NameResolution {
3535
result = this.(JSDocTypeExpr).getLocation()
3636
}
3737

38-
DataFlow::Node toDataFlowNode() {
38+
DataFlow::Node toDataFlowNodeIn() {
3939
result = DataFlow::valueNode(this)
4040
or
41-
// TODO: refactor graph to avoid the need for this
41+
result = DataFlow::valueNode(this.(Variable).getAnAssignedExpr())
42+
}
43+
44+
DataFlow::Node toDataFlowNodeOut() {
45+
result = DataFlow::valueNode(this)
46+
or
47+
result = DataFlow::valueNode(this.(Variable).getAnAccess())
48+
or
4249
exists(ImportSpecifier spec |
4350
this = spec.getLocal() and
4451
result = DataFlow::valueNode(spec)
4552
)
46-
or
47-
exists(ExportDeclaration exprt, string name |
48-
exprt.exportsAs(this, name) and
49-
result = exprt.getSourceNode(name)
50-
)
5153
}
5254
}
5355

0 commit comments

Comments
 (0)