Skip to content
Open
Show file tree
Hide file tree
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
13 changes: 10 additions & 3 deletions dojo/tools/checkmarx_cxflow_sast/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,17 @@
return "Detailed Report. Import all vulnerabilities from checkmarx without aggregation"

def get_findings(self, file, test):
if file.name.strip().lower().endswith(".json"):
file_name = file.name.strip().lower()
if file_name.endswith(".json"):
return self._get_findings_json(file, test)
# TODO: support CxXML format
logger.warning("Not supported file format $%s", file)
if file_name.endswith(".xml"):
from dojo.tools.checkmarx.parser import CheckmarxParser

Check failure on line 59 in dojo/tools/checkmarx_cxflow_sast/parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

ruff (PLC0415)

dojo/tools/checkmarx_cxflow_sast/parser.py:59:13: PLC0415 `import` should be at the top-level of a file

parser = CheckmarxParser()
parser.set_mode("detailed")
return parser.get_findings(file, test)

logger.warning("Not supported file format %s", file)
return []

def _get_findings_json(self, file, test):
Expand Down
14 changes: 14 additions & 0 deletions unittests/tools/test_checkmarx_cxflow_sast_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ def test_file_name_aggregated_parse_file_with_no_vulnerabilities_has_no_findings
my_file_handle.close()
self.assertEqual(0, len(findings))

def test_xml_parse_file_with_single_vulnerability_has_single_finding(self):
my_file_handle, _, _, test = self.init(
get_unit_tests_scans_path("checkmarx") / "single_finding.xml",
)
parser = CheckmarxCXFlowSastParser()
findings = parser.get_findings(my_file_handle, test)
self.assertEqual(1, len(findings))
finding = findings[0]
self.assertIn("Reflected XSS All Clients", finding.title)
self.assertEqual("High", finding.severity)
self.assertEqual(True, finding.active)
self.assertEqual(False, finding.verified)
my_file_handle.close()

def test_file_name_aggregated_parse_file_with_no_vulnerabilities_has_1_finding(self):
my_file_handle, _, _, test = self.init(
get_unit_tests_scans_path("checkmarx_cxflow_sast") / "1-finding.json",
Expand Down
Loading