diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/Extensions.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/Extensions.kt index f91a5f078c..1092bc1a0d 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/Extensions.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/Extensions.kt @@ -1034,7 +1034,7 @@ val Expression.isImported: Pair if (name.parent == null) { // If the name does not have a parent, this reference could directly be the name // of an import, let's check - imports.firstOrNull { it.name == this.name } + imports.firstOrNull { it.name.lastPartsMatch(name) } } else { // Otherwise, the parent name could be the import imports.firstOrNull { it.name == this.name.parent } diff --git a/cpg-language-python/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/python/PythonFrontendTest.kt b/cpg-language-python/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/python/PythonFrontendTest.kt index 6f3e96ef71..d6c8b3e2bf 100644 --- a/cpg-language-python/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/python/PythonFrontendTest.kt +++ b/cpg-language-python/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/python/PythonFrontendTest.kt @@ -1459,7 +1459,7 @@ class PythonFrontendTest : BaseTest() { val topLevel = Path.of("src", "test", "resources", "python") val tu = analyzeAndGetFirstTU( - listOf(topLevel.resolve("import_no_src_test.py").toFile()), + listOf(topLevel.resolve("import_no_src.py").toFile()), topLevel, true ) {