Skip to content

Commit 7eb4419

Browse files
committed
Python: Restrict type-tracking content to only be precise
At least for now :)
1 parent 6babb2f commit 7eb4419

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,21 @@ module TypeTrackingInput implements Shared::TypeTrackingInput {
102102

103103
class LocalSourceNode = DataFlowPublic::LocalSourceNode;
104104

105-
class Content = DataFlowPublic::Content;
105+
class Content extends DataFlowPublic::Content {
106+
Content() {
107+
// TODO: for now, it's not 100% clear if should support non-precise content in
108+
// type-tracking, or if it will lead to bad results. We start with only allowing
109+
// precise content, which should always be a good improvement! It also simplifies
110+
// the process of examining new results from non-precise content steps in the
111+
// future, since you will _only_ have to look over the results from the new
112+
// non-precise steps.
113+
this instanceof DataFlowPublic::AttributeContent
114+
or
115+
this instanceof DataFlowPublic::DictionaryElementContent
116+
or
117+
this instanceof DataFlowPublic::TupleElementContent
118+
}
119+
}
106120

107121
/**
108122
* A label to use for `WithContent` and `WithoutContent` steps, restricting

python/ql/test/experimental/dataflow/typetracking-summaries/summaries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def explicit_identity(x):
4141
tms # $ MISSING: tracked
4242

4343
another_tainted_list = TTS_append_to_list([], tracked) # $ tracked
44-
atl = another_tainted_list[0] # $ tracked
45-
atl # $ tracked
44+
atl = another_tainted_list[0]
45+
atl # $ MISSING: tracked
4646

4747
# This will not work, as the call is not found by `getACallSimple`.
4848
from json import loads as json_loads

0 commit comments

Comments
 (0)