Skip to content

Commit c2962c4

Browse files
committed
Update CheckmarxReader.java
1 parent d0e25a2 commit c2962c4

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

src/main/java/org/owasp/benchmark/score/parsers/CheckmarxReader.java

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ private TestCaseResult parseCheckmarxVulnerability(Node query, Node result) {
121121
return null;
122122
}
123123

124-
//Output xml file from Checkmarx (depends on version) sometimes does not
125-
//contain attribute on the node "query" named SeverityIndex
124+
//Output xml file from Checkmarx (depends on version) sometimes does not contain attribute on the node "query" named SeverityIndex
126125
String SeverityIndex = getAttributeValue( "SeverityIndex", result);
127-
if(SeverityIndex != null && !SeverityIndex.equals("")) {
126+
boolean isGeneratedByCxWebClient = SeverityIndex != null && !SeverityIndex.equals("");
127+
if(isGeneratedByCxWebClient) {
128128
tcr.setConfidence( Integer.parseInt( getAttributeValue( "SeverityIndex", result) ) );
129129
}
130130

@@ -148,9 +148,14 @@ private TestCaseResult parseCheckmarxVulnerability(Node query, Node result) {
148148

149149
//If the result starts in a BenchmarkTest file
150150
String testcase = getAttributeValue("FileName", result);
151-
//A change was made in the following line due to the paths in the xml outputs file, they are windows based '\\'
152-
testcase = testcase.substring( testcase.lastIndexOf('\\') +1);
153-
if ( testcase.startsWith( "BenchmarkTest" ) ) {
151+
//Output xml file from Checkmarx (depends on version) may use windows based '\\' or unix based '/' delimiters for path
152+
if(isGeneratedByCxWebClient) {
153+
testcase = testcase.substring( testcase.lastIndexOf('/') +1);
154+
}
155+
else{
156+
testcase = testcase.substring( testcase.lastIndexOf('\\') +1);
157+
}
158+
if ( testcase.startsWith( "BenchmarkTest" ) ) {
154159
String testno = testcase.substring( "BenchmarkTest".length(), testcase.length() -5 );
155160
try {
156161
tcr.setNumber( Integer.parseInt( testno ) );
@@ -161,15 +166,21 @@ private TestCaseResult parseCheckmarxVulnerability(Node query, Node result) {
161166
}
162167
//If not, then the last PastNode must end in a FileName that startsWith BenchmarkTest file
163168
else{
164-
String testcase2 = fileNameNode.getFirstChild().getNodeValue();
165-
testcase2 = testcase2.substring( testcase2.lastIndexOf('\\') +1);
166-
if ( testcase2.startsWith( "BenchmarkTest" ) ) {
167-
String testno2 = testcase2.substring( "BenchmarkTest".length(), testcase2.length() -5 );
168-
try {
169-
tcr.setNumber( Integer.parseInt( testno2 ) );
170-
} catch ( NumberFormatException e ) {
171-
e.printStackTrace();
172-
}
169+
String testcase2 = fileNameNode.getFirstChild().getNodeValue();
170+
//Output xml file from Checkmarx (depends on version) may use windows based '\\' or unix based '/' delimiters for path
171+
if(isGeneratedByCxWebClient) {
172+
testcase2 = testcase2.substring( testcase2.lastIndexOf('/') +1);
173+
}
174+
else{
175+
testcase2 = testcase2.substring( testcase2.lastIndexOf('\\') +1);
176+
}
177+
if ( testcase2.startsWith( "BenchmarkTest" ) ) {
178+
String testno2 = testcase2.substring( "BenchmarkTest".length(), testcase2.length() -5 );
179+
try {
180+
tcr.setNumber( Integer.parseInt( testno2 ) );
181+
} catch ( NumberFormatException e ) {
182+
e.printStackTrace();
183+
}
173184
return tcr;
174185
}
175186
}

0 commit comments

Comments
 (0)