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
1010import semmle.python.security.TaintTracking
1111import 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 }
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments