From 4678e0954cb03e9ec2c3ff0a716d74b522098834 Mon Sep 17 00:00:00 2001 From: Alexander Kuechler Date: Fri, 17 Nov 2023 15:07:01 +0100 Subject: [PATCH] More fixes --- .../main/kotlin/de/fraunhofer/aisec/cpg/query/Query.kt | 2 +- .../kotlin/de/fraunhofer/aisec/cpg/graph/Extensions.kt | 2 +- .../aisec/cpg/passes/ControlFlowSensitiveDFGPass.kt | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cpg-analysis/src/main/kotlin/de/fraunhofer/aisec/cpg/query/Query.kt b/cpg-analysis/src/main/kotlin/de/fraunhofer/aisec/cpg/query/Query.kt index fcef8d986a7..89aa74fa0b3 100644 --- a/cpg-analysis/src/main/kotlin/de/fraunhofer/aisec/cpg/query/Query.kt +++ b/cpg-analysis/src/main/kotlin/de/fraunhofer/aisec/cpg/query/Query.kt @@ -197,7 +197,7 @@ fun max(n: Node?, eval: ValueEvaluator = MultiValueEvaluator()): QueryTree { val evalRes = from.followNextDFGEdgesUntilHit { it == to } val allPaths = evalRes.fulfilled.map { QueryTree(it) }.toMutableList() - // allPaths.addAll(evalRes.failed.map { QueryTree(it) }) + allPaths.addAll(evalRes.failed.map { QueryTree(it) }) return QueryTree( evalRes.fulfilled.isNotEmpty(), allPaths.toMutableList(), 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 6192b2a01da..b4791ff8b20 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 @@ -269,7 +269,7 @@ fun Node.followNextDFGEdgesUntilHit(predicate: (Node) -> Boolean): FulfilledAndF // follow them if (currentPath.last().nextDFG.isEmpty()) { // No further nodes in the path and the path criteria are not satisfied. - // failedPaths.add(currentPath) + failedPaths.add(currentPath) continue } diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/ControlFlowSensitiveDFGPass.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/ControlFlowSensitiveDFGPass.kt index b359976c819..effd7f3caf9 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/ControlFlowSensitiveDFGPass.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/ControlFlowSensitiveDFGPass.kt @@ -83,13 +83,18 @@ open class ControlFlowSensitiveDFGPass(ctx: TranslationContext) : TranslationUni // elements. We have the indices here, so it's amazing. key.elements.forEachIndexed { i, element -> element.addAllPrevDFG( - value.elements.filterNot { it is VariableDeclaration && key == it }, + value.elements.filterNot { + (it is VariableDeclaration || it is ParameterDeclaration) && + key == it + }, mutableMapOf(Properties.INDEX to i) ) } } else { key.addAllPrevDFG( - value.elements.filterNot { it is VariableDeclaration && key == it } + value.elements.filterNot { + (it is VariableDeclaration || it is ParameterDeclaration) && key == it + } ) } }