Skip to content

Commit 4776e9c

Browse files
committed
Type tracking: Allow for a non-standard flowsTo predicate
1 parent c8b4a21 commit 4776e9c

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

shared/typetracking/codeql/typetracking/TypeTracking.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ signature module TypeTrackingInput {
113113
* themselves.
114114
*/
115115
predicate hasFeatureBacktrackStoreTarget();
116+
117+
/**
118+
* Holds if a non-standard `flowsTo` predicate is needed, i.e., one that is not
119+
* simply `simpleLocalSmallStep*(localSource, dst)`.
120+
*/
121+
default predicate nonStandardFlowsTo(LocalSourceNode localSource, Node dst) { none() }
116122
}
117123

118124
private import internal.TypeTrackingImpl as Impl

shared/typetracking/codeql/typetracking/internal/TypeTrackingImpl.qll

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,15 @@ module TypeTracking<TypeTrackingInput I> {
249249
pragma[inline]
250250
private predicate isLocalSourceNode(LocalSourceNode n) { any() }
251251

252-
/**
253-
* Holds if there is flow from `localSource` to `dst` using zero or more
254-
* `simpleLocalSmallStep`s.
255-
*/
256252
cached
257-
predicate flowsTo(Node localSource, Node dst) {
253+
predicate standardFlowsTo(Node localSource, Node dst) {
254+
not nonStandardFlowsTo(_, _) and
258255
// explicit type check in base case to avoid repeated type tests in recursive case
259256
isLocalSourceNode(localSource) and
260257
dst = localSource
261258
or
262259
exists(Node mid |
263-
flowsTo(localSource, mid) and
260+
standardFlowsTo(localSource, mid) and
264261
simpleLocalSmallStep(mid, dst)
265262
)
266263
}
@@ -278,6 +275,16 @@ module TypeTracking<TypeTrackingInput I> {
278275

279276
import Cached
280277

278+
/**
279+
* Holds if there is flow from `localSource` to `dst` using zero or more
280+
* `simpleLocalSmallStep`s.
281+
*/
282+
predicate flowsTo(LocalSourceNode localSource, Node dst) {
283+
nonStandardFlowsTo(localSource, dst)
284+
or
285+
standardFlowsTo(localSource, dst)
286+
}
287+
281288
/**
282289
* A description of a step on an inter-procedural data flow path.
283290
*/

0 commit comments

Comments
 (0)