mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 14:55:00 +00:00
feat(groups): Launch specific checks from groups and services (#1204)
This commit is contained in:
27
lib/utils/utils.py
Normal file
27
lib/utils/utils.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import json
|
||||
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__}")
|
||||
quit()
|
||||
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__}")
|
||||
quit()
|
||||
else:
|
||||
return json_file
|
||||
Reference in New Issue
Block a user