Skip to content

Commit

Permalink
api based flows for benchmark
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
  • Loading branch information
prabhu committed Oct 13, 2023
1 parent 44b14e4 commit 8d59ff2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main/scala/io/appthreat/atom/slicing/ReachableSlicing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@ object ReachableSlicing {
val engineConfig = EngineConfig()
implicit val context: EngineContext = EngineContext(semantics, engineConfig)
private implicit val finder: NodeExtensionFinder = DefaultNodeExtensionFinder
private val API_TAG = "api"

def calculateReachableSlice(atom: Cpg, config: ReachablesConfig): ReachableSlice = {
def source = atom.tag.name(config.sourceTag).parameter
def sink = atom.ret.where(_.tag.name(config.sinkTag))
ReachableSlice(sink.reachableByFlows(source).map(toSlice).toList)
def source = atom.tag.name(config.sourceTag).parameter
def sink = atom.ret.where(_.tag.name(config.sinkTag))
var flowsList = sink.reachableByFlows(source).map(toSlice).toList
// If we did not identify any flows from input to output, fallback to looking for
// flows between two apis
if (flowsList.isEmpty) {
flowsList =
atom.tag.name(API_TAG).parameter.reachableByFlows(atom.tag.name(API_TAG).parameter).map(toSlice).toList
}
ReachableSlice(flowsList)
}

private def tagAsString(tag: Iterator[Tag]): String = if (tag.nonEmpty) tag.name.mkString(", ") else ""
Expand Down

0 comments on commit 8d59ff2

Please # to comment.