mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 23:05:05 +00:00
feat(organizations): Extract Metadata from Management Account ID (-O) (#1248)
* feat(organizations): add organizations funtion to provider * feat(organizations): add organizations -O option * fix(comments): Resolve comments. * feat(test): add test * fix(pipfile): update pipfile Co-authored-by: sergargar <sergio@verica.io>
This commit is contained in:
@@ -9,7 +9,7 @@ from colorama import Fore, Style
|
||||
from config.config import groups_file
|
||||
from lib.check.models import Output_From_Options, load_check_metadata
|
||||
from lib.logger import logger
|
||||
from lib.outputs.outputs import get_orgs_info, report
|
||||
from lib.outputs.outputs import report
|
||||
from lib.utils.utils import open_file, parse_json_file
|
||||
|
||||
|
||||
@@ -98,7 +98,6 @@ def print_services(service_list: set):
|
||||
print(f"- {service}")
|
||||
|
||||
|
||||
|
||||
def print_checks(provider: str, check_list: set, bulk_checks_metadata: dict):
|
||||
for check in check_list:
|
||||
try:
|
||||
@@ -111,7 +110,6 @@ def print_checks(provider: str, check_list: set, bulk_checks_metadata: dict):
|
||||
)
|
||||
|
||||
|
||||
|
||||
# List available groups
|
||||
def list_groups(provider: str):
|
||||
groups = parse_groups_from_file(groups_file)
|
||||
@@ -193,10 +191,7 @@ def run_check(check, audit_info, output_options):
|
||||
logger.debug(f"Executing check: {check.checkName}")
|
||||
findings = check.execute()
|
||||
|
||||
# Call to get orgs, need to check if input option is passed in output options
|
||||
# right now it is not checked and is called straight to generate the fields to be passed to the csv
|
||||
organizations_info = get_orgs_info()
|
||||
report(findings, output_options, audit_info, organizations_info)
|
||||
report(findings, output_options, audit_info)
|
||||
|
||||
|
||||
def import_check(check_path: str) -> ModuleType:
|
||||
|
||||
@@ -192,12 +192,3 @@ class Check_Report:
|
||||
self.resource_tags = []
|
||||
self.resource_id = ""
|
||||
self.resource_arn = ""
|
||||
|
||||
|
||||
@dataclass
|
||||
class Organizations_Info:
|
||||
account_details_email: str
|
||||
account_details_name: str
|
||||
account_details_arn: str
|
||||
account_details_org: str
|
||||
account_details_tags: str
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from dataclasses import asdict, dataclass
|
||||
|
||||
from config.config import timestamp
|
||||
from lib.check.models import Check_Report, Organizations_Info
|
||||
from lib.check.models import Check_Report
|
||||
from providers.aws.models import AWS_Organizations_Info
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -65,7 +66,7 @@ class Check_Output_CSV:
|
||||
account: str,
|
||||
profile: str,
|
||||
report: Check_Report,
|
||||
organizations: Organizations_Info,
|
||||
organizations: AWS_Organizations_Info,
|
||||
):
|
||||
self.assessment_start_time = timestamp.isoformat()
|
||||
self.finding_unique_id = ""
|
||||
@@ -181,9 +182,3 @@ class Check_Output_CSV:
|
||||
groups = ""
|
||||
|
||||
return unrolled_compliance
|
||||
|
||||
def get_csv_header(self):
|
||||
csv_header = []
|
||||
for key in asdict(self):
|
||||
csv_header = csv_header.append(key)
|
||||
return csv_header
|
||||
|
||||
@@ -3,12 +3,11 @@ from csv import DictWriter
|
||||
from colorama import Fore, Style
|
||||
|
||||
from config.config import csv_file_suffix
|
||||
from lib.check.models import Organizations_Info
|
||||
from lib.outputs.models import Check_Output_CSV
|
||||
from lib.utils.utils import file_exists, open_file
|
||||
|
||||
|
||||
def report(check_findings, output_options, audit_info, organizations_info):
|
||||
def report(check_findings, output_options, audit_info):
|
||||
check_findings.sort(key=lambda x: x.region)
|
||||
|
||||
csv_fields = []
|
||||
@@ -45,9 +44,8 @@ def report(check_findings, output_options, audit_info, organizations_info):
|
||||
audit_info.audited_account,
|
||||
audit_info.profile,
|
||||
finding,
|
||||
organizations_info,
|
||||
audit_info.organizations_metadata,
|
||||
)
|
||||
|
||||
csv_writer = DictWriter(
|
||||
file_descriptors["csv"], fieldnames=csv_fields, delimiter=";"
|
||||
)
|
||||
@@ -106,14 +104,3 @@ def generate_csv_fields():
|
||||
for field in Check_Output_CSV.__dict__["__annotations__"].keys():
|
||||
csv_fields.append(field)
|
||||
return csv_fields
|
||||
|
||||
|
||||
def get_orgs_info():
|
||||
organizations_info = Organizations_Info(
|
||||
account_details_email="",
|
||||
account_details_name="",
|
||||
account_details_arn="",
|
||||
account_details_org="",
|
||||
account_details_tags="",
|
||||
)
|
||||
return organizations_info
|
||||
|
||||
Reference in New Issue
Block a user