Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ossdataflowengine: fix edge case when tracking from receivers #2722

Merged
merged 2 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class SourceToStartingPoints(src: StoredNode) extends RecursiveTask[List[CfgNode
withFieldAndIndexAccesses(
List(x).collectAll[CfgNode].toList ++ x.refsTo.collectAll[Local].flatMap(sourceToStartingPoints)
) ++ x.refsTo.capturedByMethodRef.referencedMethod.flatMap(m => usagesForName(x.name, m))
case x: Call =>
(x._receiverIn.l ++ List(x)).collect { case y: CfgNode => y }
fabsx00 marked this conversation as resolved.
Show resolved Hide resolved
case x => List(x).collect { case y: CfgNode => y }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,4 +446,18 @@ class RegexDefinedFlowsDataFlowTests
}
}

"flows from receivers" should {
val cpg = code("""
|class Foo:
| def func():
| return "x"
|print(Foo.func())
|""".stripMargin)
"be found" in {
val src = cpg.call.code("Foo.func").l
val snk = cpg.call("print").l
snk.argument.reachableByFlows(src).size shouldBe 1
}
}

}