ShiftLeftSecurity / ShiftLeftSecurity/codepropertygraph

Exception when using multiple return values

Open
#1,044 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
597
Forks
84
Avg merge
18h 29m
Merged PRs (30d)
1

Description

I am not sure whether this is already possible.

I'm specifying ASTs and am creating CPGs from them. I had some trouble finding out how return values need to be specified. I think that there needs to be a gap of 1 between the last order of an input parameter (METHOD_PARAMETER_IN) and the order of the (first) return value (METHOD_RETURN). This seems to work reliably as long as there only is 1 return value.

Are multiple return values already possible?

Both if I increment order further for a second return value and if I leave it just the same as ther first return value's order, I get this error message:

[error] (Writer) java.lang.RuntimeException: Edge of type CFG with direction OUT not supported by class MethodReturnDb
[error] java.lang.RuntimeException: Edge of type CFG with direction OUT not supported by class MethodReturnDb
[error]         at overflowdb.NodeDb.storeAdjacentNode(NodeDb.java:621)
[error]         at overflowdb.NodeDb.storeAdjacentNode(NodeDb.java:602)
[error]         at overflowdb.NodeDb.addEdge(NodeDb.java:298)
[error]         at overflowdb.NodeRef.addEdge(NodeRef.java:151)
[error]         at overflowdb.SemiEdge.$minus$minus$greater(SyntacticSugar.scala:59)
[error]         at io.shiftleft.passes.DiffGraph$Applier.odbAddEdge(DiffGraph.scala:388)
[error]         at io.shiftleft.passes.DiffGraph$Applier.addEdge(DiffGraph.scala:380)
[error]         at io.shiftleft.passes.DiffGraph$Applier.$anonfun$run$1(DiffGraph.scala:332)
[error]         at io.shiftleft.passes.DiffGraph$Applier.$anonfun$run$1$adapted(DiffGraph.scala:328)
[error]         at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:576)
[error]         at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:574)
[error]         at scala.collection.AbstractIterator.foreach(Iterator.scala:1196)
[error]         at io.shiftleft.passes.DiffGraph$Applier.run(DiffGraph.scala:328)
[error]         at io.shiftleft.passes.DiffGraph$Applier$.applyDiff(DiffGraph.scala:417)
[error]         at io.shiftleft.passes.ParallelCpgPass$Writer.run(ParallelCpgPass.scala:105)
[error]         at java.lang.Thread.run(Thread.java:748)

It is thrown only when building the CPG, not when just specifying the AST.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure by specifying an AST with multiple METHOD_RETURN nodes and building a CPG, rather than only specifying the AST. Start with MethodReturnDb and the DiffGraph.Applier.addEdge path shown in the stack trace; done means CPG construction accepts multiple return values without the CFG edge exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.