mirror of
https://github.com/github/codeql.git
synced 2026-05-14 11:19:27 +02:00
Python: Exclude "self-inheritance" results
It's not possible for a class to actually inherit from itself, so if this happens, something has gone wrong with our analysis. We therefore explicitly exclude these results so they don't result in false positives.
This commit is contained in:
@@ -17,7 +17,10 @@ private import semmle.python.dataflow.new.internal.DataFlowDispatch
|
||||
/**
|
||||
* Gets the `i`th base class of `cls`, if it can be resolved to a user-defined class.
|
||||
*/
|
||||
Class getBaseType(Class cls, int i) { cls.getBase(i) = classTracker(result).asExpr() }
|
||||
Class getBaseType(Class cls, int i) {
|
||||
cls.getBase(i) = classTracker(result).asExpr() and
|
||||
result != cls
|
||||
}
|
||||
|
||||
Class left_base(Class type, Class base) {
|
||||
exists(int i | i > 0 and getBaseType(type, i) = base and result = getBaseType(type, i - 1))
|
||||
|
||||
Reference in New Issue
Block a user