Skip to content

Commit 35ab4b7

Browse files
gnufedejuanjux
andauthored
chore(asm): iast discover customer code to patch (#5420)
IAST: discover if module is customer code or stdlib, third-party, etc in order to avoid patching the latter. Also: Fixes a problem with module docstrings to find aspect import position ## 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] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/contributing.html#Release-Note-Guidelines) are followed. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] Author is aware of the performance implications of this PR as reported in the benchmarks PR comment. ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer is aware of, and discussed the performance implications of this PR as reported in the benchmarks PR comment. --------- Co-authored-by: Juanjo Alvarez Martinez <[email protected]>
1 parent f43af93 commit 35ab4b7

File tree

14 files changed

+1418
-23
lines changed

14 files changed

+1418
-23
lines changed

ddtrace/appsec/_python_info/__init__.py

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python3
2+
3+
from sys import version_info
4+
5+
6+
if version_info < (3, 7, 0):
7+
from .module_names_py36 import STDLIB_MODULE_NAMES
8+
elif version_info < (3, 8, 0):
9+
from .module_names_py37 import STDLIB_MODULE_NAMES
10+
elif version_info < (3, 9, 0):
11+
from .module_names_py38 import STDLIB_MODULE_NAMES
12+
elif version_info < (3, 10, 0):
13+
from .module_names_py39 import STDLIB_MODULE_NAMES
14+
elif version_info < (3, 11, 0):
15+
from .module_names_py310 import STDLIB_MODULE_NAMES
16+
else:
17+
from .module_names_py311 import STDLIB_MODULE_NAMES
18+
19+
20+
def _stdlib_for_python_version(): # type: () -> set
21+
return STDLIB_MODULE_NAMES
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
STDLIB_MODULE_NAMES = {
2+
"_ast",
3+
"_thread",
4+
"abc",
5+
"aifc",
6+
"argparse",
7+
"array",
8+
"ast",
9+
"asynchat",
10+
"asyncio",
11+
"asyncore",
12+
"atexit",
13+
"audioop",
14+
"base64",
15+
"bdb",
16+
"binascii",
17+
"binhex",
18+
"bisect",
19+
"builtins",
20+
"bz2",
21+
"cProfile",
22+
"calendar",
23+
"cgi",
24+
"cgitb",
25+
"chunk",
26+
"cmath",
27+
"cmd",
28+
"code",
29+
"codecs",
30+
"codeop",
31+
"collections",
32+
"colorsys",
33+
"compileall",
34+
"concurrent",
35+
"configparser",
36+
"contextlib",
37+
"contextvars",
38+
"copy",
39+
"copyreg",
40+
"crypt",
41+
"csv",
42+
"ctypes",
43+
"curses",
44+
"dataclasses",
45+
"datetime",
46+
"dbm",
47+
"decimal",
48+
"difflib",
49+
"dis",
50+
"distutils",
51+
"doctest",
52+
"email",
53+
"encodings",
54+
"ensurepip",
55+
"enum",
56+
"errno",
57+
"faulthandler",
58+
"fcntl",
59+
"filecmp",
60+
"fileinput",
61+
"fnmatch",
62+
"fractions",
63+
"ftplib",
64+
"functools",
65+
"gc",
66+
"getopt",
67+
"getpass",
68+
"gettext",
69+
"glob",
70+
"graphlib",
71+
"grp",
72+
"gzip",
73+
"hashlib",
74+
"heapq",
75+
"hmac",
76+
"html",
77+
"http",
78+
"idlelib",
79+
"imaplib",
80+
"imghdr",
81+
"imp",
82+
"importlib",
83+
"inspect",
84+
"io",
85+
"ipaddress",
86+
"itertools",
87+
"json",
88+
"keyword",
89+
"lib2to3",
90+
"linecache",
91+
"locale",
92+
"logging",
93+
"lzma",
94+
"mailbox",
95+
"mailcap",
96+
"marshal",
97+
"math",
98+
"mimetypes",
99+
"mmap",
100+
"modulefinder",
101+
"msilib",
102+
"msvcrt",
103+
"multiprocessing",
104+
"netrc",
105+
"nis",
106+
"nntplib",
107+
"ntpath",
108+
"numbers",
109+
"operator",
110+
"optparse",
111+
"os",
112+
"ossaudiodev",
113+
"pathlib",
114+
"pdb",
115+
"pickle",
116+
"pickletools",
117+
"pipes",
118+
"pkgutil",
119+
"platform",
120+
"plistlib",
121+
"poplib",
122+
"posix",
123+
"posixpath",
124+
"pprint",
125+
"profile",
126+
"pstats",
127+
"pty",
128+
"pwd",
129+
"py_compile",
130+
"pyclbr",
131+
"pydoc",
132+
"queue",
133+
"quopri",
134+
"random",
135+
"re",
136+
"readline",
137+
"reprlib",
138+
"resource",
139+
"rlcompleter",
140+
"runpy",
141+
"sched",
142+
"secrets",
143+
"select",
144+
"selectors",
145+
"shelve",
146+
"shlex",
147+
"shutil",
148+
"signal",
149+
"site",
150+
"smtpd",
151+
"smtplib",
152+
"sndhdr",
153+
"socket",
154+
"socketserver",
155+
"spwd",
156+
"sqlite3",
157+
"sre",
158+
"sre_compile",
159+
"sre_constants",
160+
"sre_parse",
161+
"ssl",
162+
"stat",
163+
"statistics",
164+
"string",
165+
"stringprep",
166+
"struct",
167+
"subprocess",
168+
"sunau",
169+
"symtable",
170+
"sys",
171+
"sysconfig",
172+
"syslog",
173+
"tabnanny",
174+
"tarfile",
175+
"telnetlib",
176+
"tempfile",
177+
"termios",
178+
"test",
179+
"textwrap",
180+
"threading",
181+
"time",
182+
"timeit",
183+
"tkinter",
184+
"token",
185+
"tokenize",
186+
"trace",
187+
"traceback",
188+
"tracemalloc",
189+
"tty",
190+
"turtle",
191+
"turtledemo",
192+
"types",
193+
"typing",
194+
"unicodedata",
195+
"unittest",
196+
"urllib",
197+
"uu",
198+
"uuid",
199+
"venv",
200+
"warnings",
201+
"wave",
202+
"weakref",
203+
"webbrowser",
204+
"winreg",
205+
"winsound",
206+
"wsgiref",
207+
"xdrlib",
208+
"xml",
209+
"xmlrpc",
210+
"zipapp",
211+
"zipfile",
212+
"zipimport",
213+
"zlib",
214+
"zoneinfo",
215+
}

0 commit comments

Comments
 (0)