11/** Step Summaries and Type Tracking */
22
33private import TypeTrackerSpecific
4+ private import semmle.python.dataflow.new.internal.DataFlowPublic as DataFlowPublic
45
56cached
67private module Cached {
@@ -12,10 +13,22 @@ private module Cached {
1213 LevelStep ( ) or
1314 CallStep ( ) or
1415 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
1726 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+ )
1932 } or
2033 deprecated WithContent ( ContentFilter filter ) { basicWithContentStep ( _, _, filter ) } or
2134 deprecated WithoutContent ( ContentFilter filter ) { basicWithoutContentStep ( _, _, filter ) } or
@@ -29,13 +42,13 @@ private module Cached {
2942 // Restrict `content` to those that might eventually match a load.
3043 // We can't rely on `basicStoreStep` since `startInContent` might be used with
3144 // a content that has no corresponding store.
32- exists ( TypeTrackerContent loadContents |
45+ exists ( DataFlowPublic :: AttributeContent loadContents |
3346 (
3447 basicLoadStep ( _, _, loadContents )
3548 or
3649 basicLoadStoreStep ( _, _, loadContents , _)
3750 ) and
38- compatibleContents ( content , loadContents )
51+ compatibleContents ( content , loadContents . getAttribute ( ) )
3952 )
4053 }
4154
@@ -45,13 +58,13 @@ private module Cached {
4558 content = noContent ( )
4659 or
4760 // As in MkTypeTracker, restrict `content` to those that might eventually match a store.
48- exists ( TypeTrackerContent storeContent |
61+ exists ( DataFlowPublic :: AttributeContent storeContent |
4962 (
5063 basicStoreStep ( _, _, storeContent )
5164 or
5265 basicLoadStoreStep ( _, _, _, storeContent )
5366 ) and
54- compatibleContents ( storeContent , content )
67+ compatibleContents ( storeContent . getAttribute ( ) , content )
5568 )
5669 }
5770
@@ -198,7 +211,10 @@ private module Cached {
198211 flowsToStoreStep ( nodeFrom , nodeTo , content ) and
199212 summary = StoreStep ( content )
200213 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 )
202218 )
203219 or
204220 exists ( TypeTrackerContent loadContent , TypeTrackerContent storeContent |
@@ -281,7 +297,12 @@ deprecated private predicate smallstepProj(Node nodeFrom, StepSummary summary) {
281297deprecated private predicate flowsToStoreStep (
282298 Node nodeFrom , TypeTrackingNode nodeTo , TypeTrackerContent content
283299) {
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+ )
285306}
286307
287308/**
@@ -292,7 +313,12 @@ deprecated private predicate flowsToLoadStoreStep(
292313 TypeTrackerContent storeContent
293314) {
294315 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+ )
296322 )
297323}
298324
0 commit comments