fix(json): close Json correctly when no findings (#1773)

Co-authored-by: sergargar <sergio@verica.io>
This commit is contained in:
Sergio Garcia
2023-01-25 13:54:48 +01:00
committed by GitHub
parent 07307d37a1
commit 4e34be87a1
2 changed files with 3 additions and 2 deletions

View File

@@ -71,7 +71,8 @@ def close_json(output_filename, output_directory, mode):
)
# Replace last comma for square bracket if not empty
if file_descriptor.tell() > 0:
file_descriptor.seek(file_descriptor.tell() - 1, os.SEEK_SET)
if file_descriptor.tell() != 1:
file_descriptor.seek(file_descriptor.tell() - 1, os.SEEK_SET)
file_descriptor.truncate()
file_descriptor.write("]")
file_descriptor.close()

View File

@@ -32,7 +32,7 @@ def stdout_report(finding, color, verbose, is_quiet):
if finding.check_metadata.Provider == "azure":
details = finding.check_metadata.ServiceName
if verbose:
if verbose and not (is_quiet and finding.status != "FAIL"):
print(
f"\t{color}{finding.status}{Style.RESET_ALL} {details}: {finding.status_extended}"
)