DataDog / dd-trace-py

Datadog Python APM Client
https://ddtrace.readthedocs.io/
Other
553 stars 416 forks source link

fix(iast): add code to filter out ddtrace stuff from dir() on patched modules [backport 2.17] #11504

Closed github-actions[bot] closed 22 hours ago

github-actions[bot] commented 3 days ago

Backport a9a6ad712e37e832d0e43a0c9bf6541f7bded8d4 from #11490 to 2.17.

Signed-off-by: Juanjo Alvarez juanjo.alvarezmartinez@datadoghq.com

Description

While testing on dd-source CI we found an issue where a module was doing a dir(other_module) and the changed results from the patched module were breaking stuff (because our patching would add ddtrace_aspects, ddtrace_sink_points, et cetera to the results and the original module was expecting all other_module symbols to have some members like id).

This PRs fixes this problem by:

Also:

Checklist

Reviewer Checklist

pr-commenter[bot] commented 3 days ago

Benchmarks

Benchmark execution time: 2024-11-25 10:40:28

Comparing candidate commit 3f719f09d93f8be726d9d48c3c5032c6cb28df52 in PR branch backport-11490-to-2.17 with baseline commit f3c25f767424e30000df96412c790c3cae648da8 in branch 2.17.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 58 metrics, 2 unstable metrics.

github-actions[bot] commented 23 hours ago

CODEOWNERS have been resolved as:

releasenotes/notes/code-security-patch-dir-54cc85f18e31f45c.yaml        @DataDog/apm-python
tests/appsec/iast/fixtures/ast/other/with_implemented_dir.py            @DataDog/asm-python
tests/appsec/iast/fixtures/ast/other/without_implemented_dir.py         @DataDog/asm-python
ddtrace/appsec/_constants.py                                            @DataDog/asm-python
ddtrace/appsec/_iast/_ast/ast_patching.py                               @DataDog/asm-python
ddtrace/appsec/_iast/_ast/visitor.py                                    @DataDog/asm-python
ddtrace/appsec/_iast/_loader.py                                         @DataDog/asm-python
tests/appsec/appsec_utils.py                                            @DataDog/asm-python
tests/appsec/iast/_ast/test_ast_patching.py                             @DataDog/asm-python
tests/appsec/iast/aspects/test_add_aspect_fixtures.py                   @DataDog/asm-python
tests/appsec/iast/aspects/test_add_inplace_aspect_fixtures.py           @DataDog/asm-python
tests/appsec/iast_packages/inside_env_runner.py                         @DataDog/asm-python