From 5e34778d7278a5f449fd1edddf174fff9a486fa2 Mon Sep 17 00:00:00 2001 From: Taus Date: Thu, 9 Apr 2026 21:12:17 +0000 Subject: [PATCH] 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. --- python/ql/src/Classes/InconsistentMRO.ql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/ql/src/Classes/InconsistentMRO.ql b/python/ql/src/Classes/InconsistentMRO.ql index 73f6bf9240b..93dde9288dd 100644 --- a/python/ql/src/Classes/InconsistentMRO.ql +++ b/python/ql/src/Classes/InconsistentMRO.ql @@ -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))