From 35de6c68a49e5861bed97ecc0e60ca239e60e44f Mon Sep 17 00:00:00 2001 From: "J.P. Weiser" <4422366+jpweiser@users.noreply.github.com> Date: Mon, 18 Nov 2024 15:49:59 -0500 Subject: [PATCH] Update convert_nessus_csv_to_sarif.py --- .../tools/convert_nessus_csv_to_sarif.py | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/scanners/generic/tools/convert_nessus_csv_to_sarif.py b/scanners/generic/tools/convert_nessus_csv_to_sarif.py index 07647a6..99b1468 100644 --- a/scanners/generic/tools/convert_nessus_csv_to_sarif.py +++ b/scanners/generic/tools/convert_nessus_csv_to_sarif.py @@ -81,9 +81,7 @@ def convert_csv_to_sarif(csv_file): else: logging.debug("Reading input from STDIN") - with ( - open(csv_file, newline="", encoding="utf-8") if is_file(csv_file) else sys.stdin - ) as report: + with open(csv_file, newline="", encoding="utf-8") if is_file(csv_file) else sys.stdin as report: reader = csv.DictReader(report) for row in reader: if row["Plugin ID"] == "19506": @@ -118,16 +116,8 @@ def convert_csv_to_sarif(csv_file): new_report = { "ruleId": row["Plugin ID"], "level": map_level(row["Risk"]), - "message": { - "text": f"{row['Plugin Output']}\n\nSolution: {row['Solution']}" - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": {"uri": artifact_location} - } - } - ], + "message": {"text": f"{row['Plugin Output']}\n\nSolution: {row['Solution']}"}, + "locations": [{"physicalLocation": {"artifactLocation": {"uri": artifact_location}}}], } sarif_template["runs"][0]["results"].append(new_report) @@ -140,9 +130,7 @@ def main(): Parses arguments before converting Nessus CSV report to SARIF JSON format """ # Parse command-line arguments - parser = argparse.ArgumentParser( - description="Convert Nessus CSV report to SARIF JSON format." - ) + parser = argparse.ArgumentParser(description="Convert Nessus CSV report to SARIF JSON format.") parser.add_argument( "-f", "--filename",