Skip to content

Commit 3ce8769

Browse files
committed
Soot api improvements for android
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com> Update packages Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
1 parent add037f commit 3ce8769

File tree

6 files changed

+28
-14
lines changed

6 files changed

+28
-14
lines changed

platform/frontends/c2cpg/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ libraryDependencies ++= Seq(
1010
ExclusionRule(organization = "org.eclipse.platform", name = "org.eclipse.jface"),
1111
ExclusionRule(organization = "org.eclipse.platform", name = "org.eclipse.jface.text")
1212
),
13-
"org.jline" % "jline" % "3.29.0",
13+
"org.jline" % "jline" % "3.30.4",
1414
"org.scalatest" %% "scalatest" % Versions.scalatest % Test
1515
)
1616

platform/frontends/jimple2cpg/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dependsOn(Projects.dataflowengineoss, Projects.x2cpg % "compile->compile;test->t
44

55
libraryDependencies ++= Seq(
66
"io.appthreat" %% "cpg2" % Versions.cpg,
7-
"commons-io" % "commons-io" % "2.19.0",
7+
"commons-io" % "commons-io" % "2.20.0",
88
"org.soot-oss" % "soot" % "4.6.0",
99
"org.scala-lang.modules" % "scala-asm" % "9.8.0-scala-1",
1010
"org.ow2.asm" % "asm" % "9.8",

platform/frontends/jimple2cpg/src/main/scala/io/appthreat/jimple2cpg/Jimple2Cpg.scala

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ class Jimple2Cpg extends X2CpgFrontend[Config]:
3030
case Some(value) if value.nonEmpty =>
3131
Options.v().set_src_prec(Options.src_prec_apk)
3232
Options.v().set_force_android_jar(value)
33+
Options.v().setPhaseOption("dex", "ignore-errors:true")
3334
case _ =>
3435
Options.v().set_src_prec(Options.src_prec_apk_c_j)
3536
Options.v().set_process_multiple_dex(true)
37+
Options.v().set_search_dex_in_archives(true)
38+
Options.v().set_native_code(true)
3639
// workaround for Soot's bug while parsing large apk.
3740
// see: https://github.com/soot-oss/soot/issues/1256
3841
Options.v().setPhaseOption("jb", "use-original-names:false")
@@ -50,7 +53,7 @@ class Jimple2Cpg extends X2CpgFrontend[Config]:
5053
recurse: Boolean,
5154
onlyClasses: Boolean
5255
): List[ClassFile] =
53-
val archiveFileExtensions = Set(".jar", ".war", ".zip")
56+
val archiveFileExtensions = Set(".jar", ".war", ".zip", ".apkm", ".xapk")
5457
extractClassesInPackageLayout(
5558
src,
5659
tmpDir,
@@ -139,15 +142,31 @@ class Jimple2Cpg extends X2CpgFrontend[Config]:
139142
G.reset()
140143

141144
private def configureSoot(config: Config, outDir: File): Unit =
142-
// set application mode
143-
Options.v().set_app(false)
144-
Options.v().set_whole_program(false)
145+
if config.fullResolver then
146+
// full transitive resolution of all references
147+
Options.v().set_full_resolver(true)
148+
// set application mode
149+
Options.v().set_app(true)
150+
Options.v().set_whole_program(true)
151+
Options.v().setPhaseOption(
152+
"cg.spark",
153+
"enabled:true,on-fly-cg:true,propagator:worklist,safe-newinstance:true"
154+
)
155+
Options.v().setPhaseOption("cg.cha", "enabled:true")
156+
Options.v().setPhaseOption("tagger", "enabled:true")
157+
else
158+
Options.v().set_app(false)
159+
Options.v().set_whole_program(false)
160+
// don’t choke on missing classes in huge app frameworks
161+
Options.v().set_ignore_resolution_errors(true)
162+
Options.v().set_ignore_methodsource_error(true)
145163
// keep debugging info
146164
Options.v().set_keep_line_number(true)
147165
Options.v().set_keep_offset(true)
148166
// ignore library code
149167
Options.v().set_no_bodies_for_excluded(true)
150168
Options.v().set_allow_phantom_refs(true)
169+
Options.v().set_allow_phantom_elms(true)
151170
// keep variable names
152171
Options.v().setPhaseOption("jb.sils", "enabled:false")
153172
Options.v().setPhaseOption("jb", "use-original-names:true")
@@ -157,12 +176,7 @@ class Jimple2Cpg extends X2CpgFrontend[Config]:
157176
// output jimple
158177
Options.v().set_output_format(Options.output_format_jimple)
159178
Options.v().set_output_dir(outDir.canonicalPath)
160-
161179
Options.v().set_dynamic_dir(config.dynamicDirs.asJava)
162180
Options.v().set_dynamic_package(config.dynamicPkgs.asJava)
163-
164-
if config.fullResolver then
165-
// full transitive resolution of all references
166-
Options.v().set_full_resolver(true)
167181
end configureSoot
168182
end Jimple2Cpg

platform/frontends/jimple2cpg/src/main/scala/io/appthreat/jimple2cpg/Main.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private object Frontend:
5959
.action((_, config) => config.withOnlyClasses(true)),
6060
opt[Unit]("full-resolver")
6161
.text(
62-
"enables full transitive resolution of all references found in all classes that are resolved"
62+
"enables whole program analysis and full transitive resolution of all references found in all classes that are resolved"
6363
)
6464
.action((_, config) => config.withFullResolver(true)),
6565
opt[Unit]("recurse")

platform/frontends/jssrc2cpg/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependsOn(Projects.dataflowengineoss, Projects.x2cpg % "compile->compile;test->t
1010
libraryDependencies ++= Seq(
1111
"io.appthreat" %% "cpg2" % Versions.cpg,
1212
"com.lihaoyi" %% "upickle" % Versions.upickle,
13-
"com.typesafe" % "config" % "1.4.3",
13+
"com.typesafe" % "config" % "1.4.4",
1414
"com.michaelpollmeier" % "versionsort" % "1.0.17",
1515
"org.scalatest" %% "scalatest" % Versions.scalatest % Test
1616
)

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.10.11
1+
sbt.version=1.11.2

0 commit comments

Comments
 (0)