-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds the cpg-concepts module and introduces Concept and Operation nodes. The new module is enabled for cpg-{neo4j,console}. There is an extension function to access those nodes as well as an integration test using the neo4j module. --------- Co-authored-by: Christian Banse <[email protected]>
- Loading branch information
1 parent
80d8100
commit 64dd8fc
Showing
12 changed files
with
159 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,4 @@ build.gradle.kts @oxisto | |
.github @oxisto | ||
|
||
cpg-language-ini @maximiliankaul | ||
cpg-concepts @maximiliankaul |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2021, 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. | ||
* | ||
* $$$$$$\ $$$$$$$\ $$$$$$\ | ||
* $$ __$$\ $$ __$$\ $$ __$$\ | ||
* $$ / \__|$$ | $$ |$$ / \__| | ||
* $$ | $$$$$$$ |$$ |$$$$\ | ||
* $$ | $$ ____/ $$ |\_$$ | | ||
* $$ | $$\ $$ | $$ | $$ | | ||
* \$$$$$ |$$ | \$$$$$ | | ||
* \______/ \__| \______/ | ||
* | ||
*/ | ||
plugins { | ||
id("cpg.frontend-conventions") | ||
} | ||
|
||
publishing { | ||
publications { | ||
named<MavenPublication>("cpg-concepts") { | ||
pom { | ||
artifactId = "cpg-concepts" | ||
name.set("Code Property Graph - Concepts") | ||
description.set("A 'concepts' extension for the CPG") | ||
} | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
// to evaluate some test cases | ||
testImplementation(project(":cpg-analysis")) | ||
|
||
// We depend on the Python frontend for the integration tests, but the frontend is only available if enabled. | ||
// If it's not available, the integration tests fail (which is ok). But if we would directly reference the | ||
// project here, the build system would fail any task since it will not find a non-enabled project. | ||
findProject(":cpg-language-python")?.also { | ||
integrationTestImplementation(it) | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
cpg-concepts/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/Extension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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 | ||
|
||
import de.fraunhofer.aisec.cpg.graph.concepts.Concept | ||
import de.fraunhofer.aisec.cpg.graph.concepts.Operation | ||
|
||
/** | ||
* Retrieves a set of all [Concept] nodes associated with this [Node] and its AST children | ||
* ([Node.nodes]). | ||
* | ||
* @return A set containing all [Concept] nodes found in the overlays of the [Node] and its | ||
* children. | ||
*/ | ||
val Node.conceptNodes: Set<Concept<*>> | ||
get() = this.nodes.flatMapTo(mutableSetOf()) { it.overlays.filterIsInstance<Concept<*>>() } | ||
|
||
/** | ||
* Retrieves a set of all [Operation] nodes associated with this [Node] and its AST children | ||
* ([Node.nodes]). | ||
* | ||
* @return A set containing all [Operation] nodes found in the overlays of the [Node] and its | ||
* children. | ||
*/ | ||
val Node.operationNodes: Set<Operation> | ||
get() = this.nodes.flatMapTo(mutableSetOf()) { it.overlays.filterIsInstance<Operation>() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Configuration status="WARN"> | ||
<Appenders> | ||
<Console name="STDOUT" target="SYSTEM_OUT"> | ||
<PatternLayout pattern="%d{HH:mm:ss,SSS} %-5p %C{1} %m%n"/> | ||
<ThresholdFilter level="DEBUG"/> | ||
</Console> | ||
</Appenders> | ||
<Loggers> | ||
<Logger level="DEBUG" name="de.fraunhofer.aisec.cpg"/> | ||
<Root level="DEBUG"> | ||
<AppenderRef ref="STDOUT"/> | ||
</Root> | ||
</Loggers> | ||
</Configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,4 +68,5 @@ dependencies { | |
|
||
testImplementation(testFixtures(projects.cpgCore)) | ||
|
||
implementation(project(":cpg-concepts")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters