Skip to content

Commit

Permalink
New test with import hooks re-enabled but patching disabled
Browse files Browse the repository at this point in the history
Signed-off-by: Juanjo Alvarez <[email protected]>
  • Loading branch information
juanjux committed Jul 24, 2024
1 parent 8d94dcb commit f43389f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
14 changes: 7 additions & 7 deletions ddtrace/_monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,13 @@ def patch_all(**patch_modules):
modules.update(patch_modules)

patch(raise_errors=False, **modules)
# JJJ disabled
# if asm_config._iast_enabled:
# from ddtrace.appsec._iast._patch_modules import patch_iast
# from ddtrace.appsec.iast import enable_iast_propagation
#
# patch_iast()
# enable_iast_propagation()
if asm_config._iast_enabled:
from ddtrace.appsec._iast._patch_modules import patch_iast
from ddtrace.appsec.iast import enable_iast_propagation

patch_iast()
# JJJ
# enable_iast_propagation()

if asm_config._ep_enabled or asm_config._iast_enabled:
from ddtrace.appsec._common_module_patches import patch_common_modules
Expand Down
3 changes: 2 additions & 1 deletion ddtrace/appsec/_iast/_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@


def _exec_iast_patched_module(module_watchdog, module):
# JJJ delete comment
module_watchdog.loader.exec_module(module)
return # JJJ
patched_source = None
compiled_code = None
if IS_IAST_ENABLED:
Expand Down
25 changes: 12 additions & 13 deletions ddtrace/appsec/_iast/_patch_modules.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# from ddtrace.vendor.wrapt.importer import when_imported
from ddtrace.vendor.wrapt.importer import when_imported


IAST_PATCH = {
Expand All @@ -14,15 +14,14 @@ def patch_iast(patch_modules=IAST_PATCH):
IAST_PATCH: list of implemented vulnerabilities
"""
# JJJ disabled for test
# # TODO: Devise the correct patching strategy for IAST
# from ddtrace._monkey import _on_import_factory
#
# for module in (m for m, e in patch_modules.items() if e):
# when_imported("hashlib")(
# _on_import_factory(module, prefix="ddtrace.appsec._iast.taint_sinks", raise_errors=False)
# )
#
# when_imported("json")(
# _on_import_factory("json_tainting", prefix="ddtrace.appsec._iast._patches", raise_errors=False)
# )
# TODO: Devise the correct patching strategy for IAST
from ddtrace._monkey import _on_import_factory

for module in (m for m, e in patch_modules.items() if e):
when_imported("hashlib")(
_on_import_factory(module, prefix="ddtrace.appsec._iast.taint_sinks", raise_errors=False)
)

when_imported("json")(
_on_import_factory("json_tainting", prefix="ddtrace.appsec._iast._patches", raise_errors=False)
)

0 comments on commit f43389f

Please sign in to comment.