Skip to content

fix(asm): make sure iast is not loaded by exploit prevention if disabled#12198

Merged
christophe-papazian merged 16 commits into3.x-stagingfrom
christophe-papazian/exploit_prevention_on_windows
Feb 3, 2025
Merged

fix(asm): make sure iast is not loaded by exploit prevention if disabled#12198
christophe-papazian merged 16 commits into3.x-stagingfrom
christophe-papazian/exploit_prevention_on_windows

Conversation

@christophe-papazian
Copy link
Copy Markdown
Contributor

@christophe-papazian christophe-papazian commented Feb 3, 2025

Make sure, if iast is disabled, that we don't load any iast modules in the common module mechanism used both by iast and exploit prevention.

APPSEC-56659

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

Comment thread ddtrace/appsec/_iast/_iast_request_context.py
Comment thread ddtrace/appsec/_iast/taint_sinks/insecure_cookie.py
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 3, 2025

CODEOWNERS have been resolved as:

releasenotes/notes/no_IAST_unguarded_loading_in_common_module_patches-123cf6d3f8844823.yaml  @DataDog/apm-python
ddtrace/appsec/_common_module_patches.py                                @DataDog/asm-python
ddtrace/appsec/_iast/_iast_request_context.py                           @DataDog/asm-python

@christophe-papazian christophe-papazian changed the title fix(asm): make sure iast is not loaded by exploit prevention if disabled. fix(asm): make sure iast is not loaded by exploit prevention if disabled Feb 3, 2025
@christophe-papazian christophe-papazian added the ASM Application Security Monitoring label Feb 3, 2025
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 11.18421% with 135 lines in your changes missing coverage. Please review.

Please upload report for BASE (3.x-staging@4d20460). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...appsec/integrations/flask_tests/test_iast_flask.py 0.00% 36 Missing ⚠️
...tegrations/django_tests/test_django_appsec_iast.py 0.00% 31 Missing ⚠️
ddtrace/appsec/_common_module_patches.py 25.92% 20 Missing ⚠️
ddtrace/appsec/_iast/_handlers.py 0.00% 17 Missing ⚠️
tests/contrib/dbapi/test_dbapi_appsec.py 0.00% 6 Missing ⚠️
ddtrace/appsec/_iast/_pytest_plugin.py 0.00% 3 Missing ⚠️
ddtrace/settings/asm.py 25.00% 3 Missing ⚠️
...appsec/iast/fixtures/integration/main_configure.py 0.00% 3 Missing ⚠️
ddtrace/appsec/_iast/_iast_request_context.py 60.00% 2 Missing ⚠️
ddtrace/appsec/_iast/_loader.py 0.00% 2 Missing ⚠️
... and 8 more
Additional details and impacted files
@@              Coverage Diff               @@
##             3.x-staging   #12198   +/-   ##
==============================================
  Coverage               ?    8.85%           
==============================================
  Files                  ?     1598           
  Lines                  ?   134811           
  Branches               ?        0           
==============================================
  Hits                   ?    11942           
  Misses                 ?   122869           
  Partials               ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@christophe-papazian christophe-papazian marked this pull request as ready for review February 3, 2025 16:19
@christophe-papazian christophe-papazian requested review from a team as code owners February 3, 2025 16:19
Comment thread ddtrace/appsec/_common_module_patches.py Outdated
@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Feb 3, 2025

Benchmarks

Benchmark execution time: 2025-02-03 17:33:12

Comparing candidate commit 7cf5404 in PR branch christophe-papazian/exploit_prevention_on_windows with baseline commit 1419b2f in branch 3.x-staging.

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

Comment thread ddtrace/appsec/_common_module_patches.py
Co-authored-by: Ramy Elkest <4thkest@gmail.com>
@christophe-papazian christophe-papazian enabled auto-merge (squash) February 3, 2025 16:44
@christophe-papazian christophe-papazian merged commit 362fa22 into 3.x-staging Feb 3, 2025
@christophe-papazian christophe-papazian deleted the christophe-papazian/exploit_prevention_on_windows branch February 3, 2025 17:34
christophe-papazian added a commit that referenced this pull request Feb 7, 2025
Second part of #12198

- Ensure we don't load appsec modules if appsec is disabled or
unavailable (except for a few safe modules).
- Ensure we don't load iast modules if iast is disabled or unavailable.
- Ensure all initialisation logic for enable flags are handled in
ddtrace.settings.asm (small factorisation)
- Add test on module loading with a mini flask application in
`tests/appsec/integrations/flask_tests/test_appsec_loading_modules.py`,
checking with all possible combinations of appsec/iast/aws_lambda
enabled or disabled.
- remove dead code in `ddtrace/contrib/internal/langchain/patch.py`

APPSEC-56626

(should be backported to 3.0 when possible)

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
github-actions Bot pushed a commit that referenced this pull request Feb 7, 2025
Second part of #12198

- Ensure we don't load appsec modules if appsec is disabled or
unavailable (except for a few safe modules).
- Ensure we don't load iast modules if iast is disabled or unavailable.
- Ensure all initialisation logic for enable flags are handled in
ddtrace.settings.asm (small factorisation)
- Add test on module loading with a mini flask application in
`tests/appsec/integrations/flask_tests/test_appsec_loading_modules.py`,
checking with all possible combinations of appsec/iast/aws_lambda
enabled or disabled.
- remove dead code in `ddtrace/contrib/internal/langchain/patch.py`

APPSEC-56626

(should be backported to 3.0 when possible)

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

(cherry picked from commit fa18def)
christophe-papazian added a commit that referenced this pull request Feb 7, 2025
Backport fa18def from #12212 to 3.0.

Second part of #12198

- Ensure we don't load appsec modules if appsec is disabled or
unavailable (except for a few safe modules).
- Ensure we don't load iast modules if iast is disabled or unavailable.
- Ensure all initialisation logic for enable flags are handled in
ddtrace.settings.asm (small factorisation)
- Add test on module loading with a mini flask application in
`tests/appsec/integrations/flask_tests/test_appsec_loading_modules.py`,
checking with all possible combinations of appsec/iast/aws_lambda
enabled or disabled.
- remove dead code in `ddtrace/contrib/internal/langchain/patch.py`

APPSEC-56626

(should be backported to 3.0 when possible)

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Christophe Papazian <114495376+christophe-papazian@users.noreply.github.com>
Co-authored-by: Christophe Papazian <christophe.papazian@datadoghq.com>
github-actions Bot pushed a commit that referenced this pull request Feb 10, 2025
…led (#12198)

Make sure, if iast is disabled, that we don't load any iast modules in
the common module mechanism used both by iast and exploit prevention.

APPSEC-56659

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Ramy Elkest <4thkest@gmail.com>
(cherry picked from commit 362fa22)
avara1986 pushed a commit that referenced this pull request Feb 13, 2025
Second part of #12198

- Ensure we don't load appsec modules if appsec is disabled or
unavailable (except for a few safe modules).
- Ensure we don't load iast modules if iast is disabled or unavailable.
- Ensure all initialisation logic for enable flags are handled in
ddtrace.settings.asm (small factorisation)
- Add test on module loading with a mini flask application in
`tests/appsec/integrations/flask_tests/test_appsec_loading_modules.py`,
checking with all possible combinations of appsec/iast/aws_lambda
enabled or disabled.
- remove dead code in `ddtrace/contrib/internal/langchain/patch.py`

APPSEC-56626

(should be backported to 3.0 when possible)

- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

(cherry picked from commit fa18def)
@github-actions
Copy link
Copy Markdown
Contributor

The backport to 2.19 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.19 2.19
# Navigate to the new working tree
cd .worktrees/backport-2.19
# Create a new branch
git switch --create backport-12198-to-2.19
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 362fa22be2f7f6b61b023adb2aa56949aa163210
# Push it to GitHub
git push --set-upstream origin backport-12198-to-2.19
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.19

Then, create a pull request where the base branch is 2.19 and the compare/head branch is backport-12198-to-2.19.

avara1986 pushed a commit that referenced this pull request Feb 14, 2025
…led (#12198)

Make sure, if iast is disabled, that we don't load any iast modules in
the common module mechanism used both by iast and exploit prevention.

APPSEC-56659

- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Ramy Elkest <4thkest@gmail.com>
(cherry picked from commit 362fa22)
juanjux added a commit that referenced this pull request Feb 14, 2025
## Description

PR #12198 had the unintended consequence of not honoring
`DD_IAST_ENABLED` if set after the `_common_module_patches.py` was
evaluated. This make some tests (`ssrf` and probably others) to not run.
This fixes the problem by moving `is_iast_request_enabled` and
`_IAST_CONTEXT` to `asm_config`.


## Checklist
- [X] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Signed-off-by: Juanjo Alvarez <juanjo.alvarezmartinez@datadoghq.com>
avara1986 added a commit that referenced this pull request Feb 14, 2025
…led [backport 2.19] (#12352)

backport #12198 to 2.19

Make sure, if iast is disabled, that we don't load any iast modules in
the common module mechanism used both by iast and exploit prevention.

APPSEC-56659

Co-authored-by: Ramy Elkest <4thkest@gmail.com>
(cherry picked from commit 362fa22)

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Christophe Papazian <114495376+christophe-papazian@users.noreply.github.com>
gnufede pushed a commit that referenced this pull request Feb 19, 2025
…led (#12198)

Make sure, if iast is disabled, that we don't load any iast modules in
the common module mechanism used both by iast and exploit prevention.

APPSEC-56659

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Ramy Elkest <4thkest@gmail.com>
gnufede pushed a commit that referenced this pull request Feb 19, 2025
Second part of #12198

- Ensure we don't load appsec modules if appsec is disabled or
unavailable (except for a few safe modules).
- Ensure we don't load iast modules if iast is disabled or unavailable.
- Ensure all initialisation logic for enable flags are handled in
ddtrace.settings.asm (small factorisation)
- Add test on module loading with a mini flask application in
`tests/appsec/integrations/flask_tests/test_appsec_loading_modules.py`,
checking with all possible combinations of appsec/iast/aws_lambda
enabled or disabled.
- remove dead code in `ddtrace/contrib/internal/langchain/patch.py`

APPSEC-56626

(should be backported to 3.0 when possible)

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
gnufede pushed a commit that referenced this pull request Feb 19, 2025
## Description

PR #12198 had the unintended consequence of not honoring
`DD_IAST_ENABLED` if set after the `_common_module_patches.py` was
evaluated. This make some tests (`ssrf` and probably others) to not run.
This fixes the problem by moving `is_iast_request_enabled` and
`_IAST_CONTEXT` to `asm_config`.


## Checklist
- [X] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Signed-off-by: Juanjo Alvarez <juanjo.alvarezmartinez@datadoghq.com>
RamyElkest pushed a commit that referenced this pull request Feb 20, 2025
## Description

PR #12198 had the unintended consequence of not honoring
`DD_IAST_ENABLED` if set after the `_common_module_patches.py` was
evaluated. This make some tests (`ssrf` and probably others) to not run.
This fixes the problem by moving `is_iast_request_enabled` and
`_IAST_CONTEXT` to `asm_config`.


## Checklist
- [X] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Signed-off-by: Juanjo Alvarez <juanjo.alvarezmartinez@datadoghq.com>
avara1986 pushed a commit that referenced this pull request Mar 17, 2025
PR #12198 had the unintended consequence of not honoring
`DD_IAST_ENABLED` if set after the `_common_module_patches.py` was
evaluated. This make some tests (`ssrf` and probably others) to not run.
This fixes the problem by moving `is_iast_request_enabled` and
`_IAST_CONTEXT` to `asm_config`.

- [X] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Signed-off-by: Juanjo Alvarez <juanjo.alvarezmartinez@datadoghq.com>
(cherry picked from commit 3940332)
avara1986 added a commit that referenced this pull request Mar 17, 2025
Backport # 12323 to 2.21


## Description

PR #12198 had the unintended consequence of not honoring
`DD_IAST_ENABLED` if set after the `_common_module_patches.py` was
evaluated. This make some tests (`ssrf` and probably others) to not run.
This fixes the problem by moving `is_iast_request_enabled` and
`_IAST_CONTEXT` to `asm_config`.


## Checklist
- [X] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

Co-authored-by: Juanjo Alvarez Martinez <juanjo.alvarezmartinez@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ASM Application Security Monitoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants