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:
Nacho Rivera
2022-07-04 10:30:47 +02:00
committed by GitHub
parent a1dcc1310a
commit 11652838e2
16 changed files with 532 additions and 90 deletions

View File

@@ -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