Python: Handle taint for % formatting

This commit is contained in:
Rasmus Wriedt Larsen
2020-08-24 14:15:27 +02:00
parent 80745e8881
commit 1e447c5ca2
3 changed files with 26 additions and 0 deletions

View File

@@ -43,3 +43,6 @@
| test.py:89 | fail | str_methods | ts.join(..) |
| test.py:99 | fail | non_syntactic | meth() |
| test.py:100 | fail | non_syntactic | _str(..) |
| test.py:109 | ok | percent_fmt | BinaryExpr |
| test.py:110 | ok | percent_fmt | BinaryExpr |
| test.py:111 | fail | percent_fmt | BinaryExpr |

View File

@@ -100,8 +100,21 @@ def non_syntactic():
_str(ts),
)
def percent_fmt():
print("\n#percent_fmt")
ts = TAINTED_STRING
tainted_fmt = ts + " %s %s"
ensure_tainted(
tainted_fmt % (1, 2),
"%s foo bar" % ts,
"%s %s %s" % (1, 2, ts),
)
# Make tests runable
str_operations()
str_methods()
non_syntactic()
percent_fmt()