Skip to content

Commit

Permalink
Merge branch '3.7' into tarfile-3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
ned-deily authored May 27, 2023
2 parents 64d1a92 + 1ce801b commit 773e47e
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 4 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,31 @@ jobs:
runs-on: macos-latest
needs: check_source
if: needs.check_source.outputs.run_tests == 'true'
env:
HOMEBREW_NO_ANALYTICS: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
steps:
- uses: actions/checkout@v2
- name: Configure CPython
run: SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk ./configure --with-pydebug --with-openssl=/usr/local/opt/openssl --prefix=/opt/python-dev
run: |
brew install pkg-config openssl@1.1 xz gdbm tcl-tk
brew install zlib bzip2 ncurses readline sqlite
SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk \
CC=clang \
CPPFLAGS="-I$(brew --prefix gdbm)/include -I$(brew --prefix xz)/include \
-I$(brew --prefix zlib)/include -I$(brew --prefix bzip2)/include \
-I$(brew --prefix ncurses)/include -I$(brew --prefix readline)/include \
-I$(brew --prefix sqlite)/include" \
LDFLAGS="-L$(brew --prefix gdbm)/lib -L$(brew --prefix xz)/lib \
-L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib \
-L$(brew --prefix ncurses)/lib -L$(brew --prefix readline)/lib \
-L$(brew --prefix sqlite)/lib" \
./configure --prefix=/opt/python-dev \
--with-pydebug \
--with-openssl="$(brew --prefix openssl@1.1)" \
--with-tcltk-libs="$(pkg-config --libs tk)" \
--with-tcltk-includes="$(pkg-config --cflags tk)"
- name: Build CPython
run: make -j4
- name: Display build info
Expand Down
2 changes: 1 addition & 1 deletion Lib/ensurepip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
__all__ = ["version", "bootstrap"]
_PACKAGE_NAMES = ('setuptools', 'pip')
_SETUPTOOLS_VERSION = "47.1.0"
_PIP_VERSION = "22.0.4"
_PIP_VERSION = "23.0.1"
_PROJECTS = [
("setuptools", _SETUPTOOLS_VERSION, "py3"),
("pip", _PIP_VERSION, "py3"),
Expand Down
Binary file removed Lib/ensurepip/_bundled/pip-22.0.4-py3-none-any.whl
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Lib/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ def list_directory(self, path):
displaypath = urllib.parse.unquote(self.path,
errors='surrogatepass')
except UnicodeDecodeError:
displaypath = urllib.parse.unquote(path)
displaypath = urllib.parse.unquote(self.path)
displaypath = html.escape(displaypath, quote=False)
enc = sys.getfilesystemencoding()
title = 'Directory listing for %s' % displaypath
Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_httpservers.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,14 @@ def test_undecodable_filename(self):
self.check_status_and_reason(response, HTTPStatus.OK,
data=support.TESTFN_UNDECODABLE)

def test_undecodable_parameter(self):
# sanity check using a valid parameter
response = self.request(self.base_url + '/?x=123').read()
self.assertRegex(response, f'listing for {self.base_url}/\?x=123'.encode('latin1'))
# now the bogus encoding
response = self.request(self.base_url + '/?x=%bb').read()
self.assertRegex(response, f'listing for {self.base_url}/\?x=\xef\xbf\xbd'.encode('latin1'))

def test_get_dir_redirect_location_domain_injection_bug(self):
"""Ensure //evil.co/..%2f../../X does not put //evil.co/ in Location.
Expand Down
28 changes: 28 additions & 0 deletions Lib/test/test_uu.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,34 @@ def test_newlines_escaped(self):
uu.encode(inp, out, filename)
self.assertIn(safefilename, out.getvalue())

def test_no_directory_traversal(self):
relative_bad = b"""\
begin 644 ../../../../../../../../tmp/test1
$86)C"@``
`
end
"""
with self.assertRaisesRegex(uu.Error, 'directory'):
uu.decode(io.BytesIO(relative_bad))
if os.altsep:
relative_bad_bs = relative_bad.replace(b'/', b'\\')
with self.assertRaisesRegex(uu.Error, 'directory'):
uu.decode(io.BytesIO(relative_bad_bs))

absolute_bad = b"""\
begin 644 /tmp/test2
$86)C"@``
`
end
"""
with self.assertRaisesRegex(uu.Error, 'directory'):
uu.decode(io.BytesIO(absolute_bad))
if os.altsep:
absolute_bad_bs = absolute_bad.replace(b'/', b'\\')
with self.assertRaisesRegex(uu.Error, 'directory'):
uu.decode(io.BytesIO(absolute_bad_bs))


class UUStdIOTest(unittest.TestCase):

def setUp(self):
Expand Down
9 changes: 8 additions & 1 deletion Lib/uu.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@ def decode(in_file, out_file=None, mode=None, quiet=False):
# If the filename isn't ASCII, what's up with that?!?
out_file = hdrfields[2].rstrip(b' \t\r\n\f').decode("ascii")
if os.path.exists(out_file):
raise Error('Cannot overwrite existing file: %s' % out_file)
raise Error(f'Cannot overwrite existing file: {out_file}')
if (out_file.startswith(os.sep) or
f'..{os.sep}' in out_file or (
os.altsep and
(out_file.startswith(os.altsep) or
f'..{os.altsep}' in out_file))
):
raise Error(f'Refusing to write to {out_file} due to directory traversal')
if mode is None:
mode = int(hdrfields[1], 8)
#
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade pip wheel bundled with ensurepip (pip 23.0.1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Do not expose the local on-disk location in directory indexes
produced by :class:`http.client.SimpleHTTPRequestHandler`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed a security in flaw in :func:`uu.decode` that could allow for
directory traversal based on the input if no ``out_file`` was specified.

0 comments on commit 773e47e

Please sign in to comment.