Skip to content

Commit ae8e2ae

Browse files
authored
Merge pull request #376 from stefanie-koss/feature/summariesUsingMultipleJars
Enable simultaneous processing of multiple JARs for summary generation
2 parents 830badb + c1e4e40 commit ae8e2ae

File tree

1 file changed

+28
-32
lines changed
  • soot-infoflow-summaries/src/soot/jimple/infoflow/methodSummary

1 file changed

+28
-32
lines changed

soot-infoflow-summaries/src/soot/jimple/infoflow/methodSummary/Main.java

+28-32
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.io.FilenameFilter;
66
import java.io.IOException;
77
import java.util.ArrayList;
8+
import java.util.Arrays;
89
import java.util.Collections;
910
import java.util.HashSet;
1011
import java.util.List;
@@ -104,9 +105,32 @@ public void run(final String[] args) throws FileNotFoundException, XMLStreamExce
104105
SummaryGenerator generator = new SummaryGeneratorFactory().initSummaryGenerator();
105106

106107
// Parse the mandatory arguments
107-
File toAnalyze = new File(extraArgs[0]);
108+
String toAnalyze = extraArgs[0];
108109
File outputFolder = new File(extraArgs[1]);
109110

111+
// Check if the given files to analyze do exist
112+
List<String> filesToAnalyze = Arrays.asList(toAnalyze.split(File.pathSeparator));
113+
for (String fileStr : filesToAnalyze) {
114+
File file = new File(fileStr);
115+
if (!file.exists()) {
116+
System.err.println("File not found: " + file);
117+
System.exit(1);
118+
return;
119+
}
120+
if (file.isDirectory()) {
121+
File[] files = file.listFiles(new FilenameFilter() {
122+
@Override
123+
public boolean accept(File dir, String name) {
124+
return name.toLowerCase().endsWith(".jar");
125+
}
126+
});
127+
for (int c = 0; c < files.length; c++) {
128+
File f = files[c];
129+
toAnalyze += File.pathSeparator + f.getPath();
130+
}
131+
}
132+
}
133+
110134
// Collect the classes to be analyzed from our command line
111135
List<String> classesToAnalyze = new ArrayList<>();
112136
if (!summarizeFullJAR) {
@@ -133,38 +157,10 @@ public void run(final String[] args) throws FileNotFoundException, XMLStreamExce
133157
configureOptionalSettings(cmd, generator);
134158

135159
// Configure the output directory
136-
if (!toAnalyze.exists()) {
137-
System.err.println("File not found: " + toAnalyze);
138-
System.exit(1);
139-
return;
140-
}
141160
generator.getConfig().addAdditionalSummaryDirectory(outputFolder.getAbsolutePath());
142161

143162
// Run it
144-
if (toAnalyze.isDirectory()) {
145-
File[] files = toAnalyze.listFiles(new FilenameFilter() {
146-
147-
@Override
148-
public boolean accept(File dir, String name) {
149-
return name.toLowerCase().endsWith(".jar");
150-
}
151-
152-
});
153-
for (int c = 0; c < files.length; c++) {
154-
File f = files[c];
155-
System.out.println(String.format("Jar %d of %d: %s", c + 1, files.length, f));
156-
createSummaries(generator, classesToAnalyze, forceOverwrite, f, outputFolder);
157-
}
158-
159-
// If we don't have any JAR files, the target may be a normal classpath with
160-
// Java class files
161-
if (files.length == 0) {
162-
System.out.println(String.format("Analyzing directory %s...", toAnalyze.getAbsolutePath()));
163-
createSummaries(generator, classesToAnalyze, forceOverwrite, toAnalyze, outputFolder);
164-
}
165-
} else {
166-
createSummaries(generator, classesToAnalyze, forceOverwrite, toAnalyze, outputFolder);
167-
}
163+
createSummaries(generator, classesToAnalyze, forceOverwrite, toAnalyze, outputFolder);
168164

169165
System.out.println("Done.");
170166
} catch (ParseException e) {
@@ -236,8 +232,8 @@ private void printHelpMessage() {
236232
}
237233

238234
private static void createSummaries(SummaryGenerator generator, List<String> classesToAnalyze,
239-
final boolean doForceOverwrite, File toAnalyze, File outputFolder) {
240-
ClassSummaries summaries = generator.createMethodSummaries(toAnalyze.getPath(), classesToAnalyze,
235+
final boolean doForceOverwrite, String toAnalyze, File outputFolder) {
236+
ClassSummaries summaries = generator.createMethodSummaries(toAnalyze, classesToAnalyze,
241237
new IClassSummaryHandler() {
242238

243239
@Override

0 commit comments

Comments
 (0)