chore(config): Store in provider (#3498)

Co-authored-by: Sergio Garcia <38561120+sergargar@users.noreply.github.com>
This commit is contained in:
Pepe Fagoaga
2024-03-05 10:21:08 +01:00
committed by GitHub
parent 38496ff646
commit d8e27f0d33
4 changed files with 28 additions and 12 deletions
+4 -5
View File
@@ -46,7 +46,7 @@ class AwsProvider(Provider):
_session: AWSSession
_organizations_metadata: AWSOrganizationsInfo
_audit_resources: list = []
_audit_config: dict = {}
_audit_config: dict
_ignore_unused_services: bool = False
_enabled_regions: set = set()
# TODO: enforce the mutelist for the Provider class
@@ -225,10 +225,9 @@ class AwsProvider(Provider):
self._ignore_unused_services = ignore_unused_services
# Audit Config
if getattr(arguments, "config_file", None):
self._audit_config = load_and_validate_config_file(
self._type, arguments.config_file
)
self._audit_config = load_and_validate_config_file(
self._type, arguments.config_file
)
@property
def identity(self):
+7 -3
View File
@@ -1,7 +1,6 @@
import asyncio
import sys
from os import getenv
from typing import Optional
import requests
from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential
@@ -9,6 +8,7 @@ from azure.mgmt.subscription import SubscriptionClient
from colorama import Fore, Style
from msgraph import GraphServiceClient
from prowler.config.config import load_and_validate_config_file
from prowler.lib.logger import logger
from prowler.providers.azure.lib.regions.regions import get_regions_config
from prowler.providers.azure.models import (
@@ -24,7 +24,7 @@ class AzureProvider(Provider):
_type: str = "azure"
_session: DefaultAzureCredential
_identity: AzureIdentityInfo
_audit_config: Optional[dict]
_audit_config: dict
_region_config: AzureRegionConfig
_locations: dict
_output_options: AzureOutputOptions
@@ -63,8 +63,12 @@ class AzureProvider(Provider):
# TODO: should we keep this here or within the identity?
self._locations = self.get_locations(self.session, self.region_config)
# TODO: move this to the providers, pending for AWS, GCP, AZURE and K8s
self._audit_config = {}
# Audit Config
self._audit_config = load_and_validate_config_file(
self._type, arguments.config_file
)
@property
def identity(self):
+9 -2
View File
@@ -1,12 +1,12 @@
import os
import sys
from typing import Optional
from colorama import Fore, Style
from google import auth
from google.oauth2.credentials import Credentials
from googleapiclient import discovery
from prowler.config.config import load_and_validate_config_file
from prowler.lib.logger import logger
from prowler.providers.common.models import Audit_Metadata
from prowler.providers.common.provider import Provider
@@ -18,7 +18,8 @@ class GcpProvider(Provider):
_session: Credentials
_project_ids: list
_identity: GCPIdentityInfo
_audit_config: Optional[dict]
_audit_config: dict
_output_options: GCPOutputOptions
# TODO: enforce the mutelist for the Provider class
# _mutelist: dict = {}
@@ -56,6 +57,12 @@ class GcpProvider(Provider):
default_project_id=default_project_id,
)
# TODO: move this to the providers, pending for AWS, GCP, AZURE and K8s
# Audit Config
self._audit_config = load_and_validate_config_file(
self._type, arguments.config_file
)
@property
def identity(self):
return self._identity
@@ -1,11 +1,11 @@
import os
import sys
from argparse import Namespace
from typing import Optional
from colorama import Fore, Style
from kubernetes import client, config
from prowler.config.config import load_and_validate_config_file
from prowler.lib.logger import logger
from prowler.providers.common.models import Audit_Metadata
from prowler.providers.common.provider import Provider
@@ -20,7 +20,7 @@ class KubernetesProvider(Provider):
_type: str = "kubernetes"
_session: KubernetesSession
_namespaces: list
_audit_config: Optional[dict]
_audit_config: dict
_identity: KubernetesIdentityInfo
_output_options: KubernetesOutputOptions
# TODO: enforce the mutelist for the Provider class
@@ -52,6 +52,12 @@ class KubernetesProvider(Provider):
cluster=self._session.context["context"]["user"],
)
# TODO: move this to the providers, pending for AWS, GCP, AZURE and K8s
# Audit Config
self._audit_config = load_and_validate_config_file(
self._type, arguments.config_file
)
@property
def type(self):
return self._type