Skip to content

Commit b6b93dc

Browse files
authored
Merge pull request github#18392 from asgerf/jss/deprecate-modules
JS: Deprecate some .qll files
2 parents abea019 + 36f0d2f commit b6b93dc

File tree

9 files changed

+50
-54
lines changed

9 files changed

+50
-54
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* Alias for the library `semmle.javascript.explore.BackwardDataFlow`.
33
*/
4+
deprecated module;
45

56
import semmle.javascript.explore.BackwardDataFlow

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

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,15 @@
6767
* Finally, we build `PathNode`s for all nodes that appear on a path
6868
* computed by `onPath`.
6969
*/
70+
deprecated module;
7071

7172
private import javascript
7273
private import internal.FlowSteps
7374
private import internal.AccessPaths
7475
private import semmle.javascript.Unit
7576
private import semmle.javascript.internal.CachedStages
7677
private import AdditionalFlowSteps
78+
private import internal.DataFlowPrivate as DataFlowPrivate
7779

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

18311801
/**
@@ -2031,22 +2001,6 @@ deprecated private class CallAgainstEqualityCheck extends DerivedBarrierGuardNod
20312001
override predicate appliesTo(Configuration cfg) { isBarrierGuardInternal(cfg, prev) }
20322002
}
20332003

2034-
/**
2035-
* A guard node for a variable in a negative condition, such as `x` in `if(!x)`.
2036-
* Can be added to a `isBarrier` in a data-flow configuration to block flow through such checks.
2037-
*/
2038-
class VarAccessBarrier extends DataFlow::Node {
2039-
// TODO: This does not work in dataflow2 when the variable is captured, since the capture-flow library bypasses the refinement node.
2040-
VarAccessBarrier() {
2041-
exists(ConditionGuardNode guard, SsaRefinementNode refinement |
2042-
this = DataFlow::ssaDefinitionNode(refinement) and
2043-
refinement.getGuard() = guard and
2044-
guard.getTest() instanceof VarAccess and
2045-
guard.getOutcome() = false
2046-
)
2047-
}
2048-
}
2049-
20502004
/**
20512005
* Holds if there is a path without unmatched return steps from `source` to `sink`.
20522006
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1929,7 +1929,7 @@ module DataFlow {
19291929
import Nodes
19301930
import Sources
19311931
import TypeInference
1932-
import Configuration
1932+
deprecated import Configuration
19331933
import TypeTracking
19341934
import AdditionalFlowSteps
19351935
import internal.FunctionWrapperSteps
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* Alias for the library `semmle.javascript.explore.ForwardDataFlow`.
33
*/
4+
deprecated module;
45

56
import semmle.javascript.explore.ForwardDataFlow

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,3 +1708,18 @@ class RegExpCreationNode extends DataFlow::SourceNode {
17081708
result = this.getAReference(DataFlow::TypeTracker::end())
17091709
}
17101710
}
1711+
1712+
/**
1713+
* A guard node for a variable in a negative condition, such as `x` in `if(!x)`.
1714+
* Can be added to a `isBarrier` in a data-flow configuration to block flow through such checks.
1715+
*/
1716+
class VarAccessBarrier extends DataFlow::Node {
1717+
VarAccessBarrier() {
1718+
exists(ConditionGuardNode guard, SsaRefinementNode refinement |
1719+
this = DataFlow::ssaDefinitionNode(refinement) and
1720+
refinement.getGuard() = guard and
1721+
guard.getTest() instanceof VarAccess and
1722+
guard.getOutcome() = false
1723+
)
1724+
}
1725+
}

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import javascript
8-
import semmle.javascript.dataflow.Configuration
8+
deprecated import semmle.javascript.dataflow.Configuration
99
import semmle.javascript.dataflow.internal.CallGraphs
1010
private import semmle.javascript.internal.CachedStages
1111

javascript/ql/lib/semmle/javascript/explore/BackwardDataFlow.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
* Backward exploration in particular does not scale on non-trivial code bases and hence is of limited
1313
* usefulness as it stands.
1414
*/
15+
deprecated module;
1516

1617
import javascript
1718

18-
private class BackwardExploringConfiguration extends DataFlow::Configuration {
19+
deprecated private class BackwardExploringConfiguration extends DataFlow::Configuration {
1920
BackwardExploringConfiguration() { this = any(DataFlow::Configuration cfg) }
2021

2122
override predicate isSource(DataFlow::Node node) { any() }

javascript/ql/lib/semmle/javascript/explore/ForwardDataFlow.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
*
1111
* NOTE: This library should only be used for debugging and exploration, not in production code.
1212
*/
13+
deprecated module;
1314

1415
import javascript
1516

16-
private class ForwardExploringConfiguration extends DataFlow::Configuration {
17+
deprecated private class ForwardExploringConfiguration extends DataFlow::Configuration {
1718
ForwardExploringConfiguration() { this = any(DataFlow::Configuration cfg) }
1819

1920
override predicate isSink(DataFlow::Node node) { any() }

0 commit comments

Comments
 (0)