Skip to content

Commit e632119

Browse files
github-actions[bot]juanjuxgnufede
authored
fix(iast): add more modules to the IAST patching denylist to improve startup time [backport 2.18] (#11909)
Backport 30e3b76 from #11907 to 2.18. ## Description Adds a bunch of image handling, scientific/numerical computing, linting and other modules where propagation doesn't matter to the IAST denylist. ## 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 <[email protected]> Co-authored-by: Federico Mon <[email protected]>
1 parent 0a56ee9 commit e632119

File tree

3 files changed

+99
-46
lines changed

3 files changed

+99
-46
lines changed

ddtrace/appsec/_iast/_ast/ast_patching.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,47 @@
2828
# Prefixes for modules where IAST patching is allowed
2929
IAST_ALLOWLIST: Tuple[Text, ...] = ("tests.appsec.iast.",)
3030
IAST_DENYLIST: Tuple[Text, ...] = (
31+
"altgraph.",
32+
"dipy.",
33+
"black.",
34+
"mypy.",
35+
"mypy_extensions.",
36+
"autopep8.",
37+
"pycodestyle.",
38+
"pydicom.",
39+
"pyinstaller.",
40+
"pystray.",
41+
"contourpy.",
42+
"cx_logging.",
43+
"dateutil.",
44+
"pytz.",
45+
"wcwidth.",
46+
"win32ctypes.",
47+
"xlib.",
48+
"cycler.",
49+
"cython.",
50+
"dnspython.",
51+
"elasticdeform.",
52+
"numpy.",
53+
"matplotlib.",
54+
"skbase.",
55+
"scipy.",
56+
"networkx.",
57+
"imageio.",
58+
"fonttools.",
59+
"nibabel.",
60+
"nilearn.",
61+
"gprof2dot.",
62+
"h5py.",
63+
"kiwisolver.",
64+
"pandas.",
65+
"pdf2image.",
66+
"pefile.",
67+
"pil.",
68+
"threadpoolctl.",
69+
"tifffile.",
70+
"tqdm.",
71+
"trx.",
3172
"flask.",
3273
"werkzeug.",
3374
"aiohttp._helpers.",
@@ -111,6 +152,7 @@
111152
"difflib.",
112153
"dill.info.",
113154
"dill.settings.",
155+
"silk.", # django-silk package
114156
"django.apps.config.",
115157
"django.apps.registry.",
116158
"django.conf.",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
fixes:
3+
- |
4+
Add more modules to the IAST patching denylist to improve startup time

tests/appsec/iast_packages/test_packages.py

Lines changed: 53 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -402,16 +402,17 @@ def uninstall(self, python_cmd):
402402
import_module_to_validate="multidict._multidict_py",
403403
test_propagation=True,
404404
),
405+
## Skip due to numpy added to the denylist
405406
# Python 3.12 fails in all steps with "import error" when import numpy
406-
PackageForTesting(
407-
"numpy",
408-
"1.24.4",
409-
"9 8 7 6 5 4 3",
410-
[3, 4, 5, 6, 7, 8, 9],
411-
5,
412-
skip_python_version=[(3, 12)],
413-
import_module_to_validate="numpy.core._internal",
414-
),
407+
# PackageForTesting(
408+
# "numpy",
409+
# "1.24.4",
410+
# "9 8 7 6 5 4 3",
411+
# [3, 4, 5, 6, 7, 8, 9],
412+
# 5,
413+
# skip_python_version=[(3, 12)],
414+
# import_module_to_validate="numpy.core._internal",
415+
# ),
415416
PackageForTesting(
416417
"oauthlib",
417418
"3.2.2",
@@ -430,8 +431,9 @@ def uninstall(self, python_cmd):
430431
{"is_version_valid": True, "requirement": "example-package>=1.0.0", "specifier": ">=1.0.0", "version": "1.2.3"},
431432
"",
432433
),
434+
## Skip due to pandas added to the denylist
433435
# Pandas dropped Python 3.8 support in pandas>2.0.3
434-
PackageForTesting("pandas", "2.2.2", "foobar", "Written value: foobar", "", skip_python_version=[(3, 8)]),
436+
# PackageForTesting("pandas", "2.2.2", "foobar", "Written value: foobar", "", skip_python_version=[(3, 8)]),
435437
PackageForTesting(
436438
"platformdirs",
437439
"4.2.2",
@@ -479,15 +481,16 @@ def uninstall(self, python_cmd):
479481
),
480482
# # TODO: patching Pytest fails: ImportError: cannot import name 'Dir' from '_pytest.main'
481483
# PackageForTesting("pytest", "8.2.1", "", "", "", test_e2e=False),
482-
PackageForTesting(
483-
"python-dateutil",
484-
"2.8.2",
485-
"Sat Oct 11 17:13:46 UTC 2003",
486-
"Sat, 11 Oct 2003 17:13:46 GMT",
487-
"And the Easter of that year is: 2004-04-11",
488-
import_name="dateutil",
489-
import_module_to_validate="dateutil.relativedelta",
490-
),
484+
## Skip due to python-dateutil added to the denylist
485+
# PackageForTesting(
486+
# "python-dateutil",
487+
# "2.8.2",
488+
# "Sat Oct 11 17:13:46 UTC 2003",
489+
# "Sat, 11 Oct 2003 17:13:46 GMT",
490+
# "And the Easter of that year is: 2004-04-11",
491+
# import_name="dateutil",
492+
# import_module_to_validate="dateutil.relativedelta",
493+
# ),
491494
PackageForTesting(
492495
"python-multipart",
493496
"0.0.5", # this version validates APPSEC-55240 issue, don't upgrade it
@@ -499,13 +502,14 @@ def uninstall(self, python_cmd):
499502
test_import=False,
500503
test_propagation=True,
501504
),
502-
PackageForTesting(
503-
"pytz",
504-
"2024.1",
505-
"America/New_York",
506-
"Current time in America/New_York: replaced_time",
507-
"",
508-
),
505+
## Skip due to pytz added to the denylist
506+
# PackageForTesting(
507+
# "pytz",
508+
# "2024.1",
509+
# "America/New_York",
510+
# "Current time in America/New_York: replaced_time",
511+
# "",
512+
# ),
509513
PackageForTesting(
510514
"PyYAML",
511515
"6.0.1",
@@ -584,7 +588,8 @@ def uninstall(self, python_cmd):
584588
"",
585589
import_module_to_validate="tomlkit.items",
586590
),
587-
PackageForTesting("tqdm", "4.66.4", "", "", "", test_e2e=False, import_module_to_validate="tqdm.std"),
591+
## Skip due to tqdm added to the denylist
592+
# PackageForTesting("tqdm", "4.66.4", "", "", "", test_e2e=False, import_module_to_validate="tqdm.std"),
588593
# Python 3.8 and 3.9 fail with ImportError: cannot import name 'get_host' from 'urllib3.util.url'
589594
PackageForTesting(
590595
"urllib3",
@@ -663,15 +668,16 @@ def uninstall(self, python_cmd):
663668
"",
664669
skip_python_version=[(3, 6), (3, 7), (3, 8)],
665670
),
666-
PackageForTesting(
667-
"pillow",
668-
"10.3.0",
669-
"Hello, Pillow!",
670-
"Image correctly generated",
671-
"",
672-
import_name="PIL.Image",
673-
skip_python_version=[(3, 6), (3, 7), (3, 8)],
674-
),
671+
## Skip due to pillow added to the denylist
672+
# PackageForTesting(
673+
# "pillow",
674+
# "10.3.0",
675+
# "Hello, Pillow!",
676+
# "Image correctly generated",
677+
# "",
678+
# import_name="PIL.Image",
679+
# skip_python_version=[(3, 6), (3, 7), (3, 8)],
680+
# ),
675681
PackageForTesting(
676682
"aiobotocore", "2.13.0", "", "", "", test_e2e=False, test_import=False, import_name="aiobotocore.session"
677683
),
@@ -745,16 +751,17 @@ def uninstall(self, python_cmd):
745751
"",
746752
test_e2e=False,
747753
),
748-
# scipy dropped Python 3.8 support in scipy > 1.10.1
749-
PackageForTesting(
750-
"scipy",
751-
"1.13.0",
752-
"1,2,3,4,5",
753-
"Mean: 3.0, Standard Deviation: 1.581",
754-
"",
755-
import_name="scipy.special",
756-
skip_python_version=[(3, 8)],
757-
),
754+
## Skip due to scipy added to the denylist
755+
# # scipy dropped Python 3.8 support in scipy > 1.10.1
756+
# PackageForTesting(
757+
# "scipy",
758+
# "1.13.0",
759+
# "1,2,3,4,5",
760+
# "Mean: 3.0, Standard Deviation: 1.581",
761+
# "",
762+
# import_name="scipy.special",
763+
# skip_python_version=[(3, 8)],
764+
# ),
758765
PackageForTesting(
759766
"iniconfig",
760767
"2.0.0",

0 commit comments

Comments
 (0)