Skip to content

Commit 266de2e

Browse files
authored
Merge pull request github#3348 from RasmusWL/python-random-modernisation
Python: random modernisations
2 parents fcc2b66 + 367ee3e commit 266de2e

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

python/ql/src/semmle/python/security/injection/Exec.qll

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ import python
1010
import semmle.python.security.TaintTracking
1111
import semmle.python.security.strings.Untrusted
1212

13-
private FunctionObject exec_or_eval() {
14-
result = Object::builtin("exec")
15-
or
16-
result = Object::builtin("eval")
17-
}
18-
1913
/**
2014
* A taint sink that represents an argument to exec or eval that is vulnerable to malicious input.
2115
* The `vuln` in `exec(vuln)` or similar.
@@ -26,10 +20,9 @@ class StringEvaluationNode extends TaintSink {
2620
StringEvaluationNode() {
2721
exists(Exec exec | exec.getASubExpression().getAFlowNode() = this)
2822
or
29-
exists(CallNode call |
30-
exec_or_eval().getACall() = call and
31-
call.getAnArg() = this
32-
)
23+
Value::named("exec").getACall().getAnArg() = this
24+
or
25+
Value::named("eval").getACall().getAnArg() = this
3326
}
3427

3528
override predicate sinks(TaintKind kind) { kind instanceof ExternalStringKind }

python/ql/src/semmle/python/security/injection/Path.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ class OpenNode extends TaintSink {
6464

6565
OpenNode() {
6666
exists(CallNode call |
67-
call.getFunction().refersTo(Object::builtin("open")) and
68-
call.getAnArg() = this
67+
call = Value::named("open").getACall() and
68+
(
69+
call.getArg(0) = this
70+
or
71+
call.getArgByName("file") = this
72+
)
6973
)
7074
}
7175

0 commit comments

Comments
 (0)