-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jimple2cpg: Support loading apk/dex files to cpg directly (#2321)
* jimple2cpg: Support loading apk/dex files to cpg directly (via Soot's Dexpler converter) * jimple2cpg: Fix bug when Soot handling single class or jimple file
- Loading branch information
Showing
2 changed files
with
103 additions
and
34 deletions.
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
33 changes: 33 additions & 0 deletions
33
.../frontends/jimple2cpg/src/main/scala/io/joern/jimple2cpg/passes/SootAstCreationPass.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,33 @@ | ||
package io.joern.jimple2cpg.passes | ||
|
||
import io.joern.jimple2cpg.Jimple2Cpg | ||
import io.joern.x2cpg.datastructures.Global | ||
import io.shiftleft.codepropertygraph.Cpg | ||
import io.shiftleft.passes.ConcurrentWriterCpgPass | ||
import org.slf4j.LoggerFactory | ||
import soot.Scene | ||
import soot.SootClass | ||
import soot.SourceLocator | ||
|
||
/** Creates the AST layer from the given class file and stores all types in the given global parameter. | ||
*/ | ||
class SootAstCreationPass(cpg: Cpg) extends ConcurrentWriterCpgPass[SootClass](cpg) { | ||
|
||
val global: Global = new Global() | ||
private val logger = LoggerFactory.getLogger(classOf[AstCreationPass]) | ||
|
||
override def generateParts(): Array[_ <: AnyRef] = Scene.v().getApplicationClasses().toArray() | ||
|
||
override def runOnPart(builder: DiffGraphBuilder, part: SootClass): Unit = { | ||
val jimpleFile = SourceLocator.v().getSourceForClass(part.getName()) | ||
try { | ||
// sootClass.setApplicationClass() | ||
val localDiff = new AstCreator(jimpleFile, part, global).createAst() | ||
builder.absorb(localDiff) | ||
} catch { | ||
case e: Exception => | ||
logger.warn(s"Cannot parse: $part", e) | ||
} | ||
} | ||
|
||
} |