From: Jason R. Coombs Date: Sun, 23 Jan 2022 04:00:23 +0000 (-0500) Subject: bpo-46474: Avoid REDoS in EntryPoint.pattern (sync with importlib_metadata 4.10.1... X-Git-Tag: v3.11.0a5~133 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=51c3e28c8a163e58dc753765e3cc51d5a717e70d;p=thirdparty%2FPython%2Fcpython.git bpo-46474: Avoid REDoS in EntryPoint.pattern (sync with importlib_metadata 4.10.1) (GH-30803) --- diff --git a/Lib/importlib/metadata/__init__.py b/Lib/importlib/metadata/__init__.py index 5ef6d9dc4893..371c48220958 100644 --- a/Lib/importlib/metadata/__init__.py +++ b/Lib/importlib/metadata/__init__.py @@ -156,8 +156,8 @@ class EntryPoint(DeprecatedTuple): pattern = re.compile( r'(?P[\w.]+)\s*' - r'(:\s*(?P[\w.]+))?\s*' - r'(?P\[.*\])?\s*$' + r'(:\s*(?P[\w.]+)\s*)?' + r'((?P\[.*\])\s*)?$' ) """ A regular expression describing the syntax for an entry point, diff --git a/Misc/NEWS.d/next/Library/2022-01-22-14-49-10.bpo-46474.eKQhvx.rst b/Misc/NEWS.d/next/Library/2022-01-22-14-49-10.bpo-46474.eKQhvx.rst new file mode 100644 index 000000000000..156b7de4f678 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-01-22-14-49-10.bpo-46474.eKQhvx.rst @@ -0,0 +1,2 @@ +In ``importlib.metadata.EntryPoint.pattern``, avoid potential REDoS by +limiting ambiguity in consecutive whitespace.