Skip to content

Commit

Permalink
Update convert_nessus_csv_to_sarif.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jpweiser authored Nov 18, 2024
1 parent a6666dc commit 35de6c6
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions scanners/generic/tools/convert_nessus_csv_to_sarif.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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)
Expand All @@ -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",
Expand Down

0 comments on commit 35de6c6

Please sign in to comment.