@@ -352,6 +352,7 @@ def __init__(self, config, logger=None, noOutput=False, timeAfter="1970-01-01T00
352
352
self .timeField = timeField
353
353
self .hashes = hashes
354
354
self .delimiter = delimiter
355
+ self .first_json_output = True # To manage commas in JSON output
355
356
356
357
def close (self ):
357
358
self .dbConnection .close ()
@@ -565,7 +566,6 @@ def executeRuleset(self, outFile, writeMode='w', showAll=False,
565
566
Execute all rules in the ruleset and handle output.
566
567
"""
567
568
csvWriter = None
568
- first_json_output = True # To manage commas in JSON output
569
569
is_json_mode = not self .csvMode
570
570
571
571
# Prepare output file handle if needed
@@ -628,10 +628,10 @@ def executeRuleset(self, outFile, writeMode='w', showAll=False,
628
628
# Write results as JSON using orjson
629
629
try :
630
630
# Handle commas between JSON objects
631
- if not first_json_output :
631
+ if not self . first_json_output :
632
632
fileHandle .write (',\n ' )
633
633
else :
634
- first_json_output = False
634
+ self . first_json_output = False
635
635
# Serialize ruleResults to JSON bytes with indentation
636
636
json_bytes = json .dumps (ruleResults , option = json .OPT_INDENT_2 )
637
637
# Write the decoded JSON string to the file
0 commit comments