Skip to content

Commit 8f68f51

Browse files
committed
deprecate TrackedNodes.qll
1 parent 6adedac commit 8f68f51

File tree

6 files changed

+29
-110
lines changed

6 files changed

+29
-110
lines changed

javascript/ql/src/semmle/javascript/dataflow/Sources.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Provides support for intra-procedural tracking of a customizable
33
* set of data flow nodes.
44
*
5-
* Note that unlike `TrackedNodes`, this library only performs
5+
* Note that unlike `TypeTracking.qll`, this library only performs
66
* local tracking within a function.
77
*/
88

javascript/ql/src/semmle/javascript/dataflow/TrackedNodes.qll

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/**
2+
* DEPRECATED: Use `TypeTracking.qll` or a `DataFlow::Configuration` from `Configuration.qll` instead.
3+
*
24
* Provides support for inter-procedural tracking of a customizable
35
* set of data flow nodes.
46
*/
@@ -12,7 +14,7 @@ private import internal.FlowSteps as FlowSteps
1214
* To track additional values, extends this class with additional
1315
* subclasses.
1416
*/
15-
abstract class TrackedNode extends DataFlow::Node {
17+
deprecated abstract class TrackedNode extends DataFlow::Node {
1618
/**
1719
* Holds if this node flows into `sink` in zero or more (possibly
1820
* inter-procedural) steps.
@@ -26,7 +28,7 @@ abstract class TrackedNode extends DataFlow::Node {
2628
* To track additional expressions, extends this class with additional
2729
* subclasses.
2830
*/
29-
abstract class TrackedExpr extends Expr {
31+
deprecated abstract class TrackedExpr extends Expr {
3032
predicate flowsTo(Expr sink) {
3133
exists(TrackedExprNode ten | ten.asExpr() = this | ten.flowsTo(DataFlow::valueNode(sink)))
3234
}
@@ -35,7 +37,7 @@ abstract class TrackedExpr extends Expr {
3537
/**
3638
* Turn all `TrackedExpr`s into `TrackedNode`s.
3739
*/
38-
private class TrackedExprNode extends TrackedNode {
40+
deprecated private class TrackedExprNode extends TrackedNode {
3941
TrackedExprNode() { asExpr() instanceof TrackedExpr }
4042
}
4143

@@ -64,7 +66,7 @@ private module NodeTracking {
6466
*
6567
* Summary steps through function calls are not taken into account.
6668
*/
67-
private predicate basicFlowStep(DataFlow::Node pred, DataFlow::Node succ, PathSummary summary) {
69+
deprecated private predicate basicFlowStep(DataFlow::Node pred, DataFlow::Node succ, PathSummary summary) {
6870
isRelevant(pred) and
6971
(
7072
// Local flow
@@ -94,7 +96,7 @@ private module NodeTracking {
9496
*
9597
* No call/return matching is done, so this is a relatively coarse over-approximation.
9698
*/
97-
private predicate isRelevant(DataFlow::Node nd) {
99+
deprecated private predicate isRelevant(DataFlow::Node nd) {
98100
nd instanceof TrackedNode
99101
or
100102
exists(DataFlow::Node mid | isRelevant(mid) |
@@ -115,7 +117,7 @@ private module NodeTracking {
115117
* either `pred` is an argument of `f` and `succ` the corresponding parameter, or
116118
* `pred` is a variable definition whose value is captured by `f` at `succ`.
117119
*/
118-
private predicate callInputStep(
120+
deprecated private predicate callInputStep(
119121
Function f, DataFlow::Node invk, DataFlow::Node pred, DataFlow::Node succ
120122
) {
121123
isRelevant(pred) and
@@ -136,7 +138,7 @@ private module NodeTracking {
136138
* that is captured by `f`, may flow to `nd` (possibly through callees, but not containing
137139
* any unmatched calls or returns) along a path summarized by `summary`.
138140
*/
139-
private predicate reachableFromInput(
141+
deprecated private predicate reachableFromInput(
140142
Function f, DataFlow::Node invk, DataFlow::Node input, DataFlow::Node nd, PathSummary summary
141143
) {
142144
callInputStep(f, invk, input, nd) and
@@ -154,7 +156,7 @@ private module NodeTracking {
154156
* Holds if `nd` may flow into a return statement of `f`
155157
* (possibly through callees) along a path summarized by `summary`.
156158
*/
157-
private predicate reachesReturn(Function f, DataFlow::Node nd, PathSummary summary) {
159+
deprecated private predicate reachesReturn(Function f, DataFlow::Node nd, PathSummary summary) {
158160
returnExpr(f, nd, _) and
159161
summary = PathSummary::level()
160162
or
@@ -170,7 +172,7 @@ private module NodeTracking {
170172
* which is either an argument or a definition captured by the function, flows,
171173
* possibly through callees.
172174
*/
173-
private predicate flowThroughCall(DataFlow::Node input, DataFlow::Node output) {
175+
deprecated private predicate flowThroughCall(DataFlow::Node input, DataFlow::Node output) {
174176
exists(Function f, DataFlow::ValueNode ret |
175177
ret.asExpr() = f.getAReturnedExpr() and
176178
reachableFromInput(f, output, input, ret, _)
@@ -187,7 +189,7 @@ private module NodeTracking {
187189
/**
188190
* Holds if `pred` may flow into property `prop` of `succ` along a path summarized by `summary`.
189191
*/
190-
private predicate storeStep(
192+
deprecated private predicate storeStep(
191193
DataFlow::Node pred, DataFlow::SourceNode succ, string prop, PathSummary summary
192194
) {
193195
basicStoreStep(pred, succ, prop) and
@@ -210,7 +212,7 @@ private module NodeTracking {
210212
* Holds if property `prop` of `pred` may flow into `succ` along a path summarized by
211213
* `summary`.
212214
*/
213-
private predicate loadStep(
215+
deprecated private predicate loadStep(
214216
DataFlow::Node pred, DataFlow::Node succ, string prop, PathSummary summary
215217
) {
216218
basicLoadStep(pred, succ, prop) and
@@ -226,7 +228,7 @@ private module NodeTracking {
226228
* Holds if `rhs` is the right-hand side of a write to property `prop`, and `nd` is reachable
227229
* from the base of that write (possibly through callees) along a path summarized by `summary`.
228230
*/
229-
private predicate reachableFromStoreBase(
231+
deprecated private predicate reachableFromStoreBase(
230232
string prop, DataFlow::Node rhs, DataFlow::Node nd, PathSummary summary
231233
) {
232234
storeStep(rhs, nd, prop, summary)
@@ -244,7 +246,7 @@ private module NodeTracking {
244246
*
245247
* In other words, `pred` may flow to `succ` through a property.
246248
*/
247-
private predicate flowThroughProperty(
249+
deprecated private predicate flowThroughProperty(
248250
DataFlow::Node pred, DataFlow::Node succ, PathSummary summary
249251
) {
250252
exists(string prop, DataFlow::Node base, PathSummary oldSummary, PathSummary newSummary |
@@ -259,7 +261,7 @@ private module NodeTracking {
259261
* invokes `cb`, passing `arg` as its `i`th argument. `arg` flows along a path summarized
260262
* by `summary`, while `cb` is only tracked locally.
261263
*/
262-
private predicate summarizedHigherOrderCall(
264+
deprecated private predicate summarizedHigherOrderCall(
263265
DataFlow::Node arg, DataFlow::Node cb, int i, PathSummary summary
264266
) {
265267
exists(
@@ -293,7 +295,7 @@ private module NodeTracking {
293295
* Alternatively, the callback can flow into a call `f(callback)` which itself provides the `arg`.
294296
* That is, `arg` refers to a value defined in `f` or one of its callees.
295297
*/
296-
predicate higherOrderCall(
298+
deprecated predicate higherOrderCall(
297299
DataFlow::Node arg, DataFlow::SourceNode callback, int i, PathSummary summary
298300
) {
299301
// Summarized call
@@ -328,7 +330,7 @@ private module NodeTracking {
328330
* of `cb`. `arg` flows along a path summarized by `summary`, while `cb` is only tracked
329331
* locally.
330332
*/
331-
private predicate flowIntoHigherOrderCall(
333+
deprecated private predicate flowIntoHigherOrderCall(
332334
DataFlow::Node pred, DataFlow::Node succ, PathSummary summary
333335
) {
334336
exists(DataFlow::FunctionNode cb, int i, PathSummary oldSummary |
@@ -341,7 +343,7 @@ private module NodeTracking {
341343
/**
342344
* Holds if there is a flow step from `pred` to `succ` described by `summary`.
343345
*/
344-
private predicate flowStep(DataFlow::Node pred, DataFlow::Node succ, PathSummary summary) {
346+
deprecated private predicate flowStep(DataFlow::Node pred, DataFlow::Node succ, PathSummary summary) {
345347
basicFlowStep(pred, succ, summary)
346348
or
347349
// Flow through a function that returns a value that depends on one of its arguments
@@ -360,7 +362,7 @@ private module NodeTracking {
360362
* Holds if there is a path from `source` to `nd` along a path summarized by
361363
* `summary`.
362364
*/
363-
predicate flowsTo(TrackedNode source, DataFlow::Node nd, PathSummary summary) {
365+
deprecated predicate flowsTo(TrackedNode source, DataFlow::Node nd, PathSummary summary) {
364366
source = nd and
365367
summary = PathSummary::level()
366368
or

javascript/ql/src/semmle/javascript/dataflow/TypeTracking.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Provides the `TypeTracker` class for tracking types interprocedurally.
33
*
4-
* This provides an alternative to `DataFlow::TrackedNode` and `AbstractValue`
4+
* This provides an alternative to `AbstractValue`
55
* for tracking certain types interprocedurally without computing which source
66
* a given value came from.
77
*/

javascript/ql/test/library-tests/InterProceduralFlow/TrackedNodes.expected

Lines changed: 0 additions & 55 deletions
This file was deleted.

javascript/ql/test/library-tests/InterProceduralFlow/TrackedNodes.ql

Lines changed: 0 additions & 31 deletions
This file was deleted.

javascript/ql/test/tutorials/Introducing the JavaScript libraries/query15.qll

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import javascript
22

3-
class TrackedStringLiteral extends DataFlow::TrackedNode {
4-
TrackedStringLiteral() { this.asExpr() instanceof ConstantString }
3+
DataFlow::Node constantString(DataFlow::TypeTracker t) {
4+
t.start() and
5+
result.asExpr() instanceof ConstantString
6+
or
7+
exists(DataFlow::TypeTracker t2 | t = t2.smallstep(constantString(t2), result))
58
}
69

710
query predicate test_query15(DataFlow::Node sink) {
8-
exists(TrackedStringLiteral source, SsaExplicitDefinition def |
9-
source.flowsTo(sink) and
11+
exists(SsaExplicitDefinition def |
12+
sink = constantString(DataFlow::TypeTracker::end()) and
1013
sink = DataFlow::ssaDefinitionNode(def) and
1114
def.getSourceVariable().getName().toLowerCase() = "password"
1215
|

0 commit comments

Comments
 (0)