@@ -4207,7 +4207,11 @@ module StdlibPrivate {
4207
4207
// ---------------------------------------------------------------------------
4208
4208
// Flow summaries for functions contructing containers
4209
4209
// ---------------------------------------------------------------------------
4210
- /** A flow summary for `dict`. */
4210
+ /**
4211
+ * A flow summary for `dict`.
4212
+ *
4213
+ * see https://docs.python.org/3/library/stdtypes.html#dict
4214
+ */
4211
4215
class DictSummary extends SummarizedCallable {
4212
4216
DictSummary ( ) { this = "builtins.dict" }
4213
4217
@@ -4218,18 +4222,23 @@ module StdlibPrivate {
4218
4222
}
4219
4223
4220
4224
override predicate propagatesFlow ( string input , string output , boolean preservesValue ) {
4225
+ // The positional argument contains a mapping.
4226
+ // TODO: Add the list-of-pairs version
4227
+ // TODO: these values can be overwritten by keyword arguments
4221
4228
exists ( DataFlow:: DictionaryElementContent dc , string key | key = dc .getKey ( ) |
4222
4229
input = "Argument[0].DictionaryElement[" + key + "]" and
4223
4230
output = "ReturnValue.DictionaryElement[" + key + "]" and
4224
4231
preservesValue = true
4225
4232
)
4226
4233
or
4234
+ // The keyword arguments are added to the dictionary.
4227
4235
exists ( DataFlow:: DictionaryElementContent dc , string key | key = dc .getKey ( ) |
4228
4236
input = "Argument[" + key + ":]" and
4229
4237
output = "ReturnValue.DictionaryElement[" + key + "]" and
4230
4238
preservesValue = true
4231
4239
)
4232
4240
or
4241
+ // Imprecise content in any argument ends up on the container itself.
4233
4242
input = "Argument[0..]" and
4234
4243
output = "ReturnValue" and
4235
4244
preservesValue = false
0 commit comments