Skip to content

Commit c096f64

Browse files
author
Dave Wichers
committed
Merge branch 'main' into generalizeScoring
2 parents 22f45fd + f6dcf0b commit c096f64

18 files changed

+271
-90
lines changed

plugin/src/main/java/org/owasp/benchmarkutils/score/CweNumber.java

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -19,179 +19,179 @@
1919

2020
public class CweNumber {
2121

22-
/** 0000: To be used when the CWE reported is one we don't care about in any test suite */
23-
public static int DONTCARE = 0000;
22+
/** Used occasionally to indicate a CWE isn't mapped yet, but might get mapped properly later */
23+
public static final int UNMAPPED = -1;
2424

25-
/** -1: To be used when the CWE reported is unknown */
26-
public static int UNKNOWN = -1;
25+
/** To be used when the CWE reported is one we don't care about in any test suite */
26+
public static final int DONTCARE = 0000;
2727

2828
/** CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') */
29-
public static int PATH_TRAVERSAL = 22;
29+
public static final int PATH_TRAVERSAL = 22;
3030

3131
/** CWE-23: Relative Path Traversal */
32-
public static int RELATIVE_PATH_TRAVERSAL = 23;
32+
public static final int RELATIVE_PATH_TRAVERSAL = 23;
3333

3434
/**
3535
* CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command
3636
* Injection')
3737
*/
38-
public static int COMMAND_INJECTION = 78;
38+
public static final int COMMAND_INJECTION = 78;
3939

4040
/**
4141
* CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
4242
*/
43-
public static int XSS = 79;
43+
public static final int XSS = 79;
4444

4545
/**
4646
* CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
4747
*/
48-
public static int SQL_INJECTION = 89;
48+
public static final int SQL_INJECTION = 89;
4949

5050
/**
5151
* CWE-90: Improper Neutralization of Special Elements used in an LDAP Query ('LDAP Injection')
5252
*/
53-
public static int LDAP_INJECTION = 90;
53+
public static final int LDAP_INJECTION = 90;
5454

5555
/** CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') */
56-
public static int CRLF_INJECTION = 93;
56+
public static final int CRLF_INJECTION = 93;
5757

5858
/**
5959
* CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response
6060
* Splitting')
6161
*/
62-
public static int HTTP_RESPONSE_SPLITTING = 113;
62+
public static final int HTTP_RESPONSE_SPLITTING = 113;
6363

6464
/** CWE-134: Use of Externally-Controlled Format String */
65-
public static int EXTERNALLY_CONTROLLED_STRING = 134;
65+
public static final int EXTERNALLY_CONTROLLED_STRING = 134;
6666

6767
/** CWE-284: Improper Access Control */
68-
public static int IMPROPER_ACCESS_CONTROL = 284;
68+
public static final int IMPROPER_ACCESS_CONTROL = 284;
6969

7070
/** CWE-327: Use of a Broken or Risky Cryptographic Algorithm */
71-
public static int WEAK_CRYPTO_ALGO = 327;
71+
public static final int WEAK_CRYPTO_ALGO = 327;
7272

7373
/** CWE-328: Use of Weak Hash */
74-
public static int WEAK_HASH_ALGO = 328;
74+
public static final int WEAK_HASH_ALGO = 328;
7575

7676
/** CWE-329: Generation of Predictable IV with CBC Mode */
77-
public static int STATIC_CRYPTO_INIT = 329;
77+
public static final int STATIC_CRYPTO_INIT = 329;
7878

7979
/** CWE-330: Use of Insufficiently Random Values */
80-
public static int WEAK_RANDOM = 330;
80+
public static final int WEAK_RANDOM = 330;
8181

8282
/** CWE-352: Cross-Site Request Forgery (CSRF) */
83-
public static int CSRF = 352;
83+
public static final int CSRF = 352;
8484

8585
/** CWE-382: J2EE Bad Practices: Use of System.exit() */
86-
public static int SYSTEM_EXIT = 382;
86+
public static final int SYSTEM_EXIT = 382;
8787

8888
/** CWE-395: Use of NullPointerException Catch to Detect NULL Pointer Dereference */
89-
public static int CATCHING_NULL_POINTER_EXCEPTION = 395;
89+
public static final int CATCHING_NULL_POINTER_EXCEPTION = 395;
9090

9191
/** CWE-396: Declaration of Catch for Generic Exception */
92-
public static int CATCH_GENERIC_EXCEPTION = 396;
92+
public static final int CATCH_GENERIC_EXCEPTION = 396;
9393

9494
/** CWE-397: Declaration of Throws for Generic Exception */
95-
public static int THROW_GENERIC_EXCEPTION = 397;
95+
public static final int THROW_GENERIC_EXCEPTION = 397;
9696

9797
/** CWE-478: Missing Default Case in Switch Statement */
98-
public static int MISSING_DEFAULT_CASE = 478;
98+
public static final int MISSING_DEFAULT_CASE = 478;
9999

100100
/** CWE-483: Incorrect Block Delimitation */
101-
public static int INCORRECT_BLOCK_DELIMITATION = 483;
101+
public static final int INCORRECT_BLOCK_DELIMITATION = 483;
102102

103103
/** CWE-484: Omitted Break Statement in Switch */
104-
public static int OMITTED_BREAK = 484;
104+
public static final int OMITTED_BREAK = 484;
105105

106106
/** CWE-493: Critical Public Variable Without Final Modifier */
107-
public static int PUBLIC_VAR_WITHOUT_FINAL = 493;
107+
public static final int PUBLIC_VAR_WITHOUT_FINAL = 493;
108108

109109
/** CWE-500: Public Static Field Not Marked Final */
110-
public static int PUBLIC_STATIC_NOT_FINAL = 500;
110+
public static final int PUBLIC_STATIC_NOT_FINAL = 500;
111111

112112
/** CWE-501: Trust Boundary Violation */
113-
public static int TRUST_BOUNDARY_VIOLATION = 501;
113+
public static final int TRUST_BOUNDARY_VIOLATION = 501;
114114

115115
/** CWE-502: Deserialization of Untrusted Data */
116-
public static int INSECURE_DESERIALIZATION = 502;
116+
public static final int INSECURE_DESERIALIZATION = 502;
117117

118118
/** CWE-523: Unprotected Transport of Credentials */
119-
public static int UNPROTECTED_CREDENTIALS_TRANSPORT = 523;
119+
public static final int UNPROTECTED_CREDENTIALS_TRANSPORT = 523;
120120

121121
/** CWE-532: Insertion of Sensitive Information into Log File */
122-
public static int SENSITIVE_LOGFILE = 532;
122+
public static final int SENSITIVE_LOGFILE = 532;
123123

124124
/** CWE-564: SQL Injection: Hibernate */
125-
public static int HIBERNATE_INJECTION = 564;
125+
public static final int HIBERNATE_INJECTION = 564;
126126

127127
/** CWE-572: Call to Thread run() instead of start() */
128-
public static int THREAD_WRONG_CALL = 572;
128+
public static final int THREAD_WRONG_CALL = 572;
129129

130130
/** CWE-580: clone() Method Without super.clone() */
131-
public static int CLONE_WITHOUT_SUPER_CLONE = 580;
131+
public static final int CLONE_WITHOUT_SUPER_CLONE = 580;
132132

133133
/** CWE-563: Assignment to Variable without Use */
134-
public static int UNUSED_VAR_ASSIGNMENT = 563;
134+
public static final int UNUSED_VAR_ASSIGNMENT = 563;
135135

136136
/** CWE-581: Object Model Violation: Just One of Equals and Hashcode Defined */
137-
public static int OBJECT_MODEL_VIOLATION = 581;
137+
public static final int OBJECT_MODEL_VIOLATION = 581;
138138

139139
/** CWE-583: finalize() Method Declared Public */
140-
public static int FINALIZE_DECLARED_PUBLIC = 583;
140+
public static final int FINALIZE_DECLARED_PUBLIC = 583;
141141

142142
/** CWE-584: Return Inside Finally Block */
143-
public static int RETURN_INSIDE_FINALLY = 584;
143+
public static final int RETURN_INSIDE_FINALLY = 584;
144144

145145
/** CWE-595: Comparison of Object References Instead of Object Contents */
146-
public static int OBJECT_REFERENCE_COMPARISON = 595;
146+
public static final int OBJECT_REFERENCE_COMPARISON = 595;
147147

148148
/** CWE-601: URL Redirection to Untrusted Site ('Open Redirect') */
149-
public static int OPEN_REDIRECT = 601;
149+
public static final int OPEN_REDIRECT = 601;
150150

151151
/** CWE-611: Improper Restriction of XML External Entity Reference */
152-
public static int XXE = 611;
152+
public static final int XXE = 611;
153153

154154
/** CWE-614: Sensitive Cookie in HTTPS Session Without 'Secure' Attribute */
155-
public static int INSECURE_COOKIE = 614;
155+
public static final int INSECURE_COOKIE = 614;
156156

157157
/** CWE-643: Improper Neutralization of Data within XPath Expressions ('XPath Injection') */
158-
public static int XPATH_INJECTION = 643;
158+
public static final int XPATH_INJECTION = 643;
159159

160160
/**
161161
* CWE-649: Reliance on Obfuscation or Encryption of Security-Relevant Inputs without Integrity
162162
* Checking
163163
*/
164-
public static int OBFUSCATION = 649;
164+
public static final int OBFUSCATION = 649;
165165

166166
/** CWE-652: Improper Neutralization of Data within XQuery Expressions ('XQuery Injection') */
167167
public static int XQUERY_INJECTION = 652;
168168

169169
/** CWE-754: Improper Check for Unusual or Exceptional Conditions */
170-
public static int IMPROPER_CHECK_FOR_CONDITIONS = 754;
170+
public static final int IMPROPER_CHECK_FOR_CONDITIONS = 754;
171171

172172
/**
173173
* CWE-776: Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion')
174174
*/
175175
public static int XEE = 776;
176176

177177
/** CWE-783: Operator Precedence Logic Error */
178-
public static int OPERATOR_PRECEDENCE_LOGIC = 783;
178+
public static final int OPERATOR_PRECEDENCE_LOGIC = 783;
179179

180180
/** CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop') */
181-
public static int LOOP_WITH_UNREACHABLE_EXIT = 835;
181+
public static final int LOOP_WITH_UNREACHABLE_EXIT = 835;
182182

183183
/** CWE-916: Use of Password Hash With Insufficient Computational Effort */
184-
public static int PASSWORD_HASH_WITH_INSUFFICIENT_COMPUTATIONAL_EFFORT = 916;
184+
public static final int PASSWORD_HASH_WITH_INSUFFICIENT_COMPUTATIONAL_EFFORT = 916;
185185

186186
/** CWE-918: Server-Side Request Forgery (SSRF) */
187-
public static int SSRF = 918;
187+
public static final int SSRF = 918;
188188

189189
/** CWE-1004: Sensitive Cookie Without 'HttpOnly' Flag */
190-
public static int COOKIE_WITHOUT_HTTPONLY = 1004;
190+
public static final int COOKIE_WITHOUT_HTTPONLY = 1004;
191191

192192
/** CWE-1021: Improper Restriction of Rendered UI Layers or Frames */
193-
public static int IMPROPER_UI_LAYER_RESTRICTION = 1021;
193+
public static final int IMPROPER_UI_LAYER_RESTRICTION = 1021;
194194

195195
/** CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine */
196-
public static int SSTI = 1336;
196+
public static final int SSTI = 1336;
197197
}

plugin/src/main/java/org/owasp/benchmarkutils/score/parsers/AcunetixReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,15 @@ private TestCaseResult parseAcunetixReportItem(Node flaw) throws Exception {
211211
private int cweLookup(String cweNum) {
212212
if (cweNum == null || cweNum.isEmpty()) {
213213
System.err.println("ERROR: No CWE number supplied");
214-
return CweNumber.UNKNOWN;
214+
return CweNumber.UNMAPPED;
215215
}
216216
return cweLookup(cweNum, null);
217217
}
218218

219219
private int cweLookup(String cweNum, String name) {
220220
if (cweNum == null || cweNum.isEmpty()) {
221221
System.err.println("ERROR: No CWE number supplied");
222-
return CweNumber.UNKNOWN;
222+
return CweNumber.UNMAPPED;
223223
}
224224
switch (cweNum) {
225225
case "22":

plugin/src/main/java/org/owasp/benchmarkutils/score/parsers/AppScanSourceReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public TestSuiteResults parse(ResultFile resultFile) throws Exception {
109109

110110
int cwe = cweLookup(vtype);
111111
// Exclude unmapped findings
112-
if (cwe == CweNumber.DONTCARE || cwe == CweNumber.UNKNOWN) continue;
112+
if (cwe == CweNumber.DONTCARE || cwe == CweNumber.UNMAPPED) continue;
113113
tcr.setCWE(cwe);
114114
tcr.setEvidence(vtype);
115115
tcr.setConfidence(confidence);
@@ -180,7 +180,7 @@ private int cweLookup(String vtype) {
180180
default:
181181
System.out.println("Unknown vuln type for AppScanSource: " + vtype);
182182
}
183-
return CweNumber.UNKNOWN;
183+
return CweNumber.UNMAPPED;
184184
}
185185

186186
/**

plugin/src/main/java/org/owasp/benchmarkutils/score/parsers/BurpReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,6 @@ static int cweLookup(String id) {
163163
return CweNumber.DONTCARE; // TLS Certificate Problem
164164
} // end switch(id)
165165
System.out.println("Unknown Burp rule id: " + id);
166-
return CweNumber.UNKNOWN;
166+
return CweNumber.UNMAPPED;
167167
}
168168
}

plugin/src/main/java/org/owasp/benchmarkutils/score/parsers/CASTAIPReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private TestCaseResult parseCASTAIPIssue(Node flaw) throws Exception {
9797

9898
private int cweLookup(String name) {
9999
if (name == null || name.isEmpty()) {
100-
return CweNumber.UNKNOWN;
100+
return CweNumber.UNMAPPED;
101101
}
102102
switch (name.trim()) {
103103
case "614":

plugin/src/main/java/org/owasp/benchmarkutils/score/parsers/FindbugsReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,6 @@ private int figureCWE(
406406
+ classname);
407407
}
408408

409-
return CweNumber.UNKNOWN;
409+
return CweNumber.UNMAPPED;
410410
}
411411
}

0 commit comments

Comments
 (0)