Skip to content

Conversation

avara1986
Copy link
Member

@avara1986 avara1986 commented Apr 3, 2025

Backport #13021 to 2.21

This PR improves the AST patching allowlist mechanism to better handle third-party modules. The changes include:

  • Enhanced allowlist logic in iastpatch.c for third-party module detection
  • Improved string comparison in AST patching to properly handle module paths

These changes make the IAST module patching more reliable and maintainable, while ensuring proper handling of third-party modules like psycopg2.

Related to: APPSEC-56946 &
#13017

(cherry picked from commit 0b25c11)

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

This PR improves the AST patching allowlist mechanism to better handle
third-party modules. The changes include:

- Enhanced allowlist logic in iastpatch.c for third-party module
detection
- Improved string comparison in AST patching to properly handle module
paths

These changes make the IAST module patching more reliable and
maintainable, while ensuring proper handling of third-party modules like
psycopg2.

Related to: APPSEC-56946 &
#13017

- [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 0b25c11)
@avara1986 avara1986 added changelog/no-changelog A changelog entry is not required for this PR. ASM Application Security Monitoring labels Apr 3, 2025
Copy link
Contributor

github-actions bot commented Apr 3, 2025

CODEOWNERS have been resolved as:

ddtrace/appsec/_iast/_ast/iastpatch.c                                   @DataDog/asm-python
tests/appsec/iast/_ast/test_ast_patching.py                             @DataDog/asm-python
tests/appsec/iast/conftest.py                                           @DataDog/asm-python
tests/appsec/iast/iast_utils.py                                         @DataDog/asm-python
tests/appsec/iast/test_env_var.py                                       @DataDog/asm-python
tests/appsec/iast/test_iast_propagation_path.py                         @DataDog/asm-python
tests/appsec/iast_packages/test_packages.py                             @DataDog/asm-python

@pr-commenter
Copy link

pr-commenter bot commented Apr 3, 2025

Benchmarks

Benchmark execution time: 2025-04-03 12:03:00

Comparing candidate commit dd6907b in PR branch backport-13021-to-2.21 with baseline commit 8015b10 in branch 2.21.

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

@avara1986 avara1986 marked this pull request as ready for review April 3, 2025 11:52
@avara1986 avara1986 requested a review from a team as a code owner April 3, 2025 11:52
@avara1986 avara1986 merged commit 502a758 into 2.21 Apr 3, 2025
371 of 372 checks passed
@avara1986 avara1986 deleted the backport-13021-to-2.21 branch April 3, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASM Application Security Monitoring changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants