Skip to content

when saving nodes and edges of generated code graph to file, errors happened. #345

@zqxyus

Description

@zqxyus

Hi,
my goal is to use joern to generate code graph and save the edges and nodes to file. For example , given the file " before/177736.c" , we want to save the file's nodes and edges to local files etc., "before/177736.nodes.json", and "before/177736.edges.json" , the two files store node properties, and control/data flow edges for the 177736.c. The following code is the script saved in file get_func_graph.scala.

@main def exec(filename: String) = { importCode.c(filename) run.ossdataflow cpg.graph.E.map(node=>List(node.inNode.id, node.outNode.id, node.label, node.propertiesMap.get("VARIABLE"))).toJson |> filename + ".edges.json" cpg.graph.V.map(node=>node).toJson |> filename + ".nodes.json" delete }
when i run the command ./joern --script get_func_graph.scala --param='filename=/before/177736.c'. the following errors happened.

-- [E008] Not Found Error: /tmp/wrapped-script5571462726263193239.sc:4:13 ------
4 | cpg.graph.E.map(node=>List(node.inNode.id, node.outNode.id, node.label, node.propertiesMap.get("VARIABLE"))).toJson |> filename + ".edges.json"
| ^^^^^^^^^^^
| value E is not a member of flatgraph.Graph
-- [E008] Not Found Error: /tmp/wrapped-script5571462726263193239.sc:5:13 ------
5 | cpg.graph.V.map(node=>node).toJson |> filename + ".nodes.json"
| ^^^^^^^^^^^
| value V is not a member of flatgraph.Graph
2 errors found
Exception in thread "main" replpp.scripting.NonForkingScriptRunner$$anon$1: error during script execution: Error during compilation: Errors encountered during compilation - try --verbose for more output
Please check error output above!
For given input files: /tmp/wrapped-script5571462726263193239.sc
Re-run with --verbose for more details

joern version: v4.0.410
os : ubuntu

How to handle the errors? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions