Skip to content

Commit

Permalink
[jimple2cpg]Update soot to 4.6.0 (#5249)
Browse files Browse the repository at this point in the history
* [jimple2cpg]Update soot to 4.6.0

https://github.com/soot-oss/soot/releases/tag/4.6.0

* [jimple2cpg] fix parse jimple fail, the two problems will cause the class and method not have correct info.

---------

Co-authored-by: NextToMinus <NextToMinus@gmail.com>
  • Loading branch information
sfncat and NextToMinus authored Jan 26, 2025
1 parent 133df78 commit c528e8a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,38 @@ trait AstForMethodsCreator(implicit withSchemaValidation: ValidationMode) { this
bodyStatementsInfo.targets.foreach { case (asts, unit) =>
asts.headOption match {
case Some(value) =>
diffGraph.addEdge(value.root.get, bodyStatementsInfo.unitToAsts(unit).last.root.get, EdgeTypes.CFG)
bodyStatementsInfo.unitToAsts.get(unit) match {
case Some(targetAsts) if targetAsts.nonEmpty =>
diffGraph.addEdge(value.root.get, targetAsts.last.root.get, EdgeTypes.CFG)
case _ =>
logger.error(
s"AstForMethodsCreator: Missing unit in unitToAsts: $unit (${unit.getClass.getSimpleName})"
)
}
case None =>
logger.error("AstForMethodsCreator: Empty asts list for target")
}
}

bodyStatementsInfo.edges.foreach { case (a, b) =>
val aNode = bodyStatementsInfo.unitToAsts(a).last.root.get
val bNode = bodyStatementsInfo.unitToAsts(b).last.root.get
diffGraph.addEdge(aNode, bNode, EdgeTypes.CFG)
(bodyStatementsInfo.unitToAsts.get(a), bodyStatementsInfo.unitToAsts.get(b)) match {
case (Some(aAsts), Some(bAsts)) if aAsts.nonEmpty && bAsts.nonEmpty =>
val aNode = aAsts.last.root.get
val bNode = bAsts.last.root.get
diffGraph.addEdge(aNode, bNode, EdgeTypes.CFG)
case _ =>
logger.error(
s"AstForMethodsCreator: Failed to add CFG edge between units: " +
s"a=${a.getClass.getSimpleName} (${a.toString.take(50)}) " +
s"b=${b.getClass.getSimpleName} (${b.toString.take(50)})"
)
if (bodyStatementsInfo.unitToAsts.get(a).isEmpty) {
logger.debug(s"AstForMethodsCreator: Missing source unit in unitToAsts: $a (${a.getClass.getSimpleName})")
}
if (bodyStatementsInfo.unitToAsts.get(b).isEmpty) {
logger.debug(s"AstForMethodsCreator: Missing target unit in unitToAsts: $b (${b.getClass.getSimpleName})")
}
}
}
}
}
Expand Down Expand Up @@ -230,7 +254,11 @@ trait AstForMethodsCreator(implicit withSchemaValidation: ValidationMode) { this
val trapStack = new mutable.Stack[soot.Trap];
body.getUnits.asScala.filterNot(isIgnoredUnit).foreach { statement =>
// Remove traps that ended on the previous unit
(1 to popTraps.getOrElse(statement, 0)).foreach(_ => trapStack.pop)
(1 to popTraps.getOrElse(statement, 0)).foreach { _ =>
if (trapStack.nonEmpty) {
trapStack.pop()
}
}

// Add traps that apply to this unit
pushTraps.getOrElse(statement, List.empty).foreach(trapStack.push)
Expand All @@ -246,7 +274,11 @@ trait AstForMethodsCreator(implicit withSchemaValidation: ValidationMode) { this
stack.push(stack.pop().withChildren(asts))
}

stack.pop()
if (stack.nonEmpty) {
stack.pop()
} else {
Ast(blockNode(body))
}
}

}
Expand Down
2 changes: 1 addition & 1 deletion project/Versions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object Versions {
val scalatest = "3.2.18"
val scopt = "4.1.0"
val semverParser = "0.0.6"
val soot = "4.5.0"
val soot = "4.6.0"
val slf4j = "2.0.7"
val log4j = "2.20.0"
val upickle = "4.0.2"
Expand Down

0 comments on commit c528e8a

Please sign in to comment.