in dusty/reporters/junit/reporter.py [0:0]
def report(self):
""" Report """
file = self.config.get("file", constants.DEFAULT_REPORT_FILE)
if self.config.get("format_file_name", True):
file = file.format(**self.context.meta)
log.info("Creating XML report %s", file)
# Prepare test cases
test_name = \
f"{self.context.get_meta('project_name', 'UnnamedProject')}-" \
f"{self.context.get_meta('environment_name', 'unknown')}-" \
f"{self.context.get_meta('testing_type', 'AST')}"
test_cases = list()
# Summary
summary_case = TestCase(
f"Security tests has been COMPLETED",
classname="Carrier Dusty",
stdout=\
f"Total findings (with false positives and info): {len(self.context.findings)}. " \
f"Total scan errors: {len(self.context.errors)}."
)
test_cases.append(summary_case)
# Findings
for item in self.context.findings:
if item.get_meta("information_finding", False) or \
item.get_meta("false_positive_finding", False) or \
item.get_meta("excluded_finding", False):
continue
if isinstance(item, DastFinding):
test_case = TestCase(item.title, classname=item.get_meta("tool", ""))
test_case.add_error_info(
message=markdown.markdown_to_text(item.description) if \
self.config.get("plain_text", False) else \
markdown.markdown_unescape(item.description),
error_type=item.get_meta("severity", SEVERITIES[-1])
)
test_cases.append(test_case)
if isinstance(item, SastFinding):
test_case = TestCase(item.title, classname=item.get_meta("tool", ""))
test_case.add_error_info(
message=markdown.markdown_to_text("\n\n".join(item.description)) if \
self.config.get("plain_text", False) else \
markdown.markdown_unescape("\n\n".join(item.description)),
error_type=item.get_meta("severity", SEVERITIES[-1])
)
test_cases.append(test_case)
# Save to file
with open(file, "w") as report:
TestSuite.to_file(report, [TestSuite(test_name, test_cases)], prettyprint=False)
self.set_meta("report_file", file)