Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(config): Store in provider #3498

Merged
9 changes: 4 additions & 5 deletions prowler/providers/aws/aws_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -225,10 +225,9 @@ def __init__(self, arguments: Namespace):
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):
Expand Down
10 changes: 7 additions & 3 deletions prowler/providers/azure/azure_provider.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import asyncio
import sys
from os import getenv
from typing import Optional

import requests
from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential
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 (
Expand All @@ -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
Expand Down Expand Up @@ -63,8 +63,12 @@ def __init__(self, arguments):

# 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):
Expand Down
11 changes: 9 additions & 2 deletions prowler/providers/gcp/gcp_provider.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 = {}
Expand Down Expand Up @@ -56,6 +57,12 @@ def __init__(self, arguments):
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
Expand Down
10 changes: 8 additions & 2 deletions prowler/providers/kubernetes/kubernetes_provider.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -52,6 +52,12 @@ def __init__(self, arguments: Namespace):
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
Expand Down
Loading