Skip to content

Commit 73971cf

Browse files
committed
Python: Model exec statement (Python 2 only) as CodeExecution
1 parent 453c391 commit 73971cf

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

python/ql/src/experimental/semmle/python/frameworks/Stdlib.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,17 @@ private module Stdlib {
328328
}
329329
}
330330
}
331+
332+
/**
333+
* An exec statement (only Python 2).
334+
* Se ehttps://docs.python.org/2/reference/simple_stmts.html#the-exec-statement.
335+
*/
336+
private class ExecStatement extends CodeExecution::Range {
337+
ExecStatement() {
338+
// since there are no DataFlow::Nodes for a Statement, we can't do anything like
339+
// `this = any(Exec exec)`
340+
this.asExpr() = any(Exec exec).getBody()
341+
}
342+
343+
override DataFlow::Node getCode() { result = this }
344+
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
| CodeExecution.py:2:19:2:40 | Comment # $getCode="print(42)" | Missing result:getCode="print(42)" |

0 commit comments

Comments
 (0)