Skip to content

Commit 0f91139

Browse files
authored
Merge pull request #2419 from tausbn/python-fix-use-of-input-fp
Python: Fix false positive for `py/use-of-input`.
2 parents 8f39989 + 67647bd commit 0f91139

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

python/ql/src/Expressions/UseofInput.ql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ import python
1414

1515
from CallNode call, Context context, ControlFlowNode func
1616
where
17-
context.getAVersion().includes(2, _) and call.getFunction() = func and func.refersTo(context, Object::builtin("input"), _, _)
17+
context.getAVersion().includes(2, _) and
18+
call.getFunction() = func and
19+
func.pointsTo(context, Value::named("input"), _) and
20+
not func.pointsTo(context, Value::named("raw_input"), _)
1821
select call, "The unsafe built-in function 'input' is used."
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
try:
2+
input = raw_input
3+
except NameError:
4+
pass
5+
6+
def use_of_input():
7+
return input()
8+
9+
print(use_of_input())
10+

0 commit comments

Comments
 (0)