mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-05 03:12:14 +00:00
fix(provider): avoid import cycle in get_output_options default
Move the models.py Provider import (used only in the shodan path) to a local import so models no longer depends on provider at module level. This breaks the provider <-> models import cycle CodeQL flagged after the generic OutputOptions default was added, and lets provider.py import ProviderOutputOptions without a cycle. The output_file_timestamp import is consolidated into the existing top-level config import.
This commit is contained in:
@@ -4,8 +4,6 @@ from os.path import isdir
|
||||
|
||||
from pydantic.v1 import BaseModel
|
||||
|
||||
from prowler.providers.common.provider import Provider
|
||||
|
||||
|
||||
# TODO: include this for all the providers
|
||||
class Audit_Metadata(BaseModel):
|
||||
@@ -41,6 +39,9 @@ class ProviderOutputOptions:
|
||||
# Shodan API Key
|
||||
if self.shodan_api_key:
|
||||
# TODO: revisit this logic
|
||||
# Local import to avoid a module-level import cycle with provider.py
|
||||
from prowler.providers.common.provider import Provider
|
||||
|
||||
provider = Provider.get_global_provider()
|
||||
updated_audit_config = Provider.update_provider_config(
|
||||
provider.audit_config, "shodan_api_key", self.shodan_api_key
|
||||
|
||||
@@ -9,7 +9,7 @@ from argparse import Namespace
|
||||
from importlib import import_module
|
||||
from typing import Any, Optional
|
||||
|
||||
from prowler.config.config import load_and_validate_config_file
|
||||
from prowler.config.config import load_and_validate_config_file, output_file_timestamp
|
||||
from prowler.lib.logger import logger
|
||||
from prowler.lib.mutelist.mutelist import Mutelist
|
||||
|
||||
@@ -155,7 +155,6 @@ class Provider(ABC):
|
||||
|
||||
def get_output_options(self, arguments, bulk_checks_metadata):
|
||||
"""Return a generic OutputOptions default; override for provider-specific output."""
|
||||
from prowler.config.config import output_file_timestamp
|
||||
from prowler.providers.common.models import ProviderOutputOptions
|
||||
|
||||
output_options = ProviderOutputOptions(arguments, bulk_checks_metadata)
|
||||
|
||||
Reference in New Issue
Block a user