File tree Expand file tree Collapse file tree 2 files changed +9
-12
lines changed
python/ql/src/semmle/python/security/injection Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -10,12 +10,6 @@ import python
10
10
import semmle.python.security.TaintTracking
11
11
import semmle.python.security.strings.Untrusted
12
12
13
- private FunctionObject exec_or_eval ( ) {
14
- result = Object:: builtin ( "exec" )
15
- or
16
- result = Object:: builtin ( "eval" )
17
- }
18
-
19
13
/**
20
14
* A taint sink that represents an argument to exec or eval that is vulnerable to malicious input.
21
15
* The `vuln` in `exec(vuln)` or similar.
@@ -26,10 +20,9 @@ class StringEvaluationNode extends TaintSink {
26
20
StringEvaluationNode ( ) {
27
21
exists ( Exec exec | exec .getASubExpression ( ) .getAFlowNode ( ) = this )
28
22
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
33
26
}
34
27
35
28
override predicate sinks ( TaintKind kind ) { kind instanceof ExternalStringKind }
Original file line number Diff line number Diff line change @@ -64,8 +64,12 @@ class OpenNode extends TaintSink {
64
64
65
65
OpenNode ( ) {
66
66
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
+ )
69
73
)
70
74
}
71
75
You can’t perform that action at this time.
0 commit comments