diff --git a/cloudpg/src/main/java/io/clouditor/graph/App.kt b/cloudpg/src/main/java/io/clouditor/graph/App.kt index bf4ca18..04dbfc8 100644 --- a/cloudpg/src/main/java/io/clouditor/graph/App.kt +++ b/cloudpg/src/main/java/io/clouditor/graph/App.kt @@ -18,10 +18,7 @@ import io.clouditor.graph.nodes.Builder import io.clouditor.graph.passes.* import io.clouditor.graph.passes.golang.* import io.clouditor.graph.passes.java.JaxRsClientPass -import io.clouditor.graph.passes.java.JaxRsPass -import io.clouditor.graph.passes.java.SpringBootPass import io.clouditor.graph.passes.js.FetchPass -import io.clouditor.graph.passes.js.JSHttpPass import io.clouditor.graph.passes.python.* import io.clouditor.graph.testing.LocalTestingPass import java.nio.file.Path @@ -119,7 +116,7 @@ object App : Callable { val builder = TranslationConfiguration.builder() .topLevel(rootPath.toFile()) - .sourceLocations(paths.map { rootPath.resolve(it).toFile() }) + .sourceLocations(paths.map { rootPath.resolve(it).toFile().normalize() }) .registerLanguage(JavaLanguage()) .registerLanguage(CPPLanguage()) .registerLanguage(CLanguage()) @@ -129,13 +126,13 @@ object App : Callable { .debugParser(true) .defaultPasses() .registerPass(GitHubWorkflowPass::class) - .registerPass(SpringBootPass::class) - .registerPass(JaxRsPass::class) + // .registerPass(SpringBootPass::class) + // .registerPass(JaxRsPass::class) .registerPass(GolangHttpPass::class) .registerPass(GinGonicPass::class) // .registerPass(WebBrickPass::class) - .registerPass(JSHttpPass::class) - .registerPass(FlaskPass::class) + // .registerPass(JSHttpPass::class) + // .registerPass(FlaskPass::class) .apply { if (localMode) { // register the localTestingPass after the HTTP Passes since it needs HTTP @@ -194,7 +191,7 @@ val TranslationResult.computes: MutableList MutableList fun TranslationResult.findApplicationByTU(tu: TranslationUnitDeclaration): Application? { - return this.additionalNodes.filterIsInstance(Application::class.java).firstOrNull { + return this.additionalNodes.filterIsInstance().firstOrNull { it.translationUnits.contains(tu) } } diff --git a/cloudpg/src/main/java/io/clouditor/graph/passes/LabelExtractionPass.kt b/cloudpg/src/main/java/io/clouditor/graph/passes/LabelExtractionPass.kt index 855d7d9..a5b866e 100644 --- a/cloudpg/src/main/java/io/clouditor/graph/passes/LabelExtractionPass.kt +++ b/cloudpg/src/main/java/io/clouditor/graph/passes/LabelExtractionPass.kt @@ -300,13 +300,14 @@ class LabelExtractionPass(ctx: TranslationContext) : TranslationResultPass(ctx) node.declarations .filterIsInstance() .flatMap { it.usageEdges.map { edge -> edge.end.refersTo } } + .filterNotNull() .toSet() - usages.forEach { addLabelToDFGBorderEdges(it as Node, label) } + usages.forEach { addLabelToDFGBorderEdges(it, label) } } is AssignExpression -> { val variableDeclarations = - node.lhs.filterIsInstance().map { it.refersTo } - variableDeclarations.forEach { addLabelToDFGBorderEdges(it as Node, label) } + node.lhs.filterIsInstance().mapNotNull { it.refersTo } + variableDeclarations.forEach { addLabelToDFGBorderEdges(it, label) } } else -> { addLabelToDFGBorderEdges(node, label) diff --git a/cloudpg/src/main/java/io/clouditor/graph/passes/golang/GinGonicPass.kt b/cloudpg/src/main/java/io/clouditor/graph/passes/golang/GinGonicPass.kt index 7067679..27f9d3d 100644 --- a/cloudpg/src/main/java/io/clouditor/graph/passes/golang/GinGonicPass.kt +++ b/cloudpg/src/main/java/io/clouditor/graph/passes/golang/GinGonicPass.kt @@ -7,22 +7,22 @@ import de.fraunhofer.aisec.cpg.graph.Node import de.fraunhofer.aisec.cpg.graph.declarations.FunctionDeclaration import de.fraunhofer.aisec.cpg.graph.declarations.TranslationUnitDeclaration import de.fraunhofer.aisec.cpg.graph.declarations.VariableDeclaration +import de.fraunhofer.aisec.cpg.graph.firstAssignment import de.fraunhofer.aisec.cpg.graph.parseName import de.fraunhofer.aisec.cpg.graph.statements.expressions.* import de.fraunhofer.aisec.cpg.graph.types.PointerType import de.fraunhofer.aisec.cpg.passes.* import de.fraunhofer.aisec.cpg.passes.order.DependsOn -import de.fraunhofer.aisec.cpg.passes.order.ExecuteBefore import de.fraunhofer.aisec.cpg.processing.IVisitor import de.fraunhofer.aisec.cpg.processing.strategy.Strategy import io.clouditor.graph.* -import io.clouditor.graph.passes.KubernetesPass import io.clouditor.graph.testing.LocalTestingPass -@DependsOn(GoExtraPass::class) @DependsOn(SymbolResolver::class) -@ExecuteBefore(LocalTestingPass::class) -@ExecuteBefore(KubernetesPass::class) +@DependsOn( + LocalTestingPass::class /*, softDependency = true*/ +) // should be "soft", but broken until #1532 is released +// @DependsOn(KubernetesPass::class /*, softDependency = true*/) class GinGonicPass(ctx: TranslationContext) : TranslationResultPass(ctx) { private val clients = mutableMapOf() @@ -257,9 +257,10 @@ class GinGonicPass(ctx: TranslationContext) : TranslationResultPass(ctx) { tu: TranslationUnitDeclaration, r: VariableDeclaration ) { - if (r.initializer is CallExpression && - ((r.initializer as CallExpression).name.toString() == "gin.Default" || - (r.initializer as CallExpression).name.toString() == "gin.New") + val initializer = r.firstAssignment + if (initializer is CallExpression && + (initializer.name.toString() == "gin.Default" || + initializer.name.toString() == "gin.New") ) { val app = result.findApplicationByTU(tu) diff --git a/cloudpg/src/main/java/io/clouditor/graph/passes/golang/GolangHttpPass.kt b/cloudpg/src/main/java/io/clouditor/graph/passes/golang/GolangHttpPass.kt index e665313..43afc45 100644 --- a/cloudpg/src/main/java/io/clouditor/graph/passes/golang/GolangHttpPass.kt +++ b/cloudpg/src/main/java/io/clouditor/graph/passes/golang/GolangHttpPass.kt @@ -9,16 +9,18 @@ import de.fraunhofer.aisec.cpg.graph.declarations.TranslationUnitDeclaration import de.fraunhofer.aisec.cpg.graph.declarations.VariableDeclaration import de.fraunhofer.aisec.cpg.graph.statements.expressions.* import de.fraunhofer.aisec.cpg.graph.types.PointerType -import de.fraunhofer.aisec.cpg.passes.GoExtraPass +import de.fraunhofer.aisec.cpg.passes.SymbolResolver import de.fraunhofer.aisec.cpg.passes.order.DependsOn import de.fraunhofer.aisec.cpg.processing.IVisitor import de.fraunhofer.aisec.cpg.processing.strategy.Strategy import io.clouditor.graph.* import io.clouditor.graph.passes.HttpClientPass +import io.clouditor.graph.testing.LocalTestingPass import kotlin.streams.toList -@Suppress("UNUSED_PARAMETER") -@DependsOn(GoExtraPass::class) +@DependsOn(SymbolResolver::class) +@DependsOn(LocalTestingPass::class, softDependency = true) +// @DependsOn(KubernetesPass::class, softDependency = true) class GolangHttpPass(ctx: TranslationContext) : HttpClientPass(ctx) { private val clients = mutableMapOf() diff --git a/cloudpg/src/main/java/io/clouditor/graph/testing/LocalTestingPass.kt b/cloudpg/src/main/java/io/clouditor/graph/testing/LocalTestingPass.kt index 189d224..a8510a7 100644 --- a/cloudpg/src/main/java/io/clouditor/graph/testing/LocalTestingPass.kt +++ b/cloudpg/src/main/java/io/clouditor/graph/testing/LocalTestingPass.kt @@ -9,13 +9,10 @@ import de.fraunhofer.aisec.cpg.TranslationResult import de.fraunhofer.aisec.cpg.graph.Name import de.fraunhofer.aisec.cpg.graph.declarations.TranslationUnitDeclaration import de.fraunhofer.aisec.cpg.passes.TranslationResultPass -import de.fraunhofer.aisec.cpg.passes.order.DependsOn import io.clouditor.graph.* -import io.clouditor.graph.passes.golang.GinGonicPass import io.clouditor.graph.passes.golang.appendPath import java.nio.file.Files -@DependsOn(GinGonicPass::class) class LocalTestingPass(ctx: TranslationContext) : TranslationResultPass(ctx) { override fun accept(t: TranslationResult) { diff --git a/cloudpg/src/test/java/io/clouditor/graph/PerformanceTest.kt b/cloudpg/src/test/java/io/clouditor/graph/PerformanceTest.kt index d8bbb0c..5a183f5 100644 --- a/cloudpg/src/test/java/io/clouditor/graph/PerformanceTest.kt +++ b/cloudpg/src/test/java/io/clouditor/graph/PerformanceTest.kt @@ -2,7 +2,6 @@ package io.clouditor.graph import kotlin.io.path.* import kotlinx.benchmark.Scope -import kotlinx.benchmark.readFile import org.junit.Test import org.openjdk.jmh.annotations.* @@ -70,7 +69,7 @@ open class PerformanceTest { // create ONE large file val tmp = createTempFile(dir, "detectability", ".py") - tmp.appendText(serverSrc.readFile()) + tmp.appendText(Path(serverSrc).readText()) // append the function i times to the temporary file for (i in 1..range.toInt()) { val sampleFunction = diff --git a/ppg-testing-library/Linkability/L3-linkability-of-inbound-data/Go/client.go b/ppg-testing-library/Linkability/L3-linkability-of-inbound-data/Go/client.go index 3a78bd4..af52da6 100644 --- a/ppg-testing-library/Linkability/L3-linkability-of-inbound-data/Go/client.go +++ b/ppg-testing-library/Linkability/L3-linkability-of-inbound-data/Go/client.go @@ -7,9 +7,10 @@ import ( func main() { //@PseudoIdentifier - name := "firstname lastname" + var name = "firstname lastname" + //name := "firstname lastname" data := url.Values{ - "Name": {name}, + "Name": {name}, "Message": {"hello world"}, }