Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NXDRIVE-2933: Fix ReDoS in py library when used with subversion #4908

Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e4d5843
Bump tox from 3.24.5 to 4.15.0 in /tools/deps
dependabot[bot] May 20, 2024
a564589
Added cachetools 5.3.3 and pyproject-api 1.6.1
swetayadav1 May 20, 2024
2054120
Bump pluggy from 1.4.0 to 1.5.0 in /tools/deps (#4866)
dependabot[bot] May 20, 2024
e58e582
Bump py-cpuinfo from 8.0.0 to 9.0.0 in /tools/deps (#3677)
dependabot[bot] May 20, 2024
daca6e3
Bump pytest-cov from 4.1.0 to 5.0.0 in /tools/deps (#4732)
dependabot[bot] May 20, 2024
2f114c0
Bump pytest-timeout from 2.2.0 to 2.3.1 in /tools/deps (#4679)
dependabot[bot] May 20, 2024
7c4e379
Bump pytest-benchmark from 3.4.1 to 4.0.0 in /tools/deps (#4072)
dependabot[bot] May 20, 2024
b1be39f
Bump pytest from 7.4.4 to 8.2.1 in /tools/deps (#4888)
dependabot[bot] May 20, 2024
dd8f517
Bump filelock from 3.12.4 to 3.14.0 in /tools/deps (#4833)
dependabot[bot] May 20, 2024
4b0e372
Bump virtualenv from 20.4.7 to 20.26.2 in /tools/deps (#4887)
dependabot[bot] May 20, 2024
6899de3
Bump chardet from 4.0.0 to 5.2.0 in /tools/deps (#4054)
dependabot[bot] May 20, 2024
50a1945
Bump py from 1.10.0 to 1.11.0 in /tools/deps (#3676)
dependabot[bot] May 20, 2024
c297aa4
Removed pyproject-api
swetayadav1 May 20, 2024
9df142a
Added pyproject-api and colorama in MacOS
swetayadav1 May 22, 2024
8ee51f1
Added tomli in tox file
swetayadav1 May 22, 2024
e0cfc7e
added cardet in tox file
swetayadav1 May 22, 2024
b69b16f
Added platformdirs in tox file
swetayadav1 May 22, 2024
0d1307b
Updating colorama in all platforms
swetayadav1 May 22, 2024
c49d568
Bump platformdirs from 4.2.0 to 4.2.2 in /tools/deps (#4894)
dependabot[bot] May 22, 2024
8f889c0
updated platformdirs in tox file
swetayadav1 May 22, 2024
9cbf78b
Updated md file
swetayadav1 May 22, 2024
80d1586
Removed py and pytest-forked as it depends on py
swetayadav1 May 22, 2024
e02e4ce
Updated md file
swetayadav1 May 22, 2024
975447b
Update 5.5.0.md
swetayadav1 May 23, 2024
b260682
NXDRIVE-2936: Fix security issue Requests Session object does not ver…
swetayadav1 May 28, 2024
81a7917
Merge branch 'master' into wip-NXDRIVE-2933-Fix-redos-in-py-library-w…
swetayadav1 May 28, 2024
13ae5bd
NXDRIVE-2928: Fix security issue IDNA vulnerable to denial of service…
swetayadav1 May 28, 2024
736ec20
NXDRIVE-2927: Fix security issue black vulnerable to Regular Expressi…
swetayadav1 May 28, 2024
2e3f779
NXDRIVE-2920: Upgrade to TLS 1.2 (#4780)
swetayadav1 May 28, 2024
d91efd9
Fixed style issues
swetayadav1 May 29, 2024
a210a90
Merge branch 'wip-NXDRIVE-2933-Fix-redos-in-py-library-when-used-with…
swetayadav1 May 29, 2024
8a08a77
Fixed style error
swetayadav1 May 29, 2024
ce33ba1
Fixed style issues
swetayadav1 May 30, 2024
90d6702
Merge branch 'wip-NXDRIVE-2933-Fix-redos-in-py-library-when-used-with…
swetayadav1 May 30, 2024
8724f64
Fixed style error: Update test_cli.py
swetayadav1 May 30, 2024
6e2f7cd
Merge branch 'master' of https://github.com/nuxeo/nuxeo-drive into wi…
swetayadav1 Jun 20, 2024
ca45662
Fixed code style issue
swetayadav1 Jun 20, 2024
43ee2fa
Merge branch 'master' of https://github.com/nuxeo/nuxeo-drive into wi…
swetayadav1 Jul 3, 2024
0483482
revert changes to behaviour.py
nuxeodrive Jul 3, 2024
b30c305
Removed black dependency
swetayadav1 Jul 3, 2024
c51303b
Removed black dependency
swetayadav1 Jul 3, 2024
b89de37
Updated comments in retrieve_ssl_certificate
swetayadav1 Jul 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions docs/changes/5.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Release date: `2024-xx-xx`

## Core

- [NXDRIVE-2](https://jira.nuxeo.com/browse/NXDRIVE-2):
- [NXDRIVE-2920](https://jira.nuxeo.com/browse/NXDRIVE-2920): Upgrade to TLS 1.2

### Direct Edit

Expand All @@ -20,19 +20,38 @@ Release date: `2024-xx-xx`

## Packaging / Build

- [NXDRIVE-2](https://jira.nuxeo.com/browse/NXDRIVE-2):
- [NXDRIVE-2927](https://jira.nuxeo.com/browse/NXDRIVE-2927): Fix Security issue Black vulnerable to Regular Expression Denial of Service (ReDoS)
- [NXDRIVE-2928](https://jira.nuxeo.com/browse/NXDRIVE-2928): Fix security issue IDNA vulnerable to denial of service from specially crafted inputs to idna.encode
- [NXDRIVE-2936] (https://jira.nuxeo.com/browse/NXDRIVE-2936): Fix security issue Requests Session object does not verify requests after making first request with verify=False

## Tests

- [NXDRIVE-2](https://jira.nuxeo.com/browse/NXDRIVE-2):
- [NXDRIVE-2933](https://jira.nuxeo.com/browse/NXDRIVE-2933): Fix redos in py library when used with subversion

## Docs

- [NXDRIVE-2](https://jira.nuxeo.com/browse/NXDRIVE-2):

## Minor Changes

-
- Added `cachetools` 5.3.3
- Added `pyproject-api` 1.6.1
- Removed `py` 1.10.0
- Removed `pytest-forked` 1.6.0
- Upgraded `black` from 23.12.1 to 24.4.2
- Upgraded `chardet` from 4.0.0 to 5.2.0
- Upgraded `filelock` from 3.12.4 to 3.14.0
- Upgraded `idna` from 3.6 to 3.7
- Upgraded `platformdirs` from 4.2.0 to 4.2.2
- Upgraded `pluggy` from 1.4.0 to 1.5.0
- Upgraded `pytest` from 7.4.4 to 8.2.1
- Upgraded `py-cpuinfo` from 8.0.0 to 9.0.0
- Upgraded `pytest-benchmark` from 3.4.1 to 4.0.0
- Upgraded `pytest-cov` from 4.1.0 to 5.0.0
- Upgraded `pytest-timeout` from 2.2.0 to 2.3.1
- Upgraded `requests` from 2.31.0 to 2.32.2
- Upgraded `tox` from 3.24.5 to 4.15.0
- Upgraded `virtualenv` from 20.4.7 to 20.26.2

## Technical Changes

Expand Down
1 change: 1 addition & 0 deletions nxdrive/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
In this file we cannot use a relative import here, else Drive will not start when packaged.
See https://github.com/pyinstaller/pyinstaller/issues/2560
"""

import locale
import platform
import signal
Expand Down
1 change: 1 addition & 0 deletions nxdrive/behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Allow or disallow server deletions.

"""

from types import SimpleNamespace

Behavior = SimpleNamespace(server_deletion=True)
1 change: 1 addition & 0 deletions nxdrive/client/local/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" API to access local resources for synchronization. """

from .base import FileInfo, get

# Get the local client related to the current OS
Expand Down
1 change: 1 addition & 0 deletions nxdrive/client/uploader/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Uploader used by the Remote client for all upload stuff.
"""

import json
from abc import abstractmethod
from logging import getLogger
Expand Down
1 change: 1 addition & 0 deletions nxdrive/client/uploader/direct_transfer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Uploader used by the Direct Transfer feature.
"""

import json
from logging import getLogger
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions nxdrive/client/uploader/sync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Uploader used by the synchronization engine.
"""

from pathlib import Path
from typing import Any, Dict, Optional

Expand Down
1 change: 1 addition & 0 deletions nxdrive/dao/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Query formatting in this file is based on http://www.sqlstyle.guide/
"""

import sys
from contextlib import suppress
from logging import getLogger
Expand Down
1 change: 1 addition & 0 deletions nxdrive/dao/engine.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Query formatting in this file is based on http://www.sqlstyle.guide/
"""

import json
import os
import shutil
Expand Down
1 change: 1 addition & 0 deletions nxdrive/dao/manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Query formatting in this file is based on http://www.sqlstyle.guide/
"""

from logging import getLogger
from pathlib import Path
from sqlite3 import Cursor, IntegrityError, Row
Expand Down
4 changes: 1 addition & 3 deletions nxdrive/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,9 +819,7 @@ def resume_transfer(
meth = (
self.dao.get_download
if nature == "download"
else self.dao.get_dt_upload
if is_direct_transfer
else self.dao.get_upload
else self.dao.get_dt_upload if is_direct_transfer else self.dao.get_upload
)
func = partial(meth, uid=uid) # type: ignore
self._resume_transfers(nature, func, is_direct_transfer=is_direct_transfer)
Expand Down
1 change: 1 addition & 0 deletions nxdrive/fatal_error.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Fatal error screen management using either Qt or OS-specific dialogs.
"""

import sys
from contextlib import suppress
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions nxdrive/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Enable or disable the synchronization features.

"""

from types import SimpleNamespace
from typing import List

Expand Down
1 change: 1 addition & 0 deletions nxdrive/gui/application.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Main Qt application handling OS events and system tray UI. """

import os
import webbrowser
from contextlib import suppress
Expand Down
1 change: 1 addition & 0 deletions nxdrive/osi/darwin/pyNotificationCenter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Python integration macOS notification center. """

from typing import TYPE_CHECKING, Dict

from CoreServices import (
Expand Down
1 change: 1 addition & 0 deletions nxdrive/qt/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Put here all PyQt constants used across the project.
"""

from .imports import (
QAbstractSocket,
QDialogButtonBox,
Expand Down
1 change: 1 addition & 0 deletions nxdrive/qt/imports.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Put here all PyQt imports used across the project.
"""

from PyQt5.QtCore import (
QT_VERSION_STR,
QAbstractListModel,
Expand Down
1 change: 1 addition & 0 deletions nxdrive/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
This state is set at the start of the application to know if it has crashed at the previous run.

"""

from types import SimpleNamespace

State = SimpleNamespace(about_to_quit=False, crash_details="", has_crashed=False)
8 changes: 7 additions & 1 deletion nxdrive/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Most of functions are pure enough to be decorated with a LRU cache.
Each *maxsize* is adjusted depending of the heavy use of the decorated function.
"""

import os
import os.path
import re
Expand Down Expand Up @@ -68,6 +69,8 @@
"notBefore": "N/A",
}

MINIMUM_TLS_VERSION = "TLSv1_2"

log = getLogger(__name__)


Expand Down Expand Up @@ -604,7 +607,10 @@ def retrieve_ssl_certificate(hostname: str, /, *, port: int = 443) -> str:
import ssl

with ssl.create_connection((hostname, port)) as conn: # type: ignore
with ssl.SSLContext().wrap_socket(conn, server_hostname=hostname) as sock:
# Declaring a minimum version to restrict the protocol
context = ssl.create_default_context()
context.minimum_version = getattr(ssl.TLSVersion, MINIMUM_TLS_VERSION)
with context.wrap_socket(conn, server_hostname=hostname) as sock:
cert_data: bytes = sock.getpeercert(binary_form=True) # type: ignore
return ssl.DER_cert_to_PEM_cert(cert_data)

Expand Down
1 change: 1 addition & 0 deletions tests/benchmarks/test_safe_filename.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
If is not the most efficient for small ASCII-only filenames,
but it is the best when there are non-ASCII characters.
"""

import pytest

FILENAMES = [
Expand Down
1 change: 1 addition & 0 deletions tests/cleanup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Cleanup old test users and workspaces."""

import env
from nuxeo.client import Nuxeo

Expand Down
4 changes: 3 additions & 1 deletion tests/integration/windows/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ def test_argument_log_filename(exe, tmp, file):
assert log.is_file()


@pytest.mark.parametrize("folder", ["azerty", "$alice", "léa", "mi Kaël", "こん ツリ ^^"])
@pytest.mark.parametrize(
"folder", ["azerty", "$alice", "léa", "mi Kaël", "こん ツリ ^^"]
)
def test_argument_nxdrive_home(exe, tmp, folder):
path = tmp()
path.mkdir(parents=True, exist_ok=True)
Expand Down
1 change: 1 addition & 0 deletions tests/markers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Collection of pytest markers to ease test filtering."""

import os

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/old_functional/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Common test utilities. """

import os
import sys
import tempfile
Expand Down
1 change: 1 addition & 0 deletions tests/old_functional/test_behavior.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test application Behavior.
"""

from nxdrive.behavior import Behavior

from .. import ensure_no_exception
Expand Down
3 changes: 2 additions & 1 deletion tests/old_functional/test_direct_transfer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test the Direct Transfer feature in different scenarii.
"""

import logging
import re
from pathlib import Path
Expand Down Expand Up @@ -725,7 +726,7 @@ def checks(self, created):
assert not self.engine_1.dao.get_errors(limit=0)

def direct_transfer(self, folder, duplicate_behavior: str = "create") -> None:
paths = {path: size for path, size in get_tree_list(folder)}
paths = dict(get_tree_list(folder))
self.engine_1.direct_transfer(
paths,
self.ws.path,
Expand Down
1 change: 1 addition & 0 deletions tests/old_functional/test_local_changes_when_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Test if changes made to local file system when Drive is offline sync's back
later when Drive becomes online.
"""

import pytest

from nxdrive.constants import WINDOWS
Expand Down
1 change: 1 addition & 0 deletions tests/old_functional/test_local_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

See NXDRIVE-742.
"""

import hashlib
import os
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions tests/old_functional/test_synchronization_dedup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test behaviors when the server allows duplicates and not the client.
"""

from pathlib import Path

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/old_functional/test_transfer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test pause/resume transfers in different scenarii.
"""

import re
from unittest.mock import patch

Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_autolock.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test the Auto-Lock feature used heavily by Direct Edit.
"""

from pathlib import Path
from typing import List, Tuple
from unittest.mock import Mock, patch
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_pytest_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Tests for pytests_random: a pytest plugin to mitigate random failures.
Adapted from github.com/pytest-dev/pytest-rerunfailures
"""

import pytest

pytest_plugins = "pytester"
Expand Down
1 change: 1 addition & 0 deletions tools/cleanup_application_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Remove files from the package that are not needed and too big.
This script can be launched after PyInstaller and before installers creation.
"""

import os
import shutil
import sys
Expand Down
11 changes: 6 additions & 5 deletions tools/deps/requirements-bench.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# Modules needed by benchmarks.
# This file is independent to not pollute other test environments.
#
py-cpuinfo==8.0.0 \
--hash=sha256:5f269be0e08e33fd959de96b34cd4aeeeacac014dd8305f70eb28d06de2345c5
pytest-benchmark==3.4.1 \
--hash=sha256:36d2b08c4882f6f997fd3126a3d6dfd70f3249cde178ed8bbc0b73db7c20f809 \
--hash=sha256:40e263f912de5a81d891619032983557d62a3d85843f9a9f30b98baea0cd7b47
pytest-benchmark==4.0.0 \
--hash=sha256:fb0785b83efe599a6a956361c0691ae1dbb5318018561af10f3e915caa0048d1 \
--hash=sha256:fdb7db64e31c8b277dff9850d2a2556d8b60bcb0ea6524e36e28ffd7c87f71d6
py-cpuinfo==9.0.0 \
--hash=sha256:3cdbbf3fac90dc6f118bfd64384f309edeadd902d7c8fb17f02ffa1fc3f49690 \
--hash=sha256:859625bc251f64e21f077d099d4162689c762b5d6a4c3c97553d56241c9674d5
2 changes: 1 addition & 1 deletion tools/deps/requirements-pip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ click==8.1.7 \
--hash=sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28 \
--hash=sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de
# via pip-tools
colorama==0.4.6 ; sys_platform == "win32" \
colorama==0.4.6 \
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
# via click
Expand Down
Loading