Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iast): None as module_path at astpatch_module #8973

Merged
merged 8 commits into from
Apr 15, 2024

Conversation

gnufede
Copy link
Member

@gnufede gnufede commented Apr 15, 2024

IAST: Fixes an issue where the AST patching process fails when the origin of a module is reported as None, raising a FileNotFoundError as follows:

Traceback (most recent call last):
  File "/Users/federico.mon/go/src/github.com/DataDog/dd-trace-py/ddtrace/appsec/_iast/_ast/ast_patching.py", line 130, in astpatch_module
    if os.stat(module_path).st_size == 0:
FileNotFoundError: [Errno 2] No such file or directory: 'None'

Checklist

  • Change(s) are motivated and described in the PR description
  • Testing strategy is described if automated tests are not included in the PR
  • Risks are described (performance impact, potential for breakage, maintainability)
  • Change is maintainable (easy to change, telemetry, documentation)
  • Library release note guidelines are followed or label changelog/no-changelog is set
  • Documentation is included (in-code, generated user docs, public corp docs)
  • Backport labels are set (if applicable)
  • If this PR changes the public interface, I've notified @DataDog/apm-tees.

Reviewer Checklist

  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Description motivates each change
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Change is maintainable (easy to change, telemetry, documentation)
  • Release note makes sense to a user of the library
  • 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

@gnufede gnufede marked this pull request as ready for review April 15, 2024 08:35
@gnufede gnufede requested review from a team as code owners April 15, 2024 08:35
@gnufede gnufede enabled auto-merge (squash) April 15, 2024 08:43
@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Apr 15, 2024

Datadog Report

Branch report: gnufede/APPSEC-52604-fix-none-module_path
Commit report: 80d1507
Test service: dd-trace-py

✅ 0 Failed, 615 Passed, 110988 Skipped, 17m 10.25s Total duration (1h 33m 54.89s time saved)

@pr-commenter
Copy link

pr-commenter bot commented Apr 15, 2024

Benchmarks

Benchmark execution time: 2024-04-15 09:39:02

Comparing candidate commit 40b3f2d in PR branch gnufede/APPSEC-52604-fix-none-module_path with baseline commit d7c368f in branch main.

Found 8 performance improvements and 1 performance regressions! Performance is the same for 192 metrics, 9 unstable metrics.

scenario:flasksimple-appsec-get

  • 🟩 execution_time [-243.641µs; -190.455µs] or [-3.746%; -2.928%]

scenario:httppropagationextract-datadog_tracecontext_tracestate_not_propagated_on_trace_id_no_match

  • 🟥 max_rss_usage [+695.502KB; +771.685KB] or [+3.287%; +3.646%]

scenario:httppropagationinject-ids_only

  • 🟩 max_rss_usage [-763.805KB; -700.105KB] or [-3.493%; -3.202%]

scenario:httppropagationinject-with_dd_origin

  • 🟩 max_rss_usage [-1.092MB; -1.035MB] or [-4.994%; -4.734%]

scenario:httppropagationinject-with_sampling_priority

  • 🟩 max_rss_usage [-773.732KB; -717.212KB] or [-3.538%; -3.280%]

scenario:httppropagationinject-with_tags

  • 🟩 max_rss_usage [-640.440KB; -585.903KB] or [-2.929%; -2.680%]

scenario:httppropagationinject-with_tags_invalid

  • 🟩 max_rss_usage [-632.202KB; -579.804KB] or [-2.893%; -2.653%]

scenario:httppropagationinject-with_tags_max_size

  • 🟩 max_rss_usage [-631.183KB; -574.269KB] or [-2.887%; -2.626%]

scenario:span-start-finish

  • 🟩 max_rss_usage [-738.405KB; -483.022KB] or [-3.380%; -2.211%]

@gnufede gnufede merged commit 0f4f240 into main Apr 15, 2024
80 of 81 checks passed
@gnufede gnufede deleted the gnufede/APPSEC-52604-fix-none-module_path branch April 15, 2024 10:14
github-actions bot pushed a commit that referenced this pull request Apr 15, 2024
IAST: Fixes an issue where the AST patching process fails when the
`origin` of a module is reported as None, raising a `FileNotFoundError`
as follows:

```python
Traceback (most recent call last):
  File "/Users/federico.mon/go/src/github.com/DataDog/dd-trace-py/ddtrace/appsec/_iast/_ast/ast_patching.py", line 130, in astpatch_module
    if os.stat(module_path).st_size == 0:
FileNotFoundError: [Errno 2] No such file or directory: 'None'
```

## Checklist

- [x] Change(s) are motivated and described in the PR description
- [x] Testing strategy is described if automated tests are not included
in the PR
- [x] Risks are described (performance impact, potential for breakage,
maintainability)
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed or label `changelog/no-changelog` is set
- [x] Documentation is included (in-code, generated user docs, [public
corp docs](https://github.com/DataDog/documentation/))
- [x] Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))
- [x] If this PR changes the public interface, I've notified
`@DataDog/apm-tees`.

## Reviewer Checklist

- [x] Title is accurate
- [x] All changes are related to the pull request's stated goal
- [x] Description motivates each change
- [x] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- [x] Testing strategy adequately addresses listed risks
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] Release note makes sense to a user of the library
- [x] Author has acknowledged and discussed the performance implications
of this PR as reported in the benchmarks PR comment
- [x] 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: Gabriele N. Tornetta <[email protected]>
(cherry picked from commit 0f4f240)
github-actions bot pushed a commit that referenced this pull request Apr 15, 2024
IAST: Fixes an issue where the AST patching process fails when the
`origin` of a module is reported as None, raising a `FileNotFoundError`
as follows:

```python
Traceback (most recent call last):
  File "/Users/federico.mon/go/src/github.com/DataDog/dd-trace-py/ddtrace/appsec/_iast/_ast/ast_patching.py", line 130, in astpatch_module
    if os.stat(module_path).st_size == 0:
FileNotFoundError: [Errno 2] No such file or directory: 'None'
```

## Checklist

- [x] Change(s) are motivated and described in the PR description
- [x] Testing strategy is described if automated tests are not included
in the PR
- [x] Risks are described (performance impact, potential for breakage,
maintainability)
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed or label `changelog/no-changelog` is set
- [x] Documentation is included (in-code, generated user docs, [public
corp docs](https://github.com/DataDog/documentation/))
- [x] Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))
- [x] If this PR changes the public interface, I've notified
`@DataDog/apm-tees`.

## Reviewer Checklist

- [x] Title is accurate
- [x] All changes are related to the pull request's stated goal
- [x] Description motivates each change
- [x] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- [x] Testing strategy adequately addresses listed risks
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] Release note makes sense to a user of the library
- [x] Author has acknowledged and discussed the performance implications
of this PR as reported in the benchmarks PR comment
- [x] 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: Gabriele N. Tornetta <[email protected]>
(cherry picked from commit 0f4f240)
github-actions bot pushed a commit that referenced this pull request Apr 15, 2024
IAST: Fixes an issue where the AST patching process fails when the
`origin` of a module is reported as None, raising a `FileNotFoundError`
as follows:

```python
Traceback (most recent call last):
  File "/Users/federico.mon/go/src/github.com/DataDog/dd-trace-py/ddtrace/appsec/_iast/_ast/ast_patching.py", line 130, in astpatch_module
    if os.stat(module_path).st_size == 0:
FileNotFoundError: [Errno 2] No such file or directory: 'None'
```

## Checklist

- [x] Change(s) are motivated and described in the PR description
- [x] Testing strategy is described if automated tests are not included
in the PR
- [x] Risks are described (performance impact, potential for breakage,
maintainability)
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed or label `changelog/no-changelog` is set
- [x] Documentation is included (in-code, generated user docs, [public
corp docs](https://github.com/DataDog/documentation/))
- [x] Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))
- [x] If this PR changes the public interface, I've notified
`@DataDog/apm-tees`.

## Reviewer Checklist

- [x] Title is accurate
- [x] All changes are related to the pull request's stated goal
- [x] Description motivates each change
- [x] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- [x] Testing strategy adequately addresses listed risks
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] Release note makes sense to a user of the library
- [x] Author has acknowledged and discussed the performance implications
of this PR as reported in the benchmarks PR comment
- [x] 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: Gabriele N. Tornetta <[email protected]>
(cherry picked from commit 0f4f240)
gnufede added a commit that referenced this pull request Apr 15, 2024
#8977)

Backport 0f4f240 from #8973 to 2.7.

IAST: Fixes an issue where the AST patching process fails when the
`origin` of a module is reported as None, raising a `FileNotFoundError`
as follows:

```python
Traceback (most recent call last):
  File "/Users/federico.mon/go/src/github.com/DataDog/dd-trace-py/ddtrace/appsec/_iast/_ast/ast_patching.py", line 130, in astpatch_module
    if os.stat(module_path).st_size == 0:
FileNotFoundError: [Errno 2] No such file or directory: 'None'
```

## Checklist

- [x] Change(s) are motivated and described in the PR description
- [x] Testing strategy is described if automated tests are not included
in the PR
- [x] Risks are described (performance impact, potential for breakage,
maintainability)
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed or label `changelog/no-changelog` is set
- [x] Documentation is included (in-code, generated user docs, [public
corp docs](https://github.com/DataDog/documentation/))
- [x] Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))
- [x] If this PR changes the public interface, I've notified
`@DataDog/apm-tees`.

## Reviewer Checklist

- [x] Title is accurate
- [x] All changes are related to the pull request's stated goal
- [x] Description motivates each change
- [x] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- [x] Testing strategy adequately addresses listed risks
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] Release note makes sense to a user of the library
- [x] Author has acknowledged and discussed the performance implications
of this PR as reported in the benchmarks PR comment
- [x] 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: Federico Mon <[email protected]>
gnufede added a commit that referenced this pull request Apr 15, 2024
#8976)

Backport 0f4f240 from #8973 to 2.6.

IAST: Fixes an issue where the AST patching process fails when the
`origin` of a module is reported as None, raising a `FileNotFoundError`
as follows:

```python
Traceback (most recent call last):
  File "/Users/federico.mon/go/src/github.com/DataDog/dd-trace-py/ddtrace/appsec/_iast/_ast/ast_patching.py", line 130, in astpatch_module
    if os.stat(module_path).st_size == 0:
FileNotFoundError: [Errno 2] No such file or directory: 'None'
```

## Checklist

- [x] Change(s) are motivated and described in the PR description
- [x] Testing strategy is described if automated tests are not included
in the PR
- [x] Risks are described (performance impact, potential for breakage,
maintainability)
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed or label `changelog/no-changelog` is set
- [x] Documentation is included (in-code, generated user docs, [public
corp docs](https://github.com/DataDog/documentation/))
- [x] Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))
- [x] If this PR changes the public interface, I've notified
`@DataDog/apm-tees`.

## Reviewer Checklist

- [x] Title is accurate
- [x] All changes are related to the pull request's stated goal
- [x] Description motivates each change
- [x] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- [x] Testing strategy adequately addresses listed risks
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] Release note makes sense to a user of the library
- [x] Author has acknowledged and discussed the performance implications
of this PR as reported in the benchmarks PR comment
- [x] 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: Federico Mon <[email protected]>
gnufede added a commit that referenced this pull request Apr 15, 2024
#8978)

Backport 0f4f240 from #8973 to 2.8.

IAST: Fixes an issue where the AST patching process fails when the
`origin` of a module is reported as None, raising a `FileNotFoundError`
as follows:

```python
Traceback (most recent call last):
  File "/Users/federico.mon/go/src/github.com/DataDog/dd-trace-py/ddtrace/appsec/_iast/_ast/ast_patching.py", line 130, in astpatch_module
    if os.stat(module_path).st_size == 0:
FileNotFoundError: [Errno 2] No such file or directory: 'None'
```

## Checklist

- [x] Change(s) are motivated and described in the PR description
- [x] Testing strategy is described if automated tests are not included
in the PR
- [x] Risks are described (performance impact, potential for breakage,
maintainability)
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed or label `changelog/no-changelog` is set
- [x] Documentation is included (in-code, generated user docs, [public
corp docs](https://github.com/DataDog/documentation/))
- [x] Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))
- [x] If this PR changes the public interface, I've notified
`@DataDog/apm-tees`.

## Reviewer Checklist

- [x] Title is accurate
- [x] All changes are related to the pull request's stated goal
- [x] Description motivates each change
- [x] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- [x] Testing strategy adequately addresses listed risks
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] Release note makes sense to a user of the library
- [x] Author has acknowledged and discussed the performance implications
of this PR as reported in the benchmarks PR comment
- [x] 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: Federico Mon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASM Application Security Monitoring backport 2.7 backport 2.8 bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants