Skip to content

Commit

Permalink
Update parser.py
Browse files Browse the repository at this point in the history
  • Loading branch information
testaccount90009 committed Dec 21, 2024
1 parent df287f7 commit 7a935fe
Showing 1 changed file with 44 additions and 48 deletions.
92 changes: 44 additions & 48 deletions dojo/tools/mend/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,54 +40,50 @@ def _build_common_output(node, lib_name=None):
cvss3_score = None
mitigation = "N/A"
locations = []
if "component" in node:
# Iterate over all findingInfo nodes and process each ACTIVE status
for finding_info in node.get("findingInfo", []):
if finding_info.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)
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.")
if "component" in node and if finding_info.get("status") == "ACTIVE":

Check failure on line 43 in dojo/tools/mend/parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff

dojo/tools/mend/parser.py:43:40: SyntaxError: Expected an identifier, but found a keyword 'if' that cannot be used here

Check failure on line 43 in dojo/tools/mend/parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff

dojo/tools/mend/parser.py:43:43: SyntaxError: Expected ':', found name
description = (

Check failure on line 44 in dojo/tools/mend/parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff

dojo/tools/mend/parser.py:43:82: SyntaxError: Expected an expression

Check failure on line 44 in dojo/tools/mend/parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff

dojo/tools/mend/parser.py:44:1: SyntaxError: Unexpected indentation
"**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")

Check failure on line 61 in dojo/tools/mend/parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff

dojo/tools/mend/parser.py:61:1: SyntaxError: Unexpected indentation

Check failure on line 61 in dojo/tools/mend/parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (E113)

dojo/tools/mend/parser.py:61:1: E113 Unexpected indentation
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)
if component_path:
locations.append(component_path)
if "topFix" in node:

Check failure on line 73 in dojo/tools/mend/parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff

dojo/tools/mend/parser.py:73:1: SyntaxError: unindent does not match any outer indentation level

Check failure on line 73 in dojo/tools/mend/parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (E305)

dojo/tools/mend/parser.py:73:1: E305 Expected 2 blank lines after class or function definition, found (0)
try:

Check failure on line 74 in dojo/tools/mend/parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (E117)

dojo/tools/mend/parser.py:74:1: E117 Over-indented
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:

Check failure on line 87 in dojo/tools/mend/parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff

dojo/tools/mend/parser.py:87:13: SyntaxError: Expected a statement
node.get("project")
description = (
Expand Down

0 comments on commit 7a935fe

Please sign in to comment.