Skip to content

Commit d9383d0

Browse files
authored
Merge pull request github#2902 from RasmusWL/python-use-of-input
Python: Highlight py/use-of-input is for Python 2
2 parents 8bd3063 + 8f70101 commit d9383d0

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

python/ql/src/Expressions/UseofInput.qhelp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
"qhelp.dtd">
44
<qhelp>
55
<overview>
6-
<p>A call to the input() function, <code>input(prompt)</code> is equivalent to <code>eval(raw_input(prompt))</code>. Evaluating user input without any checking can be a serious security flaw.</p>
6+
<p>In Python 2, a call to the <code>input()</code> function, <code>input(prompt)</code> is equivalent to <code>eval(raw_input(prompt))</code>. Evaluating user input without any checking can be a serious security flaw.</p>
77

88
</overview>
99
<recommendation>
1010

11-
<p> Get user input with <code>raw_input(prompt)</code> and then validate that input before evaluating. If the expected input is a number or
11+
<p>Get user input with <code>raw_input(prompt)</code> and then validate that input before evaluating. If the expected input is a number or
1212
string, then <code>ast.literal_eval()</code> can always be used safely.</p>
1313

1414

1515
</recommendation>
1616
<references>
1717

18-
<li>Python Standard Library: <a href="http://docs.python.org/library/functions.html#input">input</a>,
19-
<a href="http://docs.python.org/library/ast.html#ast.literal_eval">ast.literal_eval</a>.</li>
18+
<li>Python Standard Library: <a href="http://docs.python.org/2/library/functions.html#input">input</a>,
19+
<a href="http://docs.python.org/2/library/ast.html#ast.literal_eval">ast.literal_eval</a>.</li>
2020
<li>Wikipedia: <a href="http://en.wikipedia.org/wiki/Data_validation">Data validation</a>.</li>
2121

2222
</references>

python/ql/src/Expressions/UseofInput.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @name 'input' function used
3-
* @description The built-in function 'input' is used which can allow arbitrary code to be run.
2+
* @name 'input' function used in Python 2
3+
* @description The built-in function 'input' is used which, in Python 2, can allow arbitrary code to be run.
44
* @kind problem
55
* @tags security
66
* correctness
@@ -18,4 +18,4 @@ where
1818
call.getFunction() = func and
1919
func.pointsTo(context, Value::named("input"), _) and
2020
not func.pointsTo(context, Value::named("raw_input"), _)
21-
select call, "The unsafe built-in function 'input' is used."
21+
select call, "The unsafe built-in function 'input' is used in Python 2."
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| expressions_test.py:6:12:6:18 | ControlFlowNode for input() | The unsafe built-in function 'input' is used. |
1+
| expressions_test.py:6:12:6:18 | ControlFlowNode for input() | The unsafe built-in function 'input' is used in Python 2. |

0 commit comments

Comments
 (0)