Skip to content

Commit 9cfa33f

Browse files
committed
Rename Category data members
1 parent cbb1008 commit 9cfa33f

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

swan-pipeline/src/main/java/de/fraunhofer/iem/swan/data/Category.java

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,33 @@
1010

1111
public enum Category {
1212

13-
SOURCE(Constants.SOURCE, false),
14-
SINK(Constants.SINK, false),
15-
SANITIZER(Constants.SANITIZER, false),
16-
AUTHENTICATION_TO_HIGH(Constants.AUTHENTICATION_SAFE, false),
17-
AUTHENTICATION_TO_LOW(Constants.AUTHENTICATION_UNSAFE, false),
18-
AUTHENTICATION_NEUTRAL(Constants.AUTHENTICATION_NOCHANGE, false),
19-
RELEVANT(Constants.RELEVANT, false),
20-
NONE(Constants.NONE, false),
21-
CWE078("CWE078", true),
22-
CWE079("CWE079", true),
23-
CWE089("CWE089", true),
24-
CWE306("CWE306", true),
25-
CWE601("CWE601", true),
26-
CWE862("CWE862", true),
27-
CWE863("CWE863", true),
28-
CWETEST("CWEtest", true),
29-
CWE_NONE("none", true);
13+
SOURCE(Constants.SOURCE, false, false),
14+
SINK(Constants.SINK, false, false),
15+
SANITIZER(Constants.SANITIZER, false, false),
16+
AUTHENTICATION_TO_HIGH(Constants.AUTHENTICATION_SAFE, false, true),
17+
AUTHENTICATION_TO_LOW(Constants.AUTHENTICATION_UNSAFE, false, true),
18+
AUTHENTICATION_NEUTRAL(Constants.AUTHENTICATION_NOCHANGE, false, true),
19+
AUTHENTICATION("authentication", false, true),
20+
RELEVANT(Constants.RELEVANT, false, false),
21+
NONE(Constants.NONE, false, false),
22+
CWE078("CWE078", true, false),
23+
CWE079("CWE079", true, false),
24+
CWE089("CWE089", true, false),
25+
CWE306("CWE306", true, false),
26+
CWE601("CWE601", true, false),
27+
CWE862("CWE862", true, false),
28+
CWE863("CWE863", true, false),
29+
CWETEST("CWEtest", true, false),
30+
CWE_NONE("cwe-none", true, false);
3031

3132
private final String id;
3233
private final boolean cwe;
34+
private final boolean authentication;
3335

34-
private Category(String id, boolean cwe) {
36+
private Category(String id, boolean cwe, boolean authentication) {
3537
this.id = id;
3638
this.cwe = cwe;
39+
this.authentication = authentication;
3740
}
3841

3942
public boolean isCwe() {
@@ -50,6 +53,14 @@ public String toString() {
5053
return id;
5154
}
5255

56+
public boolean isAuthentication() {
57+
return authentication;
58+
}
59+
60+
public boolean isNone() {
61+
return id.contains("none");
62+
}
63+
5364
public static Category getCategoryForCWE(String cweName) {
5465
for (Category c : Category.values())
5566
if (c.id.toLowerCase().equals(cweName.toLowerCase()))

swan-pipeline/src/main/java/de/fraunhofer/iem/swan/util/Util.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public Type appliesInternal(Method method) {
181181
// If we only have annotations for the parent method, but not for
182182
// the current one, we copy it down
183183
if (parentMethodData.isAnnotated() && !method.isAnnotated()) {
184-
method.setCategoriesTrained(parentMethodData.getCategoriesTrained());
184+
method.setSrm(parentMethodData.getSrm());
185185
copied = true;
186186
}
187187

@@ -247,7 +247,7 @@ public static Instances loadArffFile(String filePath) {
247247
return dataset;
248248
}
249249

250-
public static String getClassName(Instances instances){
250+
public static String getClassName(Instances instances) {
251251

252252
String categoryName = "";
253253

@@ -284,8 +284,8 @@ public static String exportInstancesToArff(Instances instances) {
284284
saver.setInstances(instances);
285285

286286
try {
287-
String arffFile = SwanPipeline.options.getOutputDir() + File.separator + "arff-data" + File.separator+ categoryName + "-methods-dataset.arff";
288-
saver.setFile(new File(arffFile ));
287+
String arffFile = SwanPipeline.options.getOutputDir() + File.separator + "arff-data" + File.separator + categoryName + "-methods-dataset.arff";
288+
saver.setFile(new File(arffFile));
289289
saver.writeBatch();
290290
} catch (IOException e) {
291291
e.printStackTrace();

0 commit comments

Comments
 (0)