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

Update soot to 4.4.1 and accept .jar as well as dirs as input #65

Merged
merged 2 commits into from
Aug 15, 2023
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
4 changes: 2 additions & 2 deletions java/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.debricked</groupId>
<artifactId>SootWrapper</artifactId>
<version>5.0</version>
<version>5.1</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
Expand All @@ -23,7 +23,7 @@
<dependency>
<groupId>org.soot-oss</groupId>
<artifactId>soot</artifactId>
<version>4.2.1</version>
<version>4.4.1</version>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
Expand Down
18 changes: 15 additions & 3 deletions java/common/src/main/java/SootWrapper/Cli.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public static void main(String[] args) {

@Override
public Integer call() throws Exception {
checkExistsAndIsDir(userCodePaths);
checkExistsAndIsDir(libraryCodePaths);
checkExistsAndIsDir(userCodePaths, true);
checkExistsAndIsDir(libraryCodePaths, false);
BufferedWriter writer;
if (outputFile != null) {
if (outputFile.isDirectory()) {
Expand Down Expand Up @@ -85,13 +85,25 @@ public Integer call() throws Exception {
return exitCode;
}

private static void checkExistsAndIsDir(Iterable<? extends Path> paths) throws FileNotFoundException {
private static void checkExistsAndIsDir(Iterable<? extends Path> paths, boolean checkJar) throws FileNotFoundException {
for (Path p : paths) {
File f = p.toFile();
if (!f.exists()) {
throw new FileNotFoundException(String.format("Error: %s can't be found", p));
}
if (!f.isDirectory()) {
// Check for .jar file
if (checkJar) {
String fileName = f.getName();
int index = fileName.lastIndexOf('.');
if (index > 0) {
String extension = fileName.substring(index+1);
if (extension.equals("jar")) {
return;
}
}
}

throw new IllegalArgumentException(String.format("Error: %s is not a directory", p));
}
}
Expand Down
2 changes: 1 addition & 1 deletion java/common/src/test/java/SootWrapper/SootWrapperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void testGetCallGraphSelf() {
"SootWrapper.Cli.main(String[])"
});
assertMethodIsCalledByMethods(calls, "java.io.File.exists()", new String[]{
"SootWrapper.Cli.checkExistsAndIsDir(Iterable)"
"SootWrapper.Cli.checkExistsAndIsDir(Iterable, boolean)"
});
assertMethodIsCalledByMethods(calls, "soot.G.reset()", new String[]{
"SootWrapper.SootWrapper.writeAnalysis(JSONWriter, Iterable, Iterable)"
Expand Down