Files
codeql/python/ql/test/2/query-tests/Expressions/safe_input.py
Taus Brock-Nannestad 67647bda66 Python: Fix false positive for py/use-of-input.
Fixes #1969.

The points-to analysis does not know that the assignment `input = raw_input`
cannot fail under Python 2, and so there are two possible values that `input`
could point-to after exiting the exception handler: the built-in `input`, or the
built-in `raw_input`. In the latter case we do not want to report the alert, and
so adding a check that the given function does not point-to the built-in
`raw_input` suffices.
2019-11-22 16:46:20 +01:00

11 lines
118 B
Python

try:
input = raw_input
except NameError:
pass
def use_of_input():
return input()
print(use_of_input())