Skip to content

Commit 728a73c

Browse files
committed
Add description for Android setup
1 parent 497f894 commit 728a73c

File tree

3 files changed

+94
-1
lines changed

3 files changed

+94
-1
lines changed

docs/general/android_setup.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Boomerang for Android Applications
2+
3+
Boomerang can be applied to Android applications using [FlowDroid](https://github.com/secure-software-engineering/FlowDroid).
4+
FlowDroid is a static analysis tool that computes call graphs and data flows in Android applications.
5+
Since it is based on Soot, one can use the Soot scope to instantiate a [FrameworkScope](../general/framework_scopes.md).
6+
7+
## Dependencies
8+
9+
To use FlowDroid with Boomerang, include the FlowDroid and the Soot scope dependencies in your project:
10+
11+
```
12+
<!-- BoomerangScope for Soot (Make sure to use the most recent Boomerang version) -->
13+
<dependency>
14+
<groupId>de.fraunhofer.iem</groupId>
15+
<artifactId>boomerangScope-Soot</artifactId>
16+
<version>a.b.c</version>
17+
</dependency>
18+
19+
<!-- FlowDroid dependencies (Make sure to choose the most recent FlowDroid version) -->
20+
<dependency>
21+
<groupId>de.fraunhofer.sit.sse.flowdroid</groupId>
22+
<artifactId>soot-infoflow</artifactId>
23+
<version>x.y.z</version>
24+
</dependency>
25+
<dependency>
26+
<groupId>de.fraunhofer.sit.sse.flowdroid</groupId>
27+
<artifactId>soot-infoflow-summaries</artifactId>
28+
<version>x.y.z</version>
29+
</dependency>
30+
<dependency>
31+
<groupId>de.fraunhofer.sit.sse.flowdroid</groupId>
32+
<artifactId>soot-infoflow-android</artifactId>
33+
<version>x.y.z</version>
34+
</dependency>
35+
```
36+
37+
## Setting up FlowDroid
38+
39+
To instantiate the `SootFrameworkScope`, we have to compute a call graph.
40+
However, instead of setting up Soot (as described [here](../general/framework_scopes.md)), we use FlowDroid to construct a call graph that takes Android's activity lifecycle into account.
41+
For example, we can use the following FlowDroid setup:
42+
43+
```java
44+
InfoflowAndroidConfiguration config = new InfoFLowAndroidConfiguration();
45+
46+
// Use CHA as call graph algorithm
47+
config.setCallgraphAlgorithm(InfoflowAndroidConfiguration.CallgraphAlgorithm.CHA);
48+
49+
// Set the target app and the platforms for the SDK(s)
50+
config.getAnalysisFileConfig().setTargetAPKFile(<pathToTheAPKFile>);
51+
config.getAnalysisFileConfig().setAndroidPlatformDir(<pathToThePlatformsDir>);
52+
53+
// Further setup: Do not eliminate unreachable code and keep the original line numbers
54+
config.setCodeEliminationMode(InfoflowConfiguration.CodeEliminationMode.NoCodeElimination);
55+
config.setEnableLineNumbers(true);
56+
57+
// Configure FlowDroid
58+
SetupApplication app = new SetupApplication();
59+
app.setSootConfig(new SootConfigForAndroid() {
60+
@Override
61+
public void setSootOptions(Options options, InfoFlowConfiguration config) {
62+
options.setPhaseOptions("jb.sils", "enabled:false");
63+
64+
// By default, FlowDroid loads the Android packages which makes the call graph very large
65+
// and the analysis slow. Only include them, if they are really needed
66+
options.set_exclude(List.of("android.*", "androidx.*"));
67+
}
68+
})
69+
```
70+
71+
With the configured `SetupApplication`, we can now construct the call graph and instantiate the `SootFrameworkScope` as follows:
72+
73+
```java
74+
// Construct the Android specific call graph
75+
app.constructCallGraph();
76+
77+
// Do not forget to apply the PreTransformer
78+
BoomerangPretransformer.v().reset();
79+
BoomerangPretransformer.v().apply();
80+
81+
// Framework scope objects
82+
DataFlowScope dataFlowScope = DataFlowScope.EXCLUDE_PHANTOM_CLASSES;
83+
CallGraph callGraph = Scene.v().getCallGraph();
84+
Collection<SootMethod> entryPoints = Scene.v().getEntryPoints();
85+
86+
// Setup up the framework scope
87+
FrameworkScope scope = new SootFrameworkScope(Scene.v(), callGraph, entryPoints, dataFlowScope);
88+
```
89+
90+
With the `scope`, we can continue with [Boomerang](../boomerang/boomerang_setup.md) and [IDEal]().

docs/general/boomerang_scope.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Boomerang defines its own scope that is not related to any static analysis framework.
44
The scope consists of a set of interfaces and classes that specify relevant information required by Boomerang to perform its analyses.
55
Currently, we provide a scope implementations for the static analysis frameworks [Soot](https://github.com/soot-oss/soot), [SootUp](https://github.com/soot-oss/sootup) and [Opal](https://github.com/opalj/opal) (see the [FrameworkScopes](framework_scopes.md)).
6-
The scopes contain implementations for all relevant interfaces and objects s.t. Boomerang can be used with those frameworks without the need of additional implementation.
6+
The scopes contain implementations for all relevant interfaces and objects such that Boomerang can be used with those frameworks without the need of additional work.
77

88
## Dealing with Framework Objects
99

@@ -186,6 +186,8 @@ public class ExtendedDataFlowScope implements DataFlowScope {
186186

187187
## Queries
188188

189+
// TODO ForwardQueries and BackwardQueries
190+
189191
## AnalysisScope
190192

191193
Boomerang provides an `AnalysisScope` to compute initial queries along the complete reachable program.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ nav:
99
- Installation: general/installation.md
1010
- Boomerang Scope: general/boomerang_scope.md
1111
- Framework Scopes: general/framework_scopes.md
12+
- Android Setup: general/android_setup.md
1213
- Boomerang:
1314
- Boomerang Setup: boomerang/boomerang_setup.md
1415
- Options: boomerang/options.md

0 commit comments

Comments
 (0)