@@ -121,8 +121,12 @@ private TestCaseResult parseCheckmarxVulnerability(Node query, Node result) {
121
121
return null ;
122
122
}
123
123
124
- //In the output xml file from Checkmarx there is no attribute on the node "query" named SeverityIndex
125
- //tcr.setConfidence( Integer.parseInt( getAttributeValue( "SeverityIndex", result) ) );
124
+ //Output xml file from Checkmarx (depends on version) sometimes does not contain attribute on the node "query" named SeverityIndex
125
+ String SeverityIndex = getAttributeValue ( "SeverityIndex" , result );
126
+ boolean isGeneratedByCxWebClient = SeverityIndex != null && !SeverityIndex .equals ("" );
127
+ if (isGeneratedByCxWebClient ) {
128
+ tcr .setConfidence ( Integer .parseInt ( getAttributeValue ( "SeverityIndex" , result ) ) );
129
+ }
126
130
127
131
tcr .setEvidence ( getAttributeValue ( "name" , query ) );
128
132
@@ -144,9 +148,14 @@ private TestCaseResult parseCheckmarxVulnerability(Node query, Node result) {
144
148
145
149
//If the result starts in a BenchmarkTest file
146
150
String testcase = getAttributeValue ("FileName" , result );
147
- //A change was made in the following line due to the paths in the xml outputs file, they are windows based '\\'
148
- testcase = testcase .substring ( testcase .lastIndexOf ('\\' ) +1 );
149
- 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" ) ) {
150
159
String testno = testcase .substring ( "BenchmarkTest" .length (), testcase .length () -5 );
151
160
try {
152
161
tcr .setNumber ( Integer .parseInt ( testno ) );
@@ -157,15 +166,21 @@ private TestCaseResult parseCheckmarxVulnerability(Node query, Node result) {
157
166
}
158
167
//If not, then the last PastNode must end in a FileName that startsWith BenchmarkTest file
159
168
else {
160
- String testcase2 = fileNameNode .getFirstChild ().getNodeValue ();
161
- testcase2 = testcase2 .substring ( testcase2 .lastIndexOf ('\\' ) +1 );
162
- if ( testcase2 .startsWith ( "BenchmarkTest" ) ) {
163
- String testno2 = testcase2 .substring ( "BenchmarkTest" .length (), testcase2 .length () -5 );
164
- try {
165
- tcr .setNumber ( Integer .parseInt ( testno2 ) );
166
- } catch ( NumberFormatException e ) {
167
- e .printStackTrace ();
168
- }
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
+ }
169
184
return tcr ;
170
185
}
171
186
}
0 commit comments