Skip to content

Commit 9fc139a

Browse files
committed
Release 1.2.0:
No Optional Command-Line Arguments anymore, but "internal" can be specified to use the internal data provided in the jar.
1 parent 24c16b6 commit 9fc139a

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

swan_core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>de.upb.cs.swt</groupId>
77
<artifactId>swan_core</artifactId>
88
<packaging>jar</packaging>
9-
<version>1.1.0</version>
9+
<version>1.2.0</version>
1010

1111
<name>SWAN Weakness Detector</name>
1212
<description>SWAN is a machine-learning approach for detection of methods of interest for security in Java libraries.</description>

swan_core/src/main/java/de/fraunhofer/iem/swan/Main.java

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,41 +21,30 @@ public class Main {
2121
public static void main(String[] args) {
2222

2323
try {
24-
boolean correctNumberOfArguments = args.length >= 2 && args.length <= 4;
25-
if (!correctNumberOfArguments) {
24+
if (args.length != 4) {
2625
System.err.println("");
2726
System.err.println(
28-
"Usage: java de.fraunhofer.iem.swan.Main <source-dir> [<train-sourcecode>] [<train-json>] <output-dir>\n");
27+
"Usage: java de.fraunhofer.iem.swan.Main <source-dir> <train-sourcecode> <train-json> <output-dir>\n");
2928
System.err.println("<source-dir>:\tDirectory with all JAR files or source code of the Test Data.");
3029
System.err.println("\t\tThis is the actual user library being evaluated.\n");
3130
System.err.println(
32-
"<train-sourcecode>: Directory with all JAR Files or source code of the Train Data to learn from.");
31+
"<train-sourcecode>: Directory with all JAR Files or source code of the Train Data to learn from");
3332
System.err.println(
34-
"\t\tThis is an optional parameter. If it is not specified, the builtin traindata is used.\n");
33+
"\t\tNote: This can be set to \"internal\" without quotes, to use the internal train sourcecode that is bundled in this jar.\n");
3534
System.err
3635
.println("<train-json>: Path to the train data file (JSON), which includes method signatures.");
3736
System.err.println(
38-
"\t\tThis is an optional parameter. If it is not specified, the builtin json file is used.\n");
37+
"\t\tNote: This can be set to \"internal\" (without quotes), to use the internal train data file that is bundled in this jar.\n");
3938
System.err.println("<output-dir>:\tDirectory where the output should be written.\n");
4039
return;
4140
}
4241

4342
// Get configuration options from command line arguments.
4443
String sourceDir = args[0];
45-
String trainSourceCode = null;
46-
String trainJson = null;
47-
String outputDir = args[args.length - 1];
48-
49-
// Train Sourcecode (extract from JAR, if not specified)
50-
if (args.length >= 3) {
51-
trainSourceCode = args[1];
52-
}
53-
54-
// Train JSON (extract from JAR, if not specified)
55-
if (args.length == 4) {
56-
trainJson = args[2];
57-
}
58-
44+
String trainSourceCode = args[1].equals("internal") ? null : args[1];
45+
String trainJson = args[2].equals("internal") ? null : args[2];
46+
String outputDir = args[3];
47+
5948
Main main = new Main();
6049
main.run(sourceDir, trainSourceCode, trainJson, outputDir);
6150
// System.out.println("Done.");

0 commit comments

Comments
 (0)