-
Notifications
You must be signed in to change notification settings - Fork 431
chore(iast): strip, rstrip, lstrip aspects #13266
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
base: main
Are you sure you want to change the base?
Conversation
|
Co-authored-by: datadog-datadog-prod-us1[bot] <88084959+datadog-datadog-prod-us1[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements new IAST aspects for Python’s string strip methods to ensure proper taint propagation during string manipulation and updates related tests, benchmarks, and patch modules. Key changes include:
- Adding and registering new aspects (strip, rstrip, lstrip) in ddtrace/appsec/_iast/_taint_tracking/aspects.py.
- Updating tests (in tests/appsec/iast/aspects and fixtures) to cover a variety of input cases, including edge cases and taint range validations.
- Adjusting patch module configurations, benchmarks, and C-level allowlists to integrate the new aspects.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
tests/appsec/integrations/packages_tests/test_iast_sanitizers.py | Added patch for werkzeug.utils to activate IAST propagation. |
tests/appsec/iast/fixtures/propagation_path.py | Updated test to apply successive strip operations and verify taint behavior. |
tests/appsec/iast/aspects/test_strip_aspect.py | Introduced comprehensive tests for strip, rstrip, and lstrip aspects. |
scripts/iast/mod_leak_functions.py | Modified string manipulation and propagation logic to use the new aspects. |
ddtrace/appsec/_iast/_taint_tracking/aspects.py | Added implementations for lstrip, rstrip, and strip aspects with taint range adjustments. |
ddtrace/appsec/_iast/_patch_modules.py | Updated comment regarding safe_join propagation to reflect new limitations. |
ddtrace/appsec/_iast/_ast/visitor.py | Registered the new strip-related aspects. |
ddtrace/appsec/_iast/_ast/iastpatch.c | Expanded the static allowlist to include werkzeug.utils. |
benchmarks/appsec_iast_aspects/functions.py & config.yaml | Added functions and configuration blocks for new aspects. |
Comments suppressed due to low confidence (1)
scripts/iast/mod_leak_functions.py:311
- [nitpick] Consider renaming variables like 'string13_3' to more descriptive names to improve code clarity.
string13_3 = string13_2.strip()
Bootstrap import analysisComparison of import times between this PR and base. SummaryThe average import time from this PR is: 238 ± 4 ms. The average import time from base is: 242 ± 5 ms. The import time difference between this PR and base is: -4.5 ± 0.2 ms. Import time breakdownThe following import paths have shrunk:
|
BenchmarksBenchmark execution time: 2025-04-25 17:22:02 Comparing candidate commit 93376c8 in PR branch Some scenarios are present only in baseline or only in candidate runs. If you didn't create or remove some scenarios in your branch, this maybe a sign of crashed benchmarks 💥💥💥 Scenarios present only in candidate:
Found 0 performance improvements and 0 performance regressions! Performance is the same for 486 metrics, 8 unstable metrics. |
This PR implements new aspects for Python's string strip methods (strip, rstrip, lstrip) to support IAST taint propagation. These aspects ensure proper taint tracking when string stripping operations are performed.
Motivation
Changes Made
Added new aspects in
ddtrace/appsec/_iast/_taint_tracking/aspects.py
:strip_aspect
: Handles both-ends string strippingrstrip_aspect
: Handles right-side string strippinglstrip_aspect
: Handles left-side string strippingEach aspect implementation:
Added comprehensive test coverage in
tests/appsec/iast/aspects/test_strip_aspect.py
:Checklist
Reviewer Checklist