Skip to content

Commit d62a552

Browse files
committed
Python: Improve AccessPath printing.
1 parent 0665f4f commit d62a552

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,30 @@ SummaryComponent interpretComponentSpecific(AccessPathToken c) {
128128
)
129129
}
130130

131+
private string getContentSpecific(Content cs) {
132+
cs = TListElementContent() and result = "ListElement"
133+
or
134+
cs = TSetElementContent() and result = "SetElement"
135+
or
136+
exists(int index |
137+
cs = TTupleElementContent(index) and result = "TupleElement[" + index.toString() + "]"
138+
)
139+
or
140+
exists(string key |
141+
cs = TDictionaryElementContent(key) and result = "DictionaryElement[" + key + "]"
142+
)
143+
or
144+
cs = TDictionaryElementAnyContent() and result = "DictionaryElementAny"
145+
or
146+
exists(string attr | cs = TAttributeContent(attr) and result = "Attribute[" + attr + "]")
147+
}
148+
131149
/** Gets the textual representation of a summary component in the format used for flow summaries. */
132150
string getAccessStepSpecific(SummaryComponent sc) {
133-
sc = TContentSummaryComponent(any(ListElementContent c)) and
134-
result = "ListElement"
151+
exists(Content c |
152+
sc = TContentSummaryComponent(c) and
153+
result = getContentSpecific(c)
154+
)
135155
}
136156

137157
/** Gets the textual representation of a parameter position in the format used for flow summaries. */

0 commit comments

Comments
 (0)