From 7cfea6d165a8c049e022910e662e4202fa1ce549 Mon Sep 17 00:00:00 2001 From: cx-rafaelc Date: Fri, 3 May 2024 20:49:53 +0100 Subject: [PATCH] Checkmarx results parser - Normalize paths (#71) * feat: Normalize FileName path to linux * style: Fix formatting --- .../score/parsers/CheckmarxESReader.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugin/src/main/java/org/owasp/benchmarkutils/score/parsers/CheckmarxESReader.java b/plugin/src/main/java/org/owasp/benchmarkutils/score/parsers/CheckmarxESReader.java index c715c67d..d9c633d6 100644 --- a/plugin/src/main/java/org/owasp/benchmarkutils/score/parsers/CheckmarxESReader.java +++ b/plugin/src/main/java/org/owasp/benchmarkutils/score/parsers/CheckmarxESReader.java @@ -141,14 +141,17 @@ private TestCaseResult parseCheckmarxFindings( // get the testcase number // Try get testcase from the first node JSONArray nodes = result.getJSONArray("Nodes"); - String resultFileName = nodes.getJSONObject(0).getString("FileName"); - String testcaseName = resultFileName.substring(resultFileName.lastIndexOf('\\') + 1); + String resultFileName = nodes.getJSONObject(0).getString("FileName").replace("\\", "/"); + String testcaseName = resultFileName.substring(resultFileName.lastIndexOf('/') + 1); if (testcaseName.startsWith(BenchmarkScore.TESTCASENAME)) { tcr.setNumber(testNumber(testcaseName)); return tcr; } else { - resultFileName = nodes.getJSONObject(nodes.length() - 1).getString("FileName"); - testcaseName = resultFileName.substring(resultFileName.lastIndexOf('\\') + 1); + resultFileName = + nodes.getJSONObject(nodes.length() - 1) + .getString("FileName") + .replace("\\", "/"); + testcaseName = resultFileName.substring(resultFileName.lastIndexOf('/') + 1); if (testcaseName.startsWith(BenchmarkScore.TESTCASENAME)) { tcr.setNumber(testNumber(testcaseName)); return tcr;