1
1
/** Step Summaries and Type Tracking */
2
2
3
3
private import TypeTrackerSpecific
4
+ private import semmle.python.dataflow.new.internal.DataFlowPublic as DataFlowPublic
4
5
5
6
cached
6
7
private module Cached {
@@ -12,10 +13,22 @@ private module Cached {
12
13
LevelStep ( ) or
13
14
CallStep ( ) or
14
15
ReturnStep ( ) or
15
- deprecated StoreStep ( TypeTrackerContent content ) { basicStoreStep ( _, _, content ) } or
16
- deprecated LoadStep ( TypeTrackerContent content ) { basicLoadStep ( _, _, content ) } or
16
+ deprecated StoreStep ( TypeTrackerContent content ) {
17
+ exists ( DataFlowPublic:: AttributeContent dfc | dfc .getAttribute ( ) = content |
18
+ basicStoreStep ( _, _, dfc )
19
+ )
20
+ } or
21
+ deprecated LoadStep ( TypeTrackerContent content ) {
22
+ exists ( DataFlowPublic:: AttributeContent dfc | dfc .getAttribute ( ) = content |
23
+ basicLoadStep ( _, _, dfc )
24
+ )
25
+ } or
17
26
deprecated LoadStoreStep ( TypeTrackerContent load , TypeTrackerContent store ) {
18
- basicLoadStoreStep ( _, _, load , store )
27
+ exists ( DataFlowPublic:: AttributeContent dfcLoad , DataFlowPublic:: AttributeContent dfcStore |
28
+ dfcLoad .getAttribute ( ) = load and dfcStore .getAttribute ( ) = store
29
+ |
30
+ basicLoadStoreStep ( _, _, dfcLoad , dfcStore )
31
+ )
19
32
} or
20
33
deprecated WithContent ( ContentFilter filter ) { basicWithContentStep ( _, _, filter ) } or
21
34
deprecated WithoutContent ( ContentFilter filter ) { basicWithoutContentStep ( _, _, filter ) } or
@@ -29,13 +42,13 @@ private module Cached {
29
42
// Restrict `content` to those that might eventually match a load.
30
43
// We can't rely on `basicStoreStep` since `startInContent` might be used with
31
44
// a content that has no corresponding store.
32
- exists ( TypeTrackerContent loadContents |
45
+ exists ( DataFlowPublic :: AttributeContent loadContents |
33
46
(
34
47
basicLoadStep ( _, _, loadContents )
35
48
or
36
49
basicLoadStoreStep ( _, _, loadContents , _)
37
50
) and
38
- compatibleContents ( content , loadContents )
51
+ compatibleContents ( content , loadContents . getAttribute ( ) )
39
52
)
40
53
}
41
54
@@ -45,13 +58,13 @@ private module Cached {
45
58
content = noContent ( )
46
59
or
47
60
// As in MkTypeTracker, restrict `content` to those that might eventually match a store.
48
- exists ( TypeTrackerContent storeContent |
61
+ exists ( DataFlowPublic :: AttributeContent storeContent |
49
62
(
50
63
basicStoreStep ( _, _, storeContent )
51
64
or
52
65
basicLoadStoreStep ( _, _, _, storeContent )
53
66
) and
54
- compatibleContents ( storeContent , content )
67
+ compatibleContents ( storeContent . getAttribute ( ) , content )
55
68
)
56
69
}
57
70
@@ -198,7 +211,10 @@ private module Cached {
198
211
flowsToStoreStep ( nodeFrom , nodeTo , content ) and
199
212
summary = StoreStep ( content )
200
213
or
201
- basicLoadStep ( nodeFrom , nodeTo , content ) and summary = LoadStep ( content )
214
+ exists ( DataFlowPublic:: AttributeContent dfc | dfc .getAttribute ( ) = content |
215
+ basicLoadStep ( nodeFrom , nodeTo , dfc )
216
+ ) and
217
+ summary = LoadStep ( content )
202
218
)
203
219
or
204
220
exists ( TypeTrackerContent loadContent , TypeTrackerContent storeContent |
@@ -281,7 +297,12 @@ deprecated private predicate smallstepProj(Node nodeFrom, StepSummary summary) {
281
297
deprecated private predicate flowsToStoreStep (
282
298
Node nodeFrom , TypeTrackingNode nodeTo , TypeTrackerContent content
283
299
) {
284
- exists ( Node obj | nodeTo .flowsTo ( obj ) and basicStoreStep ( nodeFrom , obj , content ) )
300
+ exists ( Node obj |
301
+ nodeTo .flowsTo ( obj ) and
302
+ exists ( DataFlowPublic:: AttributeContent dfc | dfc .getAttribute ( ) = content |
303
+ basicStoreStep ( nodeFrom , obj , dfc )
304
+ )
305
+ )
285
306
}
286
307
287
308
/**
@@ -292,7 +313,12 @@ deprecated private predicate flowsToLoadStoreStep(
292
313
TypeTrackerContent storeContent
293
314
) {
294
315
exists ( Node obj |
295
- nodeTo .flowsTo ( obj ) and basicLoadStoreStep ( nodeFrom , obj , loadContent , storeContent )
316
+ nodeTo .flowsTo ( obj ) and
317
+ exists ( DataFlowPublic:: AttributeContent loadDfc , DataFlowPublic:: AttributeContent storeDfc |
318
+ loadDfc .getAttribute ( ) = loadContent and storeDfc .getAttribute ( ) = storeContent
319
+ |
320
+ basicLoadStoreStep ( nodeFrom , obj , loadDfc , storeDfc )
321
+ )
296
322
)
297
323
}
298
324
0 commit comments