Skip to content

Commit 906705f

Browse files
committed
add SourceNode example to the TrackedNode deprecation description
1 parent fe41521 commit 906705f

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* DEPRECATED: Use `TypeTracking.qll` instead.
33
*
4-
* The following `TrackedNode` usage is less expressive than the equivalent type tracking usage below.
4+
* The following `TrackedNode` usage is usually equivalent to the type tracking usage below.
55
*
66
* ```
77
* class MyTrackedNode extends TrackedNode {
@@ -14,12 +14,32 @@
1414
* ```
1515
*
1616
* ```
17+
* DataFlow::SourceNode getMyTrackedNodeLocation(DataFlow::SourceNode start, DataFlow::TypeTracker t) {
18+
* t.start() and
19+
* isInteresting(result) and
20+
* result = start
21+
* or
22+
* exists (DataFlow::TypeTracker t2 |
23+
* result = getMyTrackedNodeLocation(start, t2).track(t2, t)
24+
* )
25+
* }
26+
*
27+
* DataFlow::SourceNode getMyTrackedNodeLocation(DataFlow::SourceNode n) {
28+
* result = getMyTrackedNodeLocation(n, DataFlow::TypeTracker::end())
29+
* }
30+
* ```
31+
*
32+
* In rare cases, additional tracking is required, for instance when tracking string constants, and the following type tracking formulation is required instead.
33+
*
34+
* ```
1735
* DataFlow::Node getMyTrackedNodeLocation(DataFlow::Node start, DataFlow::TypeTracker t) {
1836
* t.start() and
1937
* isInteresting(result) and
2038
* result = start
2139
* or
22-
* exists(DataFlow::TypeTracker t2 | t = t2.smallstep(getMyTrackedNodeLocation(start, t2), result))
40+
* exists(DataFlow::TypeTracker t2 |
41+
* t = t2.smallstep(getMyTrackedNodeLocation(start, t2), result)
42+
* )
2343
* }
2444
*
2545
* DataFlow::Node getMyTrackedNodeLocation(DataFlow::Node n) {

0 commit comments

Comments
 (0)