From b42a8d538cd32c98be25d2692af6ea36b270f65e Mon Sep 17 00:00:00 2001 From: Juanjo Alvarez Date: Mon, 21 Aug 2023 13:07:33 +0200 Subject: [PATCH] fix Signed-off-by: Juanjo Alvarez --- ddtrace/appsec/_capabilities.py | 9 +-------- ddtrace/appsec/_remoteconfiguration.py | 2 +- ddtrace/appsec/utils.py | 8 ++++++++ tests/appsec/test_remoteconfiguration.py | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ddtrace/appsec/_capabilities.py b/ddtrace/appsec/_capabilities.py index dc2d610d672..698b32a6159 100644 --- a/ddtrace/appsec/_capabilities.py +++ b/ddtrace/appsec/_capabilities.py @@ -4,18 +4,11 @@ from typing import Optional from ddtrace import Tracer -from ddtrace.constants import APPSEC_ENV +from ddtrace.appsec.utils import _appsec_rc_features_is_enabled from ddtrace.internal.compat import to_bytes_py2 from ddtrace.internal.utils.formats import asbool -def _appsec_rc_features_is_enabled(): - # type: () -> bool - if asbool(os.environ.get("DD_REMOTE_CONFIGURATION_ENABLED", "true")): - return APPSEC_ENV not in os.environ - return False - - def _appsec_rc_file_is_not_static(): return "DD_APPSEC_RULES" not in os.environ diff --git a/ddtrace/appsec/_remoteconfiguration.py b/ddtrace/appsec/_remoteconfiguration.py index 75a3770c65b..fab65ec4a70 100644 --- a/ddtrace/appsec/_remoteconfiguration.py +++ b/ddtrace/appsec/_remoteconfiguration.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING from ddtrace import config -from ddtrace.appsec._capabilities import _appsec_rc_features_is_enabled +from ddtrace.appsec.utils import _appsec_rc_features_is_enabled from ddtrace.appsec._capabilities import _appsec_rc_file_is_not_static from ddtrace.appsec._constants import PRODUCTS from ddtrace.constants import APPSEC_ENV diff --git a/ddtrace/appsec/utils.py b/ddtrace/appsec/utils.py index ed19e0e27ca..8d6895f801c 100644 --- a/ddtrace/appsec/utils.py +++ b/ddtrace/appsec/utils.py @@ -4,6 +4,7 @@ from ddtrace.appsec import _asm_request_context from ddtrace.appsec._constants import API_SECURITY +from ddtrace.constants import APPSEC_ENV from ddtrace.internal.compat import parse from ddtrace.internal.logger import get_logger from ddtrace.internal.utils.formats import asbool @@ -148,3 +149,10 @@ def __call__(self, *args, **kwargs): result = self.func(*args, **kwargs) self.reported_logs[raw_log_hash] = time.time() + self._time_lapse return result + + +def _appsec_rc_features_is_enabled(): + # type: () -> bool + if asbool(os.environ.get("DD_REMOTE_CONFIGURATION_ENABLED", "true")): + return APPSEC_ENV not in os.environ + return False diff --git a/tests/appsec/test_remoteconfiguration.py b/tests/appsec/test_remoteconfiguration.py index 866c465cc08..3ff790fdfd5 100644 --- a/tests/appsec/test_remoteconfiguration.py +++ b/tests/appsec/test_remoteconfiguration.py @@ -11,7 +11,7 @@ from ddtrace.appsec import _asm_request_context from ddtrace.appsec._capabilities import _appsec_rc_capabilities -from ddtrace.appsec._capabilities import _appsec_rc_features_is_enabled +from ddtrace.appsec.utils import _appsec_rc_features_is_enabled from ddtrace.appsec._constants import APPSEC from ddtrace.appsec._constants import DEFAULT from ddtrace.appsec._constants import PRODUCTS