From b7adf096df4838b6bb340bfa8fb5ddbf3581946e Mon Sep 17 00:00:00 2001 From: testaccount90009 <122134756+testaccount90009@users.noreply.github.com> Date: Sat, 21 Dec 2024 11:26:17 -0800 Subject: [PATCH] fix duplicate conditional - add into tree_node logic --- dojo/tools/mend/parser.py | 94 +++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/dojo/tools/mend/parser.py b/dojo/tools/mend/parser.py index d39710e3cf..ec7c7cdb9d 100644 --- a/dojo/tools/mend/parser.py +++ b/dojo/tools/mend/parser.py @@ -41,52 +41,51 @@ def _build_common_output(node, lib_name=None): mitigation = "N/A" locations = [] if "component" in node: - if node.get("findingInfo", {}).get("status") == "ACTIVE": - description = ( - "**Vulnerability Description**: " - + node["vulnerability"].get("description", "No Description Available") - + "\n\n" - + "**Component Name**: " - + node["component"].get("name", "") - + "\n" - + "**Component Type**: " - + node["component"].get("componentType", "") - + "\n" - + "**Root Library**: " - + str(node["component"].get("rootLibrary", "")) - + "\n" - + "**Library Type**: " - + node["component"].get("libraryType", "") - + "\n" - ) - lib_name = node["component"].get("name") - component_name = node["component"].get("artifactId") - component_version = node["component"].get("version") - impact = ( - "**Direct or Transitive Vulnerability**: " - + node["component"].get("dependencyType", "") - + "\n" - ) - cvss3_score = node["vulnerability"].get("score", None) - component_path = node["component"].get("path", None) - cve = node["vulnerability"].get("name") - title = "CVE-None | " + lib_name if cve is None else cve + " | " + lib_name - if component_path: - locations.append(component_path) - if "topFix" in node: - try: - topfix_node = node.get("topFix") - mitigation = ( - "**Resolution**: " - + topfix_node.get("date", "") - + "\n" - + topfix_node.get("message", "") - + "\n" - + topfix_node.get("fixResolution", "") - + "\n" - ) - except Exception: - logger.exception("Error handling topFix node.") + description = ( + "**Vulnerability Description**: " + + node["vulnerability"].get("description", "No Description Available") + + "\n\n" + + "**Component Name**: " + + node["component"].get("name", "") + + "\n" + + "**Component Type**: " + + node["component"].get("componentType", "") + + "\n" + + "**Root Library**: " + + str(node["component"].get("rootLibrary", "")) + + "\n" + + "**Library Type**: " + + node["component"].get("libraryType", "") + + "\n" + ) + lib_name = node["component"].get("name") + component_name = node["component"].get("artifactId") + component_version = node["component"].get("version") + impact = ( + "**Direct or Transitive Vulnerability**: " + + node["component"].get("dependencyType", "") + + "\n" + ) + cvss3_score = node["vulnerability"].get("score", None) + component_path = node["component"].get("path", None) + cve = node["vulnerability"].get("name") + title = "CVE-None | " + lib_name if cve is None else cve + " | " + lib_name + if component_path: + locations.append(component_path) + if "topFix" in node: + try: + topfix_node = node.get("topFix") + mitigation = ( + "**Resolution**: " + + topfix_node.get("date", "") + + "\n" + + topfix_node.get("message", "") + + "\n" + + topfix_node.get("fixResolution", "") + + "\n" + ) + except Exception: + logger.exception("Error handling topFix node.") elif "library" in node: node.get("project") description = ( @@ -255,7 +254,8 @@ def _build_common_output(node, lib_name=None): tree_node = content["response"] if tree_node: for node in tree_node: - findings.append(_build_common_output(node)) + if node.get("findingInfo", {}).get("status") == "ACTIVE": + findings.append(_build_common_output(node)) def create_finding_key(f: Finding) -> str: # """Hashes the finding's description and title to retrieve a key for deduplication."""