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

Skip to content

Commit ece8245

Browse files
committed
Python: type-track through tuple content
1 parent a95bb7c commit ece8245

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,9 @@ predicate jumpStepNotSharedWithTypeTracker(Node nodeFrom, Node nodeTo) {
644644
/**
645645
* Subset of `storeStep` that should be shared with type-tracking.
646646
*/
647-
predicate storeStepCommon(Node nodeFrom, ContentSet c, Node nodeTo) { none() }
647+
predicate storeStepCommon(Node nodeFrom, ContentSet c, Node nodeTo) {
648+
tupleStoreStep(nodeFrom, c, nodeTo)
649+
}
648650

649651
/**
650652
* Holds if data can flow from `nodeFrom` to `nodeTo` via an assignment to
@@ -657,8 +659,6 @@ predicate storeStep(Node nodeFrom, ContentSet c, Node nodeTo) {
657659
or
658660
setStoreStep(nodeFrom, c, nodeTo)
659661
or
660-
tupleStoreStep(nodeFrom, c, nodeTo)
661-
or
662662
dictStoreStep(nodeFrom, c, nodeTo)
663663
or
664664
moreDictStoreSteps(nodeFrom, c, nodeTo)
@@ -901,16 +901,16 @@ predicate attributeStoreStep(Node nodeFrom, AttributeContent c, Node nodeTo) {
901901
/**
902902
* Subset of `readStep` that should be shared with type-tracking.
903903
*/
904-
predicate readStepCommon(Node nodeFrom, ContentSet c, Node nodeTo) { none() }
904+
predicate readStepCommon(Node nodeFrom, ContentSet c, Node nodeTo) {
905+
subscriptReadStep(nodeFrom, c, nodeTo)
906+
}
905907

906908
/**
907909
* Holds if data can flow from `nodeFrom` to `nodeTo` via a read of content `c`.
908910
*/
909911
predicate readStep(Node nodeFrom, ContentSet c, Node nodeTo) {
910912
readStepCommon(nodeFrom, c, nodeTo)
911913
or
912-
subscriptReadStep(nodeFrom, c, nodeTo)
913-
or
914914
iterableUnpackingReadStep(nodeFrom, c, nodeTo)
915915
or
916916
matchReadStep(nodeFrom, c, nodeTo)

python/ql/test/experimental/library-tests/CallGraph/InlineCallGraphTest.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ pointsTo_found_typeTracker_notFound
1616
| code/func_defined_outside_class.py:42:1:42:7 | ControlFlowNode for Attribute() | B._gen.func |
1717
| code/func_defined_outside_class.py:43:1:43:7 | ControlFlowNode for Attribute() | B._gen.func |
1818
| code/func_ref_in_content.py:17:1:17:4 | ControlFlowNode for f2() | func |
19-
| code/func_ref_in_content.py:20:1:20:4 | ControlFlowNode for f3() | func |
2019
| code/funky_regression.py:15:9:15:17 | ControlFlowNode for Attribute() | Wat.f2 |
2120
| code/type_tracking_limitation.py:8:1:8:3 | ControlFlowNode for x() | my_func |
2221
typeTracker_found_pointsTo_notFound

python/ql/test/experimental/library-tests/CallGraph/code/func_ref_in_content.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def return_func_in_tuple():
1717
f2() # $ pt=func MISSING: tt
1818

1919
f3 = tup[0]
20-
f3() # $ pt=func MISSING: tt
20+
f3() # $ tt,pt=func
2121

2222

2323
def return_func_in_dict():

0 commit comments

Comments
 (0)