From 3e5354a7b56427d6b342f9ed90048145e20abe6b Mon Sep 17 00:00:00 2001 From: Xiaojie Wen <18635488134@163.com> Date: Mon, 13 Jul 2026 09:50:42 +0800 Subject: [PATCH] fix: include interfaces in superclass relationships --- quark/core/apkinfo.py | 2 +- tests/core/test_apkinfo.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/quark/core/apkinfo.py b/quark/core/apkinfo.py index b2029e4da..d9a08d87a 100644 --- a/quark/core/apkinfo.py +++ b/quark/core/apkinfo.py @@ -452,7 +452,7 @@ def superclass_relationships(self) -> Dict[str, Set[str]]: for _class in self.analysis.get_classes(): hierarchy_dict[str(_class.name)].add(str(_class.extends)) - hierarchy_dict[str(_class.name)].union( + hierarchy_dict[str(_class.name)].update( str(implements) for implements in _class.implements ) diff --git a/tests/core/test_apkinfo.py b/tests/core/test_apkinfo.py index e8b43ebeb..334290305 100644 --- a/tests/core/test_apkinfo.py +++ b/tests/core/test_apkinfo.py @@ -1,4 +1,5 @@ import os +from types import SimpleNamespace from typing import Literal, Tuple import zipfile @@ -689,6 +690,24 @@ def test_superclass_relationships_with_expected_class(self, apkinfo): assert expected_upper_class == upper_set + def test_superclass_relationships_include_implemented_interfaces(self): + apkinfo = AndroguardImp.__new__(AndroguardImp) + apkinfo.analysis = SimpleNamespace( + get_classes=lambda: [ + SimpleNamespace( + name="Lexample/Child;", + extends="Lexample/Parent;", + implements=["Lexample/FirstInterface;", "Lexample/SecondInterface;"], + ) + ] + ) + + assert apkinfo.superclass_relationships["Lexample/Child;"] == { + "Lexample/Parent;", + "Lexample/FirstInterface;", + "Lexample/SecondInterface;", + } + @staticmethod @pytest.mark.parametrize( "test_input, expected",