Skip to content

Commit f1c95df

Browse files
committed
chore(iast): fix import chains
1 parent da7548e commit f1c95df

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

ddtrace/appsec/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55

66
_APPSEC_TO_BE_LOADED = True
7-
_IAST_TO_BE_LOADED = True
87

98

109
def load_appsec():
@@ -17,16 +16,6 @@ def load_appsec():
1716
_APPSEC_TO_BE_LOADED = False
1817

1918

20-
def load_iast():
21-
"""Lazily load the iast module listeners."""
22-
from ddtrace.appsec._iast._listener import iast_listen
23-
24-
global _IAST_TO_BE_LOADED
25-
if _IAST_TO_BE_LOADED:
26-
iast_listen()
27-
_IAST_TO_BE_LOADED = False
28-
29-
3019
def load_common_appsec_modules():
3120
"""Lazily load the common module patches."""
3221
from ddtrace.settings.asm import config as asm_config

ddtrace/appsec/_iast/__init__.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ def wrapped_function(wrapped, instance, args, kwargs):
3737
from ddtrace.internal.module import ModuleWatchdog
3838
from ddtrace.settings.asm import config as asm_config
3939

40+
from ._listener import iast_listen
4041
from ._overhead_control_engine import OverheadControl
4142

4243

4344
log = get_logger(__name__)
4445

46+
_IAST_TO_BE_LOADED = True
47+
_iast_propagation_enabled = False
48+
4549
oce = OverheadControl()
4650

4751

@@ -79,9 +83,6 @@ def ddtrace_iast_flask_patch():
7983
exec(compiled_code, module.__dict__) # nosec B102
8084

8185

82-
_iast_propagation_enabled = False
83-
84-
8586
def enable_iast_propagation():
8687
"""Add IAST AST patching in the ModuleWatchdog"""
8788
# DEV: These imports are here to avoid _ast.ast_patching import in the top level
@@ -141,3 +142,11 @@ def disable_iast_propagation():
141142
"enable_iast_propagation",
142143
"disable_iast_propagation",
143144
]
145+
146+
147+
def load_iast():
148+
"""Lazily load the iast module listeners."""
149+
global _IAST_TO_BE_LOADED
150+
if _IAST_TO_BE_LOADED:
151+
iast_listen()
152+
_IAST_TO_BE_LOADED = False

ddtrace/appsec/_iast/processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@dataclass(eq=False)
1616
class AppSecIastSpanProcessor(SpanProcessor):
1717
def __post_init__(self) -> None:
18-
from ddtrace.appsec import load_iast
18+
from . import load_iast
1919

2020
load_iast()
2121

0 commit comments

Comments
 (0)