From 8bc8b16a77da12bf033a60c3b211474e6e9ca948 Mon Sep 17 00:00:00 2001 From: StylusFrost Date: Fri, 5 Jun 2026 13:57:36 +0200 Subject: [PATCH] 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. --- prowler/providers/common/models.py | 5 +++-- prowler/providers/common/provider.py | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/prowler/providers/common/models.py b/prowler/providers/common/models.py index ea70252f0a..b440718aff 100644 --- a/prowler/providers/common/models.py +++ b/prowler/providers/common/models.py @@ -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 diff --git a/prowler/providers/common/provider.py b/prowler/providers/common/provider.py index c8561cd4bd..5627839288 100644 --- a/prowler/providers/common/provider.py +++ b/prowler/providers/common/provider.py @@ -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)