mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-29 14:54:30 +00:00
fix: add condition before close the csv file
This commit is contained in:
1 parent
747b97fe87
commit
f7e27402aa
3 files changed
+9
-2
No files matched your search
@@ -1115,6 +1115,12 @@ class ScanViewSet(BaseRLSViewSet):
|
||||
def report(self, request, pk=None):
|
||||
scan_instance = Scan.objects.get(pk=pk)
|
||||
output_path = scan_instance.output_path
|
||||
|
||||
if not output_path:
|
||||
return Response(
|
||||
{"detail": "No files found"}, status=status.HTTP_404_NOT_FOUND
|
||||
)
|
||||
|
||||
if scan_instance.upload_to_s3:
|
||||
s3_client = None
|
||||
try:
|
||||
|
||||
@@ -223,7 +223,7 @@ def generate_outputs(scan_id: str, provider_id: str, tenant_id: str):
|
||||
)
|
||||
|
||||
# Retrieve findings queryset
|
||||
findings_qs = Finding.objects.filter(scan_id=scan_id)
|
||||
findings_qs = Finding.objects.filter(scan_id=scan_id).order_by("uid")
|
||||
|
||||
# Process findings in batches
|
||||
for batch, is_last_batch in batched(findings_qs.iterator(), 50):
|
||||
|
||||
@@ -102,7 +102,8 @@ class CSV(Output):
|
||||
csv_writer.writeheader()
|
||||
for finding in self._data:
|
||||
csv_writer.writerow(finding)
|
||||
self._file_descriptor.close()
|
||||
if self.close_file:
|
||||
self._file_descriptor.close()
|
||||
except Exception as error:
|
||||
logger.error(
|
||||
f"{error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
|
||||
Reference in new issue
Block a user