-
Notifications
You must be signed in to change notification settings - Fork 88
Use the new OGM to export cpg as json #2392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
0ea2193 to
bb2eefa
Compare
❌ 2 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
oxisto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! the implementation even looks simpler than before. Next step would be to use the same functions in the schema export thingie
| @@ -0,0 +1,116 @@ | |||
| /* | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can even move this file to cog-core? Should not have any dependencies on neo4j anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, good point, moved it to core
| import de.fraunhofer.aisec.cpg.helpers.Benchmark | ||
| import java.io.File | ||
|
|
||
| data class JsonNode(val id: String, val labels: Set<String>, val properties: Map<String, Any?>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some doc here would be nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
|
||
| data class JsonNode(val id: String, val labels: Set<String>, val properties: Map<String, Any?>) | ||
|
|
||
| data class JsonEdge( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some doc here would be nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| val properties: Map<String, Any?>, | ||
| ) | ||
|
|
||
| data class JsonGraph(val nodes: List<JsonNode>, val edges: List<JsonEdge>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some doc here would be nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
bb2eefa to
176b407
Compare
e36f3a4 to
a5f56cb
Compare
|
I noticed, the duplicate node UUID problem is not specific to inferred nodes. [
{
"id": "ffffffff-b571-ae40-ffff-ffff8b131677",
"labels": [
"Node",
"AstNode",
"Statement",
"Expression",
"Reference"
],
"properties": {
"access": "READ",
"isStaticAccess": false,
"referenceTag": -1839066876,
"argumentIndex": 0,
"code": "a",
"isImplicit": false,
"isInferred": false,
"artifact": "file:///dilithium/ref/poly.c",
"endLine": 253,
"endColumn": 30,
"startColumn": 29,
"startLine": 253,
"fullName": "a",
"localName": "a",
"nameDelimiter": "::",
"name": "a"
}
},
{
"id": "ffffffff-b571-ae40-ffff-ffff8b131677",
"labels": [
"Node",
"AstNode",
"Statement",
"Expression",
"Reference"
],
"properties": {
"access": "READ",
"isStaticAccess": false,
"referenceTag": -1497655690,
"argumentIndex": 0,
"code": "a",
"isImplicit": false,
"isInferred": false,
"artifact": "file:///dilithium/ref/poly.c",
"endLine": 625,
"endColumn": 18,
"startColumn": 17,
"startLine": 625,
"fullName": "a",
"localName": "a",
"nameDelimiter": "::",
"name": "a"
}
}
] |
| import picocli.CommandLine | ||
|
|
||
| fun createTranslationResult(file: String = "client.cpp"): Pair<Application, TranslationResult> { | ||
| fun createTranslationResult(file: String = "client.cpp"): TranslationResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No being in the cpg-core we probably cannot access the cxx language frontend anymore ^^
Is there an alternative way to create a graph that we can export for the test-case?
2454689 to
13d76da
Compare
13d76da to
464b4be
Compare
Transition from the Neo4j OGM to the cpg internal OGM to persist cpg as json, analog to the Neo4j persistence.
One problem I'm currently facing with this approach is, that in some cases nodes with duplicate id (uuid) occur.
Not sure if those nodes are actually the same, or if there is a collision with the uuid.
Example:
https://github.com/pq-crystals/dilithium
{ "id": "ffffffff-ad71-abff-ffff-ffffcb38da74", "labels": [ "Node", "Declaration", "ValueDeclaration", "VariableDeclaration" ], "properties": { "isArray": false, "isGlobal": true, "isImplicitInitializerAllowed": false, "argumentIndex": 0, "isImplicit": false, "isInferred": true, "fullName": "pqcrystals_dilithium2_ref_idxlut", "localName": "pqcrystals_dilithium2_ref_idxlut", "nameDelimiter": "::", "name": "pqcrystals_dilithium2_ref_idxlut" } }, { "id": "ffffffff-ad71-abff-ffff-ffffcb38da74", "labels": [ "Node", "Declaration", "ValueDeclaration", "VariableDeclaration" ], "properties": { "isArray": false, "isGlobal": true, "isImplicitInitializerAllowed": false, "argumentIndex": 0, "isImplicit": false, "isInferred": true, "fullName": "pqcrystals_dilithium2_ref_idxlut", "localName": "pqcrystals_dilithium2_ref_idxlut", "nameDelimiter": "::", "name": "pqcrystals_dilithium2_ref_idxlut" } }, { "id": "ffffffff-ad71-abff-ffff-ffffcb38da74", "labels": [ "Node", "Declaration", "ValueDeclaration", "VariableDeclaration" ], "properties": { "isArray": false, "isGlobal": true, "isImplicitInitializerAllowed": false, "argumentIndex": 0, "isImplicit": false, "isInferred": true, "fullName": "pqcrystals_dilithium2_ref_idxlut", "localName": "pqcrystals_dilithium2_ref_idxlut", "nameDelimiter": "::", "name": "pqcrystals_dilithium2_ref_idxlut" } }, [...]