mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-11 07:15:15 +00:00
29 lines
677 B
Python
29 lines
677 B
Python
import json
|
|
import sys
|
|
from io import TextIOWrapper
|
|
from typing import Any
|
|
|
|
from lib.logger import logger
|
|
|
|
|
|
def open_file(input_file: str) -> TextIOWrapper:
|
|
try:
|
|
# First recover the available groups in groups.json
|
|
f = open(input_file)
|
|
except Exception as e:
|
|
logger.critical(f"{input_file}: {e.__class__.__name__}")
|
|
sys.exit()
|
|
else:
|
|
return f
|
|
|
|
|
|
# Parse checks from file
|
|
def parse_json_file(input_file: TextIOWrapper) -> Any:
|
|
try:
|
|
json_file = json.load(input_file)
|
|
except Exception as e:
|
|
logger.critical(f"{input_file.name}: {e.__class__.__name__}")
|
|
sys.exit()
|
|
else:
|
|
return json_file
|