@@ -121,8 +121,12 @@ private TestCaseResult parseCheckmarxVulnerability(Node query, Node result) {
121121 return null ;
122122 }
123123
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+ }
126130
127131 tcr .setEvidence ( getAttributeValue ( "name" , query ) );
128132
@@ -144,9 +148,14 @@ private TestCaseResult parseCheckmarxVulnerability(Node query, Node result) {
144148
145149 //If the result starts in a BenchmarkTest file
146150 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" ) ) {
150159 String testno = testcase .substring ( "BenchmarkTest" .length (), testcase .length () -5 );
151160 try {
152161 tcr .setNumber ( Integer .parseInt ( testno ) );
@@ -157,15 +166,21 @@ private TestCaseResult parseCheckmarxVulnerability(Node query, Node result) {
157166 }
158167 //If not, then the last PastNode must end in a FileName that startsWith BenchmarkTest file
159168 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+ }
169184 return tcr ;
170185 }
171186 }
0 commit comments