Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7721fb3

Browse files
committed
Python: Setup shared read/store steps
1 parent 636cf61 commit 7721fb3

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,18 @@ predicate jumpStepNotSharedWithTypeTracker(Node nodeFrom, Node nodeTo) {
641641
//--------
642642
// Field flow
643643
//--------
644+
/**
645+
* Subset of `storeStep` that should be shared with type-tracking.
646+
*/
647+
predicate storeStepCommon(Node nodeFrom, ContentSet c, Node nodeTo) { none() }
648+
644649
/**
645650
* Holds if data can flow from `nodeFrom` to `nodeTo` via an assignment to
646651
* content `c`.
647652
*/
648653
predicate storeStep(Node nodeFrom, ContentSet c, Node nodeTo) {
654+
storeStepCommon(nodeFrom, c, nodeTo)
655+
or
649656
listStoreStep(nodeFrom, c, nodeTo)
650657
or
651658
setStoreStep(nodeFrom, c, nodeTo)
@@ -891,10 +898,17 @@ predicate attributeStoreStep(Node nodeFrom, AttributeContent c, Node nodeTo) {
891898
)
892899
}
893900

901+
/**
902+
* Subset of `readStep` that should be shared with type-tracking.
903+
*/
904+
predicate readStepCommon(Node nodeFrom, ContentSet c, Node nodeTo) { none() }
905+
894906
/**
895907
* Holds if data can flow from `nodeFrom` to `nodeTo` via a read of content `c`.
896908
*/
897909
predicate readStep(Node nodeFrom, ContentSet c, Node nodeTo) {
910+
readStepCommon(nodeFrom, c, nodeTo)
911+
or
898912
subscriptReadStep(nodeFrom, c, nodeTo)
899913
or
900914
iterableUnpackingReadStep(nodeFrom, c, nodeTo)

python/ql/lib/semmle/python/dataflow/new/internal/TypeTrackingImpl.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ module TypeTrackingInput implements Shared::TypeTrackingInput {
175175
nodeTo = a.getObject()
176176
)
177177
or
178+
DataFlowPrivate::storeStepCommon(nodeFrom, content, nodeTo)
179+
or
178180
TypeTrackerSummaryFlow::basicStoreStep(nodeFrom, nodeTo, content)
179181
}
180182

@@ -189,6 +191,8 @@ module TypeTrackingInput implements Shared::TypeTrackingInput {
189191
nodeTo = a
190192
)
191193
or
194+
DataFlowPrivate::readStepCommon(nodeFrom, content, nodeTo)
195+
or
192196
TypeTrackerSummaryFlow::basicLoadStep(nodeFrom, nodeTo, content)
193197
}
194198

0 commit comments

Comments
 (0)