Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public TestResults parse(final File f) throws Exception {
private final StringBuilder m_CollectedCharacters = new StringBuilder();

private String m_ProblemTypeId;
private int m_CWE = -1;
private String m_Class;
private String m_Classification;

Expand All @@ -59,8 +60,12 @@ public void startElement(final String uri, final String localName, final String
switch (qName) {
case "XanitizerFindingsList":

String version = attributes.getValue("xanitizerVersion");
version = version.replace('/', '-');
String version = attributes.getValue("xanitizerVersionShort");
// for backward compatibility - use full version
if (version == null) {
version = attributes.getValue("xanitizerVersion");
version = version.replace('/', '-');
}
tr.setToolVersion(version);

break;
Expand All @@ -85,6 +90,15 @@ public void endElement(final String uri, final String localName, final String qN
m_Classification = m_CollectedCharacters.toString();
break;

case "cweNumber":
// remove leading "CWE-" and thousands delimiter
try {
m_CWE = Integer.parseInt(m_CollectedCharacters.toString().substring(4).replace(".", "").replace(",", ""));
} catch (NumberFormatException e) {
m_CWE = -1;
}
break;

case "finding":
// Finishing a finding.

Expand All @@ -108,12 +122,18 @@ public void endElement(final String uri, final String localName, final String qN
testCaseNumber = -1;
}

// for backward compatibility
// for reports without CWE numbers - map problem type to CWE number
if (m_CWE < 0) {
m_CWE = figureCWE(m_ProblemTypeId);
}

if (testCaseNumber >= 0) {
final TestCaseResult tcr = new TestCaseResult();

tcr.setNumber(testCaseNumber);
tcr.setCategory(m_ProblemTypeId);
tcr.setCWE(figureCWE(m_ProblemTypeId));
tcr.setCWE(m_CWE);

tr.put(tcr);
}
Expand All @@ -122,6 +142,7 @@ public void endElement(final String uri, final String localName, final String qN
}

m_ProblemTypeId = null;
m_CWE = -1;
m_Class = null;
m_Classification = null;
break;
Expand Down