Fraunhofer-AISEC / cpg

A library to extract Code Property Graphs from C/C++, Java, Go, Python, Ruby and every other language through LLVM-IR.
https://fraunhofer-aisec.github.io/cpg/
Apache License 2.0
277 stars 62 forks source link

Literals and the type of Value they hold are too generic in Schema #1458

Open konradweiss opened 6 months ago

konradweiss commented 6 months ago

While the generic part of Literal<T> is specified at node creation, the Schema printer cannot add information on the types that Literal is specified with and therefore contained in value. This may be a design Issue that can only be solved by subclassing Literal as we did in the past, e.g. StringLiteral, ´IntegerLiteral`. Which IMO we do not want.

oxisto commented 6 months ago

This actually also causes problems with the neo4j OGM when trying to load literal values back that for example hold big integers since we do not know the persisted original class of the literal value.

oxisto commented 6 months ago

A possible solution would be to persist both the value (as Any or more less) and a valueClass which specifies the class. I don't think that we need more specific information about it in the schema, do we?

konradweiss commented 6 months ago

The valueClass sounds sufficient, the place where we came to that conclusion was the vector generation for machine learning where we need some information on the type to encode the value. In that case we would need to provide information what values are allowed in the valueClass so a predefined set and not a generic like we currently have.