File tree Expand file tree Collapse file tree
lib/semmle/python/dataflow/new/internal
test/library-tests/dataflow/tainttracking
defaultAdditionalTaintStep-py3
defaultAdditionalTaintStep Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1025,6 +1025,12 @@ module Conversions {
10251025 fmt .getRight ( ) = nodeFrom .asCfgNode ( )
10261026 ) and
10271027 c instanceof TupleElementContent
1028+ or
1029+ // format_map
1030+ // see https://docs.python.org/3/library/stdtypes.html#str.format_map
1031+ nodeTo .( MethodCallNode ) .calls ( _, "format_map" ) and
1032+ nodeTo .( MethodCallNode ) .getArg ( 0 ) = nodeFrom and
1033+ c instanceof DictionaryElementContent
10281034 }
10291035
10301036 predicate readStep ( Node nodeFrom , ContentSet c , Node nodeTo ) {
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ def str_methods():
1717 ts .casefold (), # $ tainted
1818
1919 ts .format_map ({}), # $ tainted
20- "{unsafe}" .format_map ({"unsafe" : ts }), # $ MISSING: tainted
20+ "{unsafe}" .format_map ({"unsafe" : ts }), # $ tainted
2121 )
2222
2323
Original file line number Diff line number Diff line change @@ -27,12 +27,14 @@ def test_construction():
2727 tainted_dict , # $ tainted
2828 )
2929
30+ # There are no implicit reads for list content as it is imprecise
31+ # Therefore, list content stemming from precise content does not end up on the list itself.
3032 ensure_tainted (
3133 list (tainted_list ), # $ tainted
32- list (tainted_tuple ), # $ MISSING: tainted
34+ list (tainted_tuple )[ 0 ] , # $ tainted
3335 list (tainted_set ), # $ tainted
34- list (tainted_dict .values ()), # $ MISSING: tainted
35- list (tainted_dict .items ()), # $ MISSING: tainted
36+ list (tainted_dict .values ())[ 0 ] , # $ tainted
37+ list (tainted_dict .items ())[ 0 ] , # $ tainted
3638
3739 tuple (tainted_list ), # $ tainted
3840 set (tainted_list ), # $ tainted
You can’t perform that action at this time.
0 commit comments