Skip to content

Commit 1a1d1ae

Browse files
committed
fix: correct multi-line record detection in Qualys CSV parser
The previous end-of-record detection incorrectly treated any line ending with a single quote as a complete record. This caused multi-line records (where Results field contains embedded newlines) to be split incorrectly. In Qualys non-standard format, multi-field records always end with """ (the last field's closing "" plus the record's closing "). Single quote endings within a record are just field content, not record terminators. Authored by T. Walker - DefectDojo
1 parent d9f0aac commit 1a1d1ae

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

dojo/tools/qualys_vmdr/helpers.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def _parse_nonstandard_content(lines, skip_metadata_lines):
385385
return []
386386

387387
# Parse data rows - need to handle multi-line records
388-
# A row starts with " and ends with "
388+
# A row starts with " and ends with """ (last field's "" + record's ")
389389
rows = []
390390
current_row = ""
391391
in_record = False
@@ -403,22 +403,16 @@ def _parse_nonstandard_content(lines, skip_metadata_lines):
403403
current_row = line
404404
in_record = True
405405
# Check if this line also ends the record
406-
if line.rstrip().endswith('"') and not line.rstrip().endswith('""'):
407-
# Complete single-line record
408-
rows.append(current_row)
409-
current_row = ""
410-
in_record = False
411-
elif line.rstrip().endswith('"""'):
412-
# Ends with "" followed by " - this is end of record
406+
# Multi-field records end with """ (last field's "" + record's ")
407+
if line.rstrip().endswith('"""'):
413408
rows.append(current_row)
414409
current_row = ""
415410
in_record = False
416411
else:
417412
# Continuing a multi-line record
418413
current_row += "\n" + line
419414
# Check if this line ends the record
420-
stripped_line = line.rstrip()
421-
if (stripped_line.endswith('"') and not stripped_line.endswith('""')) or stripped_line.endswith('"""'):
415+
if line.rstrip().endswith('"""'):
422416
rows.append(current_row)
423417
current_row = ""
424418
in_record = False

0 commit comments

Comments
 (0)