Skip to content

Commit 86d96a1

Browse files
committed
Merge branch 'master' of https://github.com/piskachev/mois.git
Conflicts: src/de/fraunhofer/iem/mois/Main.java src/de/fraunhofer/iem/mois/Writer.java
2 parents d103586 + 033b419 commit 86d96a1

File tree

7 files changed

+47
-11
lines changed

7 files changed

+47
-11
lines changed
0 Bytes
Binary file not shown.
683 Bytes
Binary file not shown.
-25 Bytes
Binary file not shown.
525 Bytes
Binary file not shown.

src/de/fraunhofer/iem/mois/Parser.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.List;
99
import java.util.Set;
1010

11+
import de.fraunhofer.iem.mois.data.RelevantPart;
1112
import org.json.simple.JSONArray;
1213
import org.json.simple.JSONObject;
1314
import org.json.simple.parser.*;
@@ -143,6 +144,11 @@ private void parse(String fileName) {
143144
}
144145
}
145146

147+
public Set<Method> parseFile(String fileName){
148+
parse(fileName);
149+
return methods;
150+
}
151+
146152
@SuppressWarnings("unchecked")
147153
private void loadMethodsFromJsonArray(JSONArray array, String type) {
148154

@@ -217,10 +223,10 @@ private void loadMethodsFromJsonArray(JSONArray array, String type) {
217223
securityLevel = Method.SecLevel.NEUTRAL;
218224
else {
219225
switch (secLevel) {
220-
case "high":
226+
case Constants.AUTH_SAFE:
221227
securityLevel = Method.SecLevel.HIGH;
222228
break;
223-
case "low":
229+
case Constants.AUTH_UNSAFE:
224230
securityLevel = Method.SecLevel.LOW;
225231
break;
226232
default:
@@ -261,16 +267,16 @@ private void loadMethodsFromJsonArray(JSONArray array, String type) {
261267
while (p.hasNext()) {
262268
String t = p.next().toString();
263269
switch (t) {
264-
case "source":
270+
case Constants.SOURCE:
265271
m.addCategoryTrained(Category.SOURCE);
266272
break;
267-
case "sink":
273+
case Constants.SINK:
268274
m.addCategoryTrained(Category.SINK);
269275
break;
270-
case "sanitizer":
276+
case Constants.SANITIZER:
271277
m.addCategoryTrained(Category.SANITIZER);
272278
break;
273-
case "authentication":
279+
case Constants.AUTHENTICATION:
274280
switch (securityLevel) {
275281
case HIGH:
276282
m.addCategoryTrained(Category.AUTHENTICATION_TO_HIGH);
@@ -321,4 +327,18 @@ public Set<String> cwe() {
321327
return cwes;
322328
}
323329

330+
private RelevantPart extractDataInOutObject(JSONObject dataObject) {
331+
332+
JSONArray parameterArray = (JSONArray) dataObject.get(Constants.PARAMETERS);
333+
334+
List<Integer> parameters = new ArrayList<>();
335+
336+
for (Object param : parameterArray) {
337+
338+
if (param instanceof Integer)
339+
parameters.add((Integer) param);
340+
}
341+
return new RelevantPart((boolean) dataObject.get(Constants.RETURN_TYPE), parameters);
342+
}
343+
324344
}

src/de/fraunhofer/iem/mois/data/Category.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
*/
99

1010
public enum Category {
11-
SOURCE("sources", false), SINK("sinks", false), AUTHENTICATION_TO_HIGH(
12-
"authentications_to_high", false), AUTHENTICATION_TO_LOW(
13-
"authentications_to_low", false), AUTHENTICATION_NEUTRAL(
14-
"authentications_neutral", false), SANITIZER("sanitizers",
15-
false), NONE("none", false),
11+
SOURCE(Constants.SOURCE, false), SINK(Constants.SINK, false), AUTHENTICATION_TO_HIGH(
12+
Constants.AUTHENTICATION_SAFE, false), AUTHENTICATION_TO_LOW(
13+
Constants.AUTHENTICATION_UNSAFE, false), AUTHENTICATION_NEUTRAL(
14+
Constants.AUTHENTICATION_NOCHANGE, false), SANITIZER(Constants.SANITIZER,
15+
false), NONE(Constants.NONE, false),
1616

1717
CWE089("CWE089", true), CWE306("CWE306", true), CWE078("CWE078",
1818
true), CWE862("CWE862", true), CWE863("CWE863",

src/de/fraunhofer/iem/mois/data/Constants.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,20 @@ public final class Constants {
1919
public final static String TYPE = "type";
2020
public final static String COMMENT = "comment";
2121

22+
//Method Categories
23+
public final static String SOURCE = "source";
24+
public final static String SINK = "sink";
25+
public final static String SANITIZER = "sanitizer";
26+
public final static String AUTHENTICATION = "authentication";
27+
public final static String AUTHENTICATION_SAFE = "auth-safe-state";
28+
public final static String AUTHENTICATION_NOCHANGE = "auth-no-change";
29+
public final static String AUTHENTICATION_UNSAFE = "auth-unsafe-state";
30+
public final static String NONE = "none";
31+
public final static String TEST = "test";
32+
33+
//Authentication states
34+
public final static String AUTH_SAFE = "high";
35+
public final static String AUTH_NOCHANGE = "none";
36+
public final static String AUTH_UNSAFE = "low";
37+
2238
}

0 commit comments

Comments
 (0)