From becdcafdce541c937ee5237a23fc240c38b07d37 Mon Sep 17 00:00:00 2001 From: gousaiyang Date: Tue, 6 Apr 2021 18:12:30 -0700 Subject: [PATCH 1/2] bpo-43756: Add new audit event to incorporate new arguments added to glob.glob --- Doc/library/glob.rst | 9 ++++++++- Lib/glob.py | 1 + .../Security/2021-04-06-18-07-48.bpo-43756.DLBNqQ.rst | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Security/2021-04-06-18-07-48.bpo-43756.DLBNqQ.rst diff --git a/Doc/library/glob.rst b/Doc/library/glob.rst index 3fdba6937c1de0..0ed76167264a36 100644 --- a/Doc/library/glob.rst +++ b/Doc/library/glob.rst @@ -65,6 +65,7 @@ For example, ``'[?]'`` matches the character ``'?'``. match. .. audit-event:: glob.glob pathname,recursive glob.glob + .. audit-event:: glob.glob/2 pathname,root_dir,dir_fd,recursive glob.glob .. note:: Using the "``**``" pattern in large directory trees may consume @@ -83,6 +84,13 @@ For example, ``'[?]'`` matches the character ``'?'``. without actually storing them all simultaneously. .. audit-event:: glob.glob pathname,recursive glob.iglob + .. audit-event:: glob.glob/2 pathname,root_dir,dir_fd,recursive glob.iglob + + .. versionchanged:: 3.5 + Support for recursive globs using "``**``". + + .. versionchanged:: 3.10 + Added the *root_dir* and *dir_fd* parameters. .. function:: escape(pathname) @@ -128,4 +136,3 @@ default. For example, consider a directory containing :file:`card.gif` and Module :mod:`fnmatch` Shell-style filename (not path) expansion - diff --git a/Lib/glob.py b/Lib/glob.py index a491363f3f9395..e2687dc585e079 100644 --- a/Lib/glob.py +++ b/Lib/glob.py @@ -34,6 +34,7 @@ def iglob(pathname, *, root_dir=None, dir_fd=None, recursive=False): zero or more directories and subdirectories. """ sys.audit("glob.glob", pathname, recursive) + sys.audit("glob.glob/2", pathname, root_dir, dir_fd, recursive) if root_dir is not None: root_dir = os.fspath(root_dir) else: diff --git a/Misc/NEWS.d/next/Security/2021-04-06-18-07-48.bpo-43756.DLBNqQ.rst b/Misc/NEWS.d/next/Security/2021-04-06-18-07-48.bpo-43756.DLBNqQ.rst new file mode 100644 index 00000000000000..e05fef2d5524ff --- /dev/null +++ b/Misc/NEWS.d/next/Security/2021-04-06-18-07-48.bpo-43756.DLBNqQ.rst @@ -0,0 +1,2 @@ +Add new audit event ``glob.glob/2`` to incorporate the new *root_dir* and +*dir_fd* arguments added to :func:`glob.glob` and :func:`glob.iglob`. From 72344e7c0ae85190c3276acf957fd204420dec26 Mon Sep 17 00:00:00 2001 From: gousaiyang Date: Wed, 7 Apr 2021 10:52:56 -0700 Subject: [PATCH 2/2] Append new arguments at the end --- Doc/library/glob.rst | 4 ++-- Lib/glob.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/glob.rst b/Doc/library/glob.rst index 0ed76167264a36..215f60d328c76a 100644 --- a/Doc/library/glob.rst +++ b/Doc/library/glob.rst @@ -65,7 +65,7 @@ For example, ``'[?]'`` matches the character ``'?'``. match. .. audit-event:: glob.glob pathname,recursive glob.glob - .. audit-event:: glob.glob/2 pathname,root_dir,dir_fd,recursive glob.glob + .. audit-event:: glob.glob/2 pathname,recursive,root_dir,dir_fd glob.glob .. note:: Using the "``**``" pattern in large directory trees may consume @@ -84,7 +84,7 @@ For example, ``'[?]'`` matches the character ``'?'``. without actually storing them all simultaneously. .. audit-event:: glob.glob pathname,recursive glob.iglob - .. audit-event:: glob.glob/2 pathname,root_dir,dir_fd,recursive glob.iglob + .. audit-event:: glob.glob/2 pathname,recursive,root_dir,dir_fd glob.iglob .. versionchanged:: 3.5 Support for recursive globs using "``**``". diff --git a/Lib/glob.py b/Lib/glob.py index e2687dc585e079..a6cff873508266 100644 --- a/Lib/glob.py +++ b/Lib/glob.py @@ -34,7 +34,7 @@ def iglob(pathname, *, root_dir=None, dir_fd=None, recursive=False): zero or more directories and subdirectories. """ sys.audit("glob.glob", pathname, recursive) - sys.audit("glob.glob/2", pathname, root_dir, dir_fd, recursive) + sys.audit("glob.glob/2", pathname, recursive, root_dir, dir_fd) if root_dir is not None: root_dir = os.fspath(root_dir) else: