Skip to content

Conversation

erikayasuda
Copy link
Contributor

@erikayasuda erikayasuda commented Jan 29, 2025

Forwardporting #12102

Depending of the timing, libddwaf loading process could create triggers that would create loops in our instrumentation.
From what I investigated:

  • if loaded too early, it could have bad interactions with gevent.
  • if loaded too late, it could be self instrumented by the tracer, creating a loop, as ctypes is using Popen and subprocess.

while keeping the late loading introduced by 2 previous PRs

(cherry picked from commit 4f0bcb5)

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

Depending of the timing, libddwaf loading process could create triggers
that would create loops in our instrumentation.
From what I investigated:
- if loaded too early, it could have bad interactions with gevent.
- if loaded too late, it could be self instrumented by the tracer,
creating a loop, as ctypes is using Popen and subprocess.

while keeping the late loading introduced by 2 previous PRs
- #11987
- #12013
this PR introduced a mechanism to bypass tracer instrumentation during
ctypes loading, to avoid a possible loop that would prevent the WAF to
be loaded.

## 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 4f0bcb5)
@erikayasuda erikayasuda added the changelog/no-changelog A changelog entry is not required for this PR. label Jan 29, 2025
@erikayasuda erikayasuda requested a review from a team as a code owner January 29, 2025 16:55
Copy link
Contributor

CODEOWNERS have been resolved as:

ddtrace/appsec/_ddwaf/ddwaf_types.py                                    @DataDog/asm-python
ddtrace/appsec/_processor.py                                            @DataDog/asm-python
ddtrace/contrib/internal/subprocess/patch.py                            @DataDog/asm-python
ddtrace/settings/asm.py                                                 @DataDog/asm-python

@datadog-dd-trace-py-rkomorn
Copy link

Datadog Report

Branch report: backport-12102-to-3.x
Commit report: 1008266
Test service: dd-trace-py

✅ 0 Failed, 130 Passed, 1378 Skipped, 4m 50.82s Total duration (35m 5.93s time saved)

@pr-commenter
Copy link

pr-commenter bot commented Jan 29, 2025

Benchmarks

Benchmark execution time: 2025-01-29 17:39:10

Comparing candidate commit 1008266 in PR branch backport-12102-to-3.x with baseline commit 3337560 in branch 3.x-staging.

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

@gnufede gnufede added the ASM Application Security Monitoring label Jan 30, 2025
@christophe-papazian christophe-papazian merged commit 03e7cf8 into 3.x-staging Jan 30, 2025
626 checks passed
@christophe-papazian christophe-papazian deleted the backport-12102-to-3.x branch January 30, 2025 09:29
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.

3 participants