Skip to content

Commit 024f25b

Browse files
author
Dave Wichers
committed
Add warning when a SARIF parser doesn't have a CWE mapping for a tool
specific rule. Add a few such missing rules to ZAP and ContrastScan readers. Fix bug in JuliaReader where it was reporting findings for test case number -1 (which isn't a real test case).
1 parent e81bc42 commit 024f25b

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ public TestSuiteResults parse(ResultFile resultFile) throws Exception {
6868
NodeList nl = root.getChildNodes();
6969
for (int i = 0; i < nl.getLength(); i++) {
7070
Node n = nl.item(i);
71-
if (n.getNodeName().equals("warning")) tr.put(parseJuliaBug(n));
71+
if (n.getNodeName().equals("warning")) {
72+
TestCaseResult tcr = parseJuliaBug(n);
73+
if (tcr.getNumber() > 0) tr.put(tcr);
74+
}
7275
}
7376

7477
return tr;

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,21 @@ static int mapCwe(String cwe) {
184184
case "-1": // Informational Alert
185185
case "0": // Informational Alert: Check for differences in response based on fuzzed User
186186
// Agent
187+
return CweNumber.DONTCARE;
188+
187189
case "16": // Configuration
188190
case "20": // Improper Input Validation
189191
case "91": // XML Injection (aka Blind XPath Injection)
190192
case "120": // Classic Buffer Overflow (Not possible in Java)
191193
case "134": // Use of Externally-Controlled Format String
194+
case "190": // Integer Overflow or Wraparound
192195
case "200": // Exposure of Sensitive Information to Unauthorized Actor - When 500 errors
193196
// are returned
194197
case "345": // Insufficient Verification of Data Authenticity
195198
case "359": // Exposure of Private Personal Information to an Unauthorized Actor
196199
case "436": // Interpretation Conflict
197200
case "525": // Browser caching sensitive data
201+
case "541": // Sensitive Info found in an Include File
198202
case "565": // Reliance on Cookies without Validation and Integrity Checking
199203
case "693": // Protection Mechanism Failure
200204
case "829": // Inclusion of Functionality from Untrusted Control Sphere (e.g., CDN)
@@ -204,8 +208,7 @@ static int mapCwe(String cwe) {
204208
return Integer.parseInt(cwe); // Return the CWE anyway.
205209

206210
default:
207-
System.out.println(
208-
"WARNING: ZAP CWE not mapped to expected test suite CWE: " + cwe);
211+
System.out.println("WARNING: No CWE mapping found for CWE: " + cwe);
209212
return Integer.parseInt(cwe);
210213
}
211214
}

plugin/src/main/java/org/owasp/benchmarkutils/score/parsers/sarif/ContrastScanReader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public Map<String, Integer> customRuleCweMappings(JSONObject driver) {
5050
ruleCweMap.put("trust-boundary-violation", CweNumber.TRUST_BOUNDARY_VIOLATION);
5151
ruleCweMap.put("xpath-injection", CweNumber.XPATH_INJECTION);
5252
ruleCweMap.put("xxe", CweNumber.XXE);
53+
ruleCweMap.put("autocomplete-missing", 522); // CWE-522 Insufficiently Protected Creds
5354

5455
return ruleCweMap;
5556
}

plugin/src/main/java/org/owasp/benchmarkutils/score/parsers/sarif/SarifReader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ private TestCaseResult testCaseResultFor(JSONObject result, Map<String, Integer>
247247
int cwe = mappings.getOrDefault(ruleId, -1);
248248

249249
if (cwe == -1) {
250+
System.out.println("WARNING: No CWE mapping found for ruleID: " + ruleId);
250251
return null;
251252
}
252253

0 commit comments

Comments
 (0)