-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix dataflow of return statement (#2244)
- Loading branch information
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...tends/javasrc2cpg/src/test/scala/io/joern/javasrc2cpg/querying/dataflow/ReturnTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.joern.javasrc2cpg.querying.dataflow | ||
|
||
import io.joern.javasrc2cpg.testfixtures.JavaDataflowFixture | ||
import io.joern.dataflowengineoss.language._ | ||
import io.shiftleft.semanticcpg.language._ | ||
|
||
class ReturnTests extends JavaDataflowFixture { | ||
|
||
behavior of "Dataflow to return statements" | ||
|
||
override val code: String = | ||
""" | ||
|public class Foo { | ||
| public void bar() { | ||
| int x = 42; | ||
| return x; | ||
| } | ||
|} | ||
|""".stripMargin | ||
|
||
it should "find a flow from x in return statement to 42" in { | ||
val src = cpg.literal("42") | ||
val snk = cpg.identifier("x").lineNumber(5) | ||
snk.reachableBy(src).size shouldBe 1 | ||
} | ||
} |