@@ -4207,7 +4207,11 @@ module StdlibPrivate {
42074207 // ---------------------------------------------------------------------------
42084208 // Flow summaries for functions contructing containers
42094209 // ---------------------------------------------------------------------------
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+ */
42114215 class DictSummary extends SummarizedCallable {
42124216 DictSummary ( ) { this = "builtins.dict" }
42134217
@@ -4218,18 +4222,23 @@ module StdlibPrivate {
42184222 }
42194223
42204224 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
42214228 exists ( DataFlow:: DictionaryElementContent dc , string key | key = dc .getKey ( ) |
42224229 input = "Argument[0].DictionaryElement[" + key + "]" and
42234230 output = "ReturnValue.DictionaryElement[" + key + "]" and
42244231 preservesValue = true
42254232 )
42264233 or
4234+ // The keyword arguments are added to the dictionary.
42274235 exists ( DataFlow:: DictionaryElementContent dc , string key | key = dc .getKey ( ) |
42284236 input = "Argument[" + key + ":]" and
42294237 output = "ReturnValue.DictionaryElement[" + key + "]" and
42304238 preservesValue = true
42314239 )
42324240 or
4241+ // Imprecise content in any argument ends up on the container itself.
42334242 input = "Argument[0..]" and
42344243 output = "ReturnValue" and
42354244 preservesValue = false
0 commit comments