mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 14:55:00 +00:00
feat(outputS): Output generation format CSV (#1230)
* chore(csv): first version csv output * chore(pytest): added pytest dependency * chore(outputs): organizations demo * chore(compliance): Added new dataclass for each compliance framework * fix(test org values): deleted test values in orgs instantiation * fix(csv): formatted to match output format * fix(csv output): Reformulation of check report and minor changes * fix(minor issues): Fix various issues coming from PR comments * fix(csv): Renamed csv output data model * fix(output dir): create default if not present * fix(typo): remove s * fix(oldcode) * fix(typo) * fix(output): Only send to csv when -M is passed Co-authored-by: sergargar <sergio@verica.io> Co-authored-by: Pepe Fagoaga <pepe@verica.io>
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import json
|
||||
import sys
|
||||
from io import TextIOWrapper
|
||||
from os.path import exists
|
||||
from typing import Any
|
||||
|
||||
from lib.logger import logger
|
||||
|
||||
|
||||
def open_file(input_file: str) -> TextIOWrapper:
|
||||
def open_file(input_file: str, mode: str = "r") -> TextIOWrapper:
|
||||
try:
|
||||
# First recover the available groups in groups.json
|
||||
f = open(input_file)
|
||||
f = open(input_file, mode)
|
||||
except Exception as e:
|
||||
logger.critical(f"{input_file}: {e.__class__.__name__}")
|
||||
sys.exit()
|
||||
@@ -26,3 +26,17 @@ def parse_json_file(input_file: TextIOWrapper) -> Any:
|
||||
sys.exit()
|
||||
else:
|
||||
return json_file
|
||||
|
||||
|
||||
# check if file exists
|
||||
def file_exists(filename: str):
|
||||
try:
|
||||
exists_filename = exists(filename)
|
||||
except Exception as e:
|
||||
logger.critical(f"{exists_filename.name}: {e.__class__.__name__}")
|
||||
quit()
|
||||
else:
|
||||
if exists_filename:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user