55fde0
%bcond_without python3
55fde0
55fde0
%global srcname urllib3
55fde0
55fde0
Name:           python-%{srcname}
f594b0
Version:        1.24.2
f594b0
Release:        1%{?dist}
55fde0
Summary:        Python HTTP library with thread-safe connection pooling and file post
55fde0
55fde0
License:        MIT
55fde0
URL:            https://github.com/shazow/urllib3
55fde0
Source0:        %{url}/archive/%{version}/%{srcname}-%{version}.tar.gz
55fde0
# Used with Python 3.5+
55fde0
Source1:        ssl_match_hostname_py3.py
55fde0
BuildArch:      noarch
55fde0
f594b0
# CVE-2019-11236 python-urllib3:
f594b0
#   - CRLF injection due to not encoding the '\r\n' sequence leading to
f594b0
#     possible attack on internal service.
f594b0
#   - Also known as CVE-2019-9740 (duplicate entry)
f594b0
# Backported from:
f594b0
#  * https://github.com/urllib3/urllib3/pull/1591
f594b0
#    - Superfluous commits were omitted (flake8 checks, travis settings, macos patch)
f594b0
#  * https://github.com/urllib3/urllib3/pull/1593
f594b0
Patch1:         CVE-2019-11236.patch
f594b0
f594b0
55fde0
%description
55fde0
Python HTTP module with connection pooling and file POST abilities.
55fde0
55fde0
%package -n python2-%{srcname}
55fde0
Summary:        Python2 HTTP library with thread-safe connection pooling and file post
55fde0
%{?python_provide:%python_provide python2-%{srcname}}
55fde0
55fde0
Requires:       ca-certificates
55fde0
55fde0
# Previously bundled things:
55fde0
Requires:       python2-six
55fde0
Requires:       python2-backports-ssl_match_hostname
55fde0
55fde0
# Secure extra requirements
55fde0
Requires:       python2-ipaddress
55fde0
Requires:       python2-pysocks
55fde0
55fde0
BuildRequires:  python2-devel
55fde0
55fde0
# For tests
55fde0
BuildRequires:  python2-pytest
55fde0
BuildRequires:  python2-mock
55fde0
BuildRequires:  python2-pysocks
f594b0
BuildRequires:  python2-backports-ssl_match_hostname
55fde0
55fde0
%description -n python2-%{srcname}
55fde0
Python2 HTTP module with connection pooling and file POST abilities.
55fde0
55fde0
55fde0
%if %{with python3}
55fde0
%package -n python3-%{srcname}
55fde0
Summary:        Python3 HTTP library with thread-safe connection pooling and file post
55fde0
55fde0
BuildRequires:  python3-devel
55fde0
# For unittests
55fde0
BuildRequires:  python3-mock
55fde0
BuildRequires:  python3-six
55fde0
BuildRequires:  python3-pysocks
55fde0
BuildRequires:  python3-pytest
55fde0
55fde0
Requires:       ca-certificates
55fde0
Requires:       python3-six
55fde0
Requires:       python3-pysocks
55fde0
55fde0
%description -n python3-%{srcname}
55fde0
Python3 HTTP module with connection pooling and file POST abilities.
55fde0
55fde0
%endif
55fde0
55fde0
%prep
55fde0
%setup -q -n %{srcname}-%{version}
f594b0
f594b0
%patch1 -p1
f594b0
55fde0
# Drop the dummyserver tests in koji.
55fde0
# These require tornado, a Web framework otherwise unused in the distro.
55fde0
rm -rf test/with_dummyserver/
55fde0
rm -rf test/test_connectionpool.py
55fde0
rm -rf dummyserver/
55fde0
# Don't run the Google App Engine tests
55fde0
rm -rf test/appengine/
55fde0
# Lots of these tests started failing, even for old versions, so it has something
55fde0
# to do with Fedora in particular. They don't fail in upstream build infrastructure
55fde0
rm -rf test/contrib/
55fde0
f594b0
# Tests for Python built without SSL, but RHEL builds with SSL. These tests
f594b0
# fail when combined with the unbundling of backports-ssl_match_hostname
f594b0
rm -f test/test_no_ssl.py
721b52
Brian Stinson adf068
# Test `test_recent_date` fails if RECENT_DATE is not up to date.
Brian Stinson adf068
# Comment from the test:
Brian Stinson adf068
#     This test is to make sure that the RECENT_DATE value
Brian Stinson adf068
#     doesn't get too far behind what the current date is.
Brian Stinson adf068
#     When this test fails update urllib3.connection.RECENT_DATE
Brian Stinson adf068
#     according to the rules defined in that file.
a7f48f
sed -i "s/^RECENT_DATE = datetime.date(2017, 6, 30)$/RECENT_DATE = datetime.date(2020, 2, 1)/" \
Brian Stinson adf068
    src/urllib3/connection.py
Brian Stinson adf068
55fde0
%build
55fde0
%py2_build
55fde0
%if %{with python3}
55fde0
%py3_build
55fde0
%endif
55fde0
55fde0
55fde0
%install
55fde0
%py2_install
55fde0
%if %{with python3}
55fde0
%py3_install
55fde0
%endif
55fde0
55fde0
# Unbundle the Python 2 build
55fde0
rm -rf %{buildroot}/%{python2_sitelib}/urllib3/packages/six.py*
55fde0
rm -rf %{buildroot}/%{python2_sitelib}/urllib3/packages/ssl_match_hostname/
55fde0
55fde0
mkdir -p %{buildroot}/%{python2_sitelib}/urllib3/packages/
f594b0
ln -s %{python2_sitelib}/six.py %{buildroot}/%{python2_sitelib}/urllib3/packages/six.py
f594b0
ln -s %{python2_sitelib}/six.pyc %{buildroot}/%{python2_sitelib}/urllib3/packages/six.pyc
f594b0
ln -s %{python2_sitelib}/six.pyo %{buildroot}/%{python2_sitelib}/urllib3/packages/six.pyo
55fde0
f594b0
ln -s %{python2_sitelib}/backports/ssl_match_hostname %{buildroot}/%{python2_sitelib}/urllib3/packages/ssl_match_hostname
55fde0
55fde0
%if %{with python3}
55fde0
# Unbundle the Python 3 build
55fde0
rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/six.py*
55fde0
rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/six*
55fde0
rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/ssl_match_hostname/
55fde0
55fde0
mkdir -p %{buildroot}/%{python3_sitelib}/urllib3/packages/
f594b0
ln -s %{python3_sitelib}/six.py \
f594b0
      %{buildroot}/%{python3_sitelib}/urllib3/packages/six.py
f594b0
ln -s %{python3_sitelib}/__pycache__/six.cpython-%{python3_version_nodots}.opt-1.pyc \
f594b0
      %{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/
f594b0
ln -s %{python3_sitelib}/__pycache__/six.cpython-%{python3_version_nodots}.pyc \
f594b0
      %{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/
55fde0
# urllib3 requires Python 3.5 to use the standard library's match_hostname,
f594b0
# which we ship in RHEL8, so we can safely replace the bundled version with
55fde0
# this stub which imports the necessary objects.
55fde0
cp %{SOURCE1} %{buildroot}/%{python3_sitelib}/urllib3/packages/ssl_match_hostname.py
55fde0
%endif
55fde0
55fde0
%check
f594b0
pushd test
f594b0
PYTHONPATH=%{buildroot}%{python2_sitelib}:%{python2_sitelib} %{__python2} -m pytest -v
f594b0
popd
55fde0
%if %{with python3}
55fde0
py.test-3
55fde0
%endif
55fde0
55fde0
%files -n python2-%{srcname}
55fde0
%license LICENSE.txt
55fde0
%doc CHANGES.rst README.rst CONTRIBUTORS.txt
55fde0
%{python2_sitelib}/urllib3/
55fde0
%{python2_sitelib}/urllib3-*.egg-info
55fde0
55fde0
55fde0
%if %{with python3}
55fde0
%files -n python3-%{srcname}
55fde0
%license LICENSE.txt
55fde0
%doc CHANGES.rst README.rst CONTRIBUTORS.txt
55fde0
%{python3_sitelib}/urllib3/
55fde0
%{python3_sitelib}/urllib3-*.egg-info
55fde0
%endif
55fde0
55fde0
55fde0
%changelog
f594b0
* Fri May 03 2019 Tomas Orsava <torsava@redhat.com> - 1.24.2-1
f594b0
- Rebased to 1.24.2 to fix CVE-2019-11324
f594b0
- Added patches for CVE-2019-11236 (AKA CVE-2019-9740)
f594b0
- Resolves: rhbz#1706765 rhbz#1706762
721b52
f594b0
* Thu Apr 25 2019 Tomas Orsava <torsava@redhat.com> - 1.23-7
f594b0
- Bumping due to problems with modular RPM upgrade path
f594b0
- Resolves: rhbz#1695587
8fc530
55fde0
* Tue Jul 31 2018 Lumír Balhar <lbalhar@redhat.com> - 1.23-6
55fde0
- Make possible to disable python3 subpackage
f594b0
55fde0
* Mon Jul 16 2018 Lumír Balhar <lbalhar@redhat.com> - 1.23-5
55fde0
- First version for python27 module