Skip to content

Commit f17cc5a

Browse files
committed
JS: Move all hidden node definitions into DataFlowPrivate
1 parent 47cc3c0 commit f17cc5a

File tree

2 files changed

+26
-34
lines changed

2 files changed

+26
-34
lines changed

javascript/ql/lib/semmle/javascript/dataflow/Configuration.qll

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ private import internal.AccessPaths
7575
private import semmle.javascript.Unit
7676
private import semmle.javascript.internal.CachedStages
7777
private import AdditionalFlowSteps
78+
private import internal.DataFlowPrivate as DataFlowPrivate
7879

7980
/**
8081
* A data flow tracking configuration for finding inter-procedural paths from
@@ -1794,39 +1795,7 @@ deprecated class MidPathNode extends PathNode, MkMidNode {
17941795
* Holds if this node is hidden from paths in path explanation queries, except
17951796
* in cases where it is the source or sink.
17961797
*/
1797-
predicate isHidden() { PathNode::shouldNodeBeHidden(nd) }
1798-
}
1799-
1800-
/** Companion module to the `PathNode` class. */
1801-
module PathNode {
1802-
/** Holds if `nd` should be hidden in data flow paths. */
1803-
predicate shouldNodeBeHidden(DataFlow::Node nd) {
1804-
// TODO: move to DataFlowPrivate
1805-
// Skip phi, refinement, and capture nodes
1806-
nd.(DataFlow::SsaDefinitionNode).getSsaVariable().getDefinition() instanceof
1807-
SsaImplicitDefinition
1808-
or
1809-
// Skip SSA definition of parameter as its location coincides with the parameter node
1810-
nd = DataFlow::ssaDefinitionNode(Ssa::definition(any(SimpleParameter p)))
1811-
or
1812-
// Skip to the top of big left-leaning string concatenation trees.
1813-
nd = any(AddExpr add).flow() and
1814-
nd = any(AddExpr add).getAnOperand().flow()
1815-
or
1816-
// Skip the exceptional return on functions, as this highlights the entire function.
1817-
nd = any(DataFlow::FunctionNode f).getExceptionalReturn()
1818-
or
1819-
// Skip the special return node for functions, as this highlights the entire function (and the returned expr is the previous node).
1820-
nd = any(DataFlow::FunctionNode f).getReturnNode()
1821-
or
1822-
// Skip the synthetic 'this' node, as a ThisExpr will be the next node anyway
1823-
nd = DataFlow::thisNode(_)
1824-
or
1825-
// Skip captured variable nodes as the successor will be a use of that variable anyway.
1826-
nd = DataFlow::capturedVariableNode(_)
1827-
or
1828-
nd instanceof DataFlow::FunctionSelfReferenceNode
1829-
}
1798+
predicate isHidden() { DataFlowPrivate::nodeIsHidden(nd) }
18301799
}
18311800

18321801
/**

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,30 @@ DataFlowType getNodeType(Node node) {
604604
}
605605

606606
predicate nodeIsHidden(Node node) {
607-
DataFlow::PathNode::shouldNodeBeHidden(node)
607+
// Skip phi, refinement, and capture nodes
608+
node.(DataFlow::SsaDefinitionNode).getSsaVariable().getDefinition() instanceof
609+
SsaImplicitDefinition
610+
or
611+
// Skip SSA definition of parameter as its location coincides with the parameter node
612+
node = DataFlow::ssaDefinitionNode(Ssa::definition(any(SimpleParameter p)))
613+
or
614+
// Skip to the top of big left-leaning string concatenation trees.
615+
node = any(AddExpr add).flow() and
616+
node = any(AddExpr add).getAnOperand().flow()
617+
or
618+
// Skip the exceptional return on functions, as this highlights the entire function.
619+
node = any(DataFlow::FunctionNode f).getExceptionalReturn()
620+
or
621+
// Skip the special return node for functions, as this highlights the entire function (and the returned expr is the previous node).
622+
node = any(DataFlow::FunctionNode f).getReturnNode()
623+
or
624+
// Skip the synthetic 'this' node, as a ThisExpr will be the next node anyway
625+
node = DataFlow::thisNode(_)
626+
or
627+
// Skip captured variable nodes as the successor will be a use of that variable anyway.
628+
node = DataFlow::capturedVariableNode(_)
629+
or
630+
node instanceof DataFlow::FunctionSelfReferenceNode
608631
or
609632
node instanceof FlowSummaryNode
610633
or

0 commit comments

Comments
 (0)