diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/Node.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/Node.kt index ddc0e09218..a2322d695f 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/Node.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/Node.kt @@ -32,16 +32,16 @@ import de.fraunhofer.aisec.cpg.TranslationContext import de.fraunhofer.aisec.cpg.TypeManager import de.fraunhofer.aisec.cpg.frontends.Handler import de.fraunhofer.aisec.cpg.frontends.Language -import de.fraunhofer.aisec.cpg.graph.concepts.OverlaySingleEdge -import de.fraunhofer.aisec.cpg.graph.declarations.* -import de.fraunhofer.aisec.cpg.graph.edges.* +import de.fraunhofer.aisec.cpg.graph.declarations.MethodDeclaration +import de.fraunhofer.aisec.cpg.graph.declarations.RecordDeclaration +import de.fraunhofer.aisec.cpg.graph.declarations.TranslationUnitDeclaration import de.fraunhofer.aisec.cpg.graph.edges.ast.astEdgesOf -import de.fraunhofer.aisec.cpg.graph.edges.flows.ControlDependences -import de.fraunhofer.aisec.cpg.graph.edges.flows.Dataflows -import de.fraunhofer.aisec.cpg.graph.edges.flows.EvaluationOrders -import de.fraunhofer.aisec.cpg.graph.edges.flows.FullDataflowGranularity -import de.fraunhofer.aisec.cpg.graph.edges.flows.ProgramDependences -import de.fraunhofer.aisec.cpg.graph.scopes.* +import de.fraunhofer.aisec.cpg.graph.edges.flows.* +import de.fraunhofer.aisec.cpg.graph.edges.overlay.OverlaySingleEdge +import de.fraunhofer.aisec.cpg.graph.edges.unwrapping +import de.fraunhofer.aisec.cpg.graph.scopes.GlobalScope +import de.fraunhofer.aisec.cpg.graph.scopes.RecordScope +import de.fraunhofer.aisec.cpg.graph.scopes.Scope import de.fraunhofer.aisec.cpg.helpers.SubgraphWalker import de.fraunhofer.aisec.cpg.helpers.neo4j.LocationConverter import de.fraunhofer.aisec.cpg.helpers.neo4j.NameConverter @@ -53,7 +53,10 @@ import java.util.* import kotlin.uuid.Uuid import org.apache.commons.lang3.builder.ToStringBuilder import org.apache.commons.lang3.builder.ToStringStyle -import org.neo4j.ogm.annotation.* +import org.neo4j.ogm.annotation.GeneratedValue +import org.neo4j.ogm.annotation.Id +import org.neo4j.ogm.annotation.Relationship +import org.neo4j.ogm.annotation.Transient import org.neo4j.ogm.annotation.typeconversion.Convert import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/OverlayNode.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/OverlayNode.kt index 378c2e334a..c8cc0f888a 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/OverlayNode.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/OverlayNode.kt @@ -45,4 +45,3 @@ abstract class OverlayNode() : Node() { ) var underlyingNode by unwrapping(OverlayNode::underlyingNodeEdge) } - diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/concepts/Concept.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/concepts/Concept.kt index a28fea3171..d589f035d5 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/concepts/Concept.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/concepts/Concept.kt @@ -26,6 +26,7 @@ package de.fraunhofer.aisec.cpg.graph.concepts import de.fraunhofer.aisec.cpg.graph.OverlayNode +import org.neo4j.ogm.annotation.Relationship /** * Represents a new concept added to the CPG. This is intended for modelling "concepts" like @@ -34,5 +35,5 @@ import de.fraunhofer.aisec.cpg.graph.OverlayNode */ abstract class Concept() : OverlayNode() { /** All [Operation]s belonging to this concept. */ - val ops: Set = setOf() + val ops: MutableSet = mutableSetOf() } diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/edges/overlay/Overlay.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/edges/overlay/Overlay.kt index afe906da1c..aa2d607720 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/edges/overlay/Overlay.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/edges/overlay/Overlay.kt @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2024, Fraunhofer AISEC. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $$$$$$\ $$$$$$$\ $$$$$$\ + * $$ __$$\ $$ __$$\ $$ __$$\ + * $$ / \__|$$ | $$ |$$ / \__| + * $$ | $$$$$$$ |$$ |$$$$\ + * $$ | $$ ____/ $$ |\_$$ | + * $$ | $$\ $$ | $$ | $$ | + * \$$$$$ |$$ | \$$$$$ | + * \______/ \__| \______/ + * + */ package de.fraunhofer.aisec.cpg.graph.edges.overlay import de.fraunhofer.aisec.cpg.graph.Node @@ -6,7 +31,6 @@ import de.fraunhofer.aisec.cpg.graph.edges.collections.EdgeSingletonList import de.fraunhofer.aisec.cpg.graph.edges.collections.MirroredEdgeCollection import kotlin.reflect.KProperty - class OverlayEdge(start: Node, end: Node) : Edge(start, end) { override var labels: Set = setOf("OVERLAY") } diff --git a/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/Neo4JTest.kt b/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/Neo4JTest.kt index f6c6fc4b5d..a623d5c1bc 100644 --- a/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/Neo4JTest.kt +++ b/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/Neo4JTest.kt @@ -67,9 +67,9 @@ class Neo4JTest { val connectCall = result.calls["connect"] abstract class NetworkingOperation( - concept: Concept<*>, + concept: Concept, ) : Operation(concept) - class Connect(concept: Concept<*>) : NetworkingOperation(concept) + class Connect(concept: Concept) : NetworkingOperation(concept) class Networking() : Concept() val nw = Networking() @@ -78,6 +78,7 @@ class Neo4JTest { val connect = Connect(concept = nw) connect.underlyingNode = connectCall connect.name = Name("connect") + nw.ops += connect assertEquals(connect, connectCall?.overlayNode)