Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed the Old APKAnalysisInputLocation #1048

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions docs/analysisinput.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,49 @@ AnalysisInputLocation jimpleLocation = new JimpleAnalysisInputLocation(path);
JavaView view = new JavaView(jimpleLocation);
```


### Android Bytecode
File-Extensions: `.apk`

The `ApkAnalysisInputLocation` is the APK frontend written for Sootup

```java
Path path = Paths.get("Banana.apk");
AnalysisInputLocation inputLocation = new ApkAnalysisInputLocation(path, "", DexBodyInterceptors.Default.bodyInterceptors());
JavaView view = new JavaView(inputLocation);
```


### Android Bytecode with Dex2Jar
File-Extensions: `.apk`

The `ApkAnalysisInputLocation` currently uses dex2jar internally

```java
Path path = Paths.get("Banana.apk");
AnalysisInputLocation inputLocation = new ApkAnalysisInputLocation(path);
AnalysisInputLocation inputLocation = new Dex2JarAnalysisInputLocation(path);
JavaView view = new JavaView(inputLocation);

```

```java
public class Dex2JarAnalysisInputLocation extends ArchiveBasedAnalysisInputLocation {

public Dex2JarAnalysisInputLocation(@Nonnull Path path, @Nullable SourceType srcType) {
super(path, srcType);
String jarPath = dex2jar(path);
this.path = Paths.get(jarPath);
}

private String dex2jar(Path path) {
String apkPath = path.toAbsolutePath().toString();
String outDir = "./tmp/";
int start = apkPath.lastIndexOf(File.separator);
int end = apkPath.lastIndexOf(".apk");
String outputFile = outDir + apkPath.substring(start + 1, end) + ".jar";
Dex2jarCmd.main("-f", apkPath, "-o", outputFile);
return outputFile;
}
}
```

!!! info "A SootUp solution to directly generate Jimple is WIP!"
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@
@Tag(TestCategories.JAVA_8_CATEGORY)
public class PathBasedAnalysisInputLocationTest extends AnalysisInputLocationTest {

@Test
public void testApk() {
PathBasedAnalysisInputLocation pathBasedNamespace =
new ApkAnalysisInputLocation(apk, SourceType.Application);
final ClassType mainClass =
getIdentifierFactory().getClassType("de.upb.futuresoot.fields.MainActivity");
testClassReceival(pathBasedNamespace, Collections.singletonList(mainClass), 1392);
}

@Test
public void testSingleClass() {
PathBasedAnalysisInputLocation pathBasedNamespace =
Expand Down
Loading