mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
Merge pull request #11402 from yoff/python/port-super-not-enclosing-class
Python: port `py/super-not-enclosing-class`
This commit is contained in:
@@ -13,17 +13,15 @@
|
||||
*/
|
||||
|
||||
import python
|
||||
import semmle.python.dataflow.new.DataFlow
|
||||
import semmle.python.ApiGraphs
|
||||
|
||||
from CallNode call_to_super, string name
|
||||
from DataFlow::CallCfgNode call_to_super, string name
|
||||
where
|
||||
exists(GlobalVariable gv, ControlFlowNode cn |
|
||||
call_to_super = ClassValue::super_().getACall() and
|
||||
gv.getId() = "super" and
|
||||
cn = call_to_super.getArg(0) and
|
||||
name = call_to_super.getScope().getScope().(Class).getName() and
|
||||
exists(ClassValue other |
|
||||
cn.pointsTo(other) and
|
||||
not other.getScope().getName() = name
|
||||
)
|
||||
call_to_super = API::builtin("super").getACall() and
|
||||
name = call_to_super.getScope().getScope().(Class).getName() and
|
||||
exists(DataFlow::Node arg |
|
||||
arg = call_to_super.getArg(0) and
|
||||
arg.getALocalSource().asExpr().(Name).getId() != name
|
||||
)
|
||||
select call_to_super.getNode(), "First argument to super() should be " + name + "."
|
||||
|
||||
@@ -1 +1 @@
|
||||
| test.py:10:9:10:27 | super() | First argument to super() should be NotMyDict. |
|
||||
| test.py:10:9:10:27 | ControlFlowNode for super() | First argument to super() should be NotMyDict. |
|
||||
|
||||
Reference in New Issue
Block a user