Skip to content

Commit

Permalink
Update convert_nessus_csv_to_sarif.py more linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jpweiser authored Nov 18, 2024
1 parent 6dc51f7 commit a6666dc
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions scanners/generic/tools/convert_nessus_csv_to_sarif.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ def convert_csv_to_sarif(csv_file):
"Nessus version", row["Plugin Output"]
)
# Adding fullname to include policy
sarif_template["runs"][0]["tool"]["driver"]["fullName"] = (
"%s %s %s Policy",
full_name = (
nessus_info("Scanner edition used", row["Plugin Output"]),
nessus_info("Nessus version", row["Plugin Output"]),
nessus_info("Scan policy used", row["Plugin Output"]),
)
sarif_template["runs"][0]["tool"]["driver"][
"fullName"
] = f"{full_name[0]} {full_name[1]} {full_name[2]} Policy"

if row["Plugin ID"] not in rule_ids:
new_rule = {
Expand All @@ -117,7 +119,7 @@ def convert_csv_to_sarif(csv_file):
"ruleId": row["Plugin ID"],
"level": map_level(row["Risk"]),
"message": {
"text": f"{row["Plugin Output"]}\n\nSolution: {row["Solution"]}"
"text": f"{row['Plugin Output']}\n\nSolution: {row['Solution']}"
},
"locations": [
{
Expand All @@ -139,15 +141,15 @@ def main():
"""
# Parse command-line arguments
parser = argparse.ArgumentParser(
description="Convert JSON data to SARIF format with JSON block added to message."
description="Convert Nessus CSV report to SARIF JSON format."
)
parser.add_argument(
"-f",
"--filename",
type=str,
required=False,
default=None,
help="Path to JSON file (if absent or '-': read from STDIN)",
help="Path to Nessus CSV file (if absent or '-': read from STDIN)",
)
parser.add_argument(
"--log-level",
Expand All @@ -169,3 +171,4 @@ def main():

if __name__ == "__main__":
main()

0 comments on commit a6666dc

Please sign in to comment.