Skip to content

Commit f763df3

Browse files
tenable: check mandatory columns before importing (#12273)
1 parent 6d412dd commit f763df3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

dojo/importers/base_importer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ def construct_imported_message(
487487
message += "."
488488
else:
489489
# Set the message to convey that all findings processed are identical to the last time an import/reimport occurred
490-
message = "No findings were added/updated/closed/reactivated as the findings in Defect Dojo are identical to those in the uploaded report."
490+
message = "No findings were added/updated/closed/reactivated as the report is empty or the findings in Defect Dojo are identical to those in the uploaded report."
491491

492492
return message
493493

dojo/tools/tenable/csv_format.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ def get_findings(self, filename: str, test: Test):
8080
content = content.decode("utf-8")
8181
csv.field_size_limit(int(sys.maxsize / 10)) # the request/resp are big
8282
reader = csv.DictReader(io.StringIO(content), delimiter=delimiter)
83+
if "Name" not in reader.fieldnames and "Plugin Name" not in reader.fieldnames and "asset.name" not in reader.fieldnames:
84+
msg = "Invalid CSV file: missing 'Name', 'Plugin Name' or 'asset.name' field"
85+
raise ValueError(msg)
8386
dupes = {}
8487
# Iterate over each line and create findings
8588
for row in reader:

0 commit comments

Comments
 (0)