devign: Mismatch methods in graph-for-funcs.sc, may need update?

Hi Dear Author,

Here is a issue about running graph-for-funcs.sc. There seems to have a lot of changes on joern methods and scalars, thus I try to modify your code to fit into the most recent one, however, here are two problems that cannot be solved yet whatever I try. Both are about the lacking methods in io.shiftleft.semanticcpg.language.NodeSteps. I checked the official repository (https://github.com/ShiftLeftSecurity/codepropertygraph) and go to codepropertygraph/semanticcpg/src/main/scala/io/shiftleft/semanticcpg/language/NodeSteps.scala, but cannot find correct methods for these two errors in line-93 and 94. Your help would be necessary for that. Thanks!

Compiling /home/zxx5113/devign/joern/graph-for-funcs.sc
graph-for-funcs.sc:93: value evalType is not a member of io.shiftleft.semanticcpg.language.NodeSteps[io.shiftleft.codepropertygraph.generated.nodes.Local]
      val sink = local.evalType(".*").referencingIdentifiers.dedup
                       ^
graph-for-funcs.sc:94: value nameNot is not a member of io.shiftleft.semanticcpg.language.NodeSteps[io.shiftleft.codepropertygraph.generated.nodes.Call]
      val source = new NodeSteps(methodVertex.out(EdgeTypes.CONTAINS).hasLabel(NodeTypes.CALL).cast[nodes.Call]).nameNot("<operator>.*").dedup
                                                                                                                 ^
java.lang.RuntimeException: Compilation Failed
  io.shiftleft.console.scripting.AmmoniteExecutor.$anonfun$runScript$7(AmmoniteExecutor.scala:50)
  cats.effect.internals.IORunLoop$.liftedTree3$1(IORunLoop.scala:229)
  cats.effect.internals.IORunLoop$.step(IORunLoop.scala:229)
  cats.effect.IO.unsafeRunTimed(IO.scala:320)
  cats.effect.IO.unsafeRunSync(IO.scala:239)
  io.shiftleft.console.scripting.ScriptManager.runScript(ScriptManager.scala:130)
  io.shiftleft.console.scripting.ScriptManager$CpgScriptRunner.runScript(ScriptManager.scala:64)
  io.shiftleft.console.scripting.ScriptManager$CpgScriptRunner.runScript(ScriptManager.scala:54)
  ammonite.$sess.cmd4$.<clinit>(cmd4.sc:1)

Bye!

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 24

Most upvoted comments

I had met many different errors when running the graph-for-funcs.sc with different versions of Joern, such as “Mismatch methods…”,“could not find implicit value for parameter encoder:…” and so on. So, I finally found that the version of Joern with 1.0.170 works fine!

Hi @epicosy, as Joern is updating every day, the graph-for-funcs.sc is not adjusted for the latest Joern anymore. I have modified the script and now it can be run in the newest Joern. (version 1.1.1456, 2023/2/17) Here is the script: graph-for-funcs.txt

Thank you @IntHelloWorld!. Now, I’m using Joern 1.1.1449, after replacing with your scripts, I have 0_cpg.bin and 0_cpg.json after creating the task. But I get the following errors:

joern> Would you like to save changes? (y/N)

Traceback (most recent call last):
  File "main.py", line 157, in <module>
    main()
  File "main.py", line 146, in main
    create_task()
  File "main.py", line 61, in create_task
    graphs = prepare.json_process(PATHS.cpg, json_file)
  File "/Users/ninolau/Documents/GitHub/devign/src/prepare/cpg_generator.py", line 74, in json_process
    container = [graph_indexing(graph) for graph in cpg_json["functions"] if graph["file"] != "N/A"]
  File "/Users/ninolau/Documents/GitHub/devign/src/prepare/cpg_generator.py", line 74, in <listcomp>
    container = [graph_indexing(graph) for graph in cpg_json["functions"] if graph["file"] != "N/A"]
  File "/Users/ninolau/Documents/GitHub/devign/src/prepare/cpg_generator.py", line 24, in graph_indexing
    idx = int(graph["file"].split(".c")[0].split("/")[-1])
ValueError: invalid literal for int() with base 10: '<empty>'

I checked 0_cpg.json and I found some in AST properties field. Do I create the CPGs successfully? If not, how should I solve it?

In the new version of Joern, the value of graph[“file”] when the graph belongs to no file is "<empty>" rather than "N/A", so simply replace "N/A" with "<empty>" will be ok 😃