giampaolo / pyftpdlib

Extremely fast and scalable Python FTP server library
MIT License
1.68k stars 263 forks source link

close connection on SSL EOF error #614

Closed giampaolo closed 1 year ago

giampaolo commented 1 year ago

Fixes the following tests:

======================================================================
ERROR: pyftpdlib.test.test_functional_ssl.TestFtpListingCmdsTLSMixin.test_list
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 1153, in test_list
    self._test_listing_cmds('list')
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 1142, in _test_listing_cmds
    self.client.retrlines('%s %s' % (cmd, tempdir), x.append)
  File "/usr/local/lib/python3.11/ftplib.py", line 462, in retrlines
    with self.transfercmd(cmd) as conn, \
         ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 393, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 793, in ntransfercmd
    conn, size = super().ntransfercmd(cmd, rest)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 353, in ntransfercmd
    host, port = self.makepasv()
                 ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 327, in makepasv
    untrusted_host, port = parse227(self.sendcmd('PASV'))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 839, in parse227
    raise error_reply(resp)
ftplib.error_reply: 200 Type set to: ASCII.

======================================================================
ERROR: pyftpdlib.test.test_functional_ssl.TestFtpListingCmdsTLSMixin.test_mlsd
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 1196, in test_mlsd
    self._test_listing_cmds('mlsd')
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 1142, in _test_listing_cmds
    self.client.retrlines('%s %s' % (cmd, tempdir), x.append)
  File "/usr/local/lib/python3.11/ftplib.py", line 462, in retrlines
    with self.transfercmd(cmd) as conn, \
         ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 393, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 793, in ntransfercmd
    conn, size = super().ntransfercmd(cmd, rest)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 353, in ntransfercmd
    host, port = self.makepasv()
                 ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 327, in makepasv
    untrusted_host, port = parse227(self.sendcmd('PASV'))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 839, in parse227
    raise error_reply(resp)
ftplib.error_reply: 200 Type set to: ASCII.

======================================================================
ERROR: pyftpdlib.test.test_functional_ssl.TestFtpListingCmdsTLSMixin.test_nlst
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional_ssl.py", line 129, in test_nlst
    super().test_nlst()
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 1149, in test_nlst
    self._test_listing_cmds('nlst')
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 1142, in _test_listing_cmds
    self.client.retrlines('%s %s' % (cmd, tempdir), x.append)
  File "/usr/local/lib/python3.11/ftplib.py", line 462, in retrlines
    with self.transfercmd(cmd) as conn, \
         ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 393, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 793, in ntransfercmd
    conn, size = super().ntransfercmd(cmd, rest)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 353, in ntransfercmd
    host, port = self.makepasv()
                 ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 327, in makepasv
    untrusted_host, port = parse227(self.sendcmd('PASV'))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 839, in parse227
    raise error_reply(resp)
ftplib.error_reply: 200 Type set to: ASCII.

======================================================================
ERROR: pyftpdlib.test.test_functional_ssl.TestFtpStoreDataTLSMixin.test_failing_rest_on_stor
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 920, in test_failing_rest_on_stor
    self.client.storbinary('stor ' + self.testfn, self.dummy_sendfile)
  File "/usr/local/lib/python3.11/ftplib.py", line 498, in storbinary
    with self.transfercmd(cmd, rest) as conn:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 393, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 793, in ntransfercmd
    conn, size = super().ntransfercmd(cmd, rest)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 353, in ntransfercmd
    host, port = self.makepasv()
                 ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 327, in makepasv
    untrusted_host, port = parse227(self.sendcmd('PASV'))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ftplib.py", line 839, in parse227
    raise error_reply(resp)
ftplib.error_reply: 200 Type set to: Binary.

======================================================================
FAIL: pyftpdlib.test.test_functional_ssl.TestCornerCasesTLSMixin.test_port_race_condition
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 2246, in tearDown
    close_client(self.client)
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/__init__.py", line 136, in close_client
    assert resp.startswith('221'), resp
AssertionError: 226 Transfer complete.

======================================================================
FAIL: pyftpdlib.test.test_functional_ssl.TestCornerCasesTLSMixin.test_repr
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 2246, in tearDown
    close_client(self.client)
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/__init__.py", line 136, in close_client
    assert resp.startswith('221'), resp
AssertionError: 226 Transfer complete.

======================================================================
FAIL: pyftpdlib.test.test_functional_ssl.TestFtpListingCmdsTLSMixin.test_list
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 1115, in tearDown
    close_client(self.client)
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/__init__.py", line 136, in close_client
    assert resp.startswith('221'), resp
AssertionError: 227 Entering passive mode (127,0,0,1,219,69).

======================================================================
FAIL: pyftpdlib.test.test_functional_ssl.TestFtpListingCmdsTLSMixin.test_mlsd
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 1115, in tearDown
    close_client(self.client)
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/__init__.py", line 136, in close_client
    assert resp.startswith('221'), resp
AssertionError: 227 Entering passive mode (127,0,0,1,158,137).

======================================================================
FAIL: pyftpdlib.test.test_functional_ssl.TestFtpListingCmdsTLSMixin.test_nlst
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 1115, in tearDown
    close_client(self.client)
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/__init__.py", line 136, in close_client
    assert resp.startswith('221'), resp
AssertionError: 227 Entering passive mode (127,0,0,1,148,221).

======================================================================
FAIL: pyftpdlib.test.test_functional_ssl.TestFtpRetrieveDataTLSMixin.test_retr
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 996, in tearDown
    close_client(self.client)
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/__init__.py", line 136, in close_client
    assert resp.startswith('221'), resp
AssertionError: 226 Transfer complete.

======================================================================
FAIL: pyftpdlib.test.test_functional_ssl.TestFtpStoreDataTLSMixin.test_failing_rest_on_stor
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 686, in tearDown
    close_client(self.client)
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/__init__.py", line 136, in close_client
    assert resp.startswith('221'), resp
AssertionError: 227 Entering passive mode (127,0,0,1,156,143).

======================================================================
FAIL: pyftpdlib.test.test_functional_ssl.TestIPv4EnvironmentTLSMixin.test_eprt
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 1975, in tearDown
    close_client(self.client)
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/__init__.py", line 136, in close_client
    assert resp.startswith('221'), resp
AssertionError: 226 Transfer complete.

======================================================================
FAIL: pyftpdlib.test.test_functional_ssl.TestIPv6EnvironmentTLSMixin.test_eprt
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 1975, in tearDown
    close_client(self.client)
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/__init__.py", line 136, in close_client
    assert resp.startswith('221'), resp
AssertionError: 226 Transfer complete.

======================================================================
FAIL: pyftpdlib.test.test_functional_ssl.TestTimeoutsTLSMixin.test_disabled_data_timeout
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 1444, in tearDown
    close_client(self.client)
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/__init__.py", line 136, in close_client
    assert resp.startswith('221'), resp
AssertionError: 226 Transfer complete.

======================================================================
FAIL: pyftpdlib.test.test_functional_ssl.TestTimeoutsTLSMixin.test_disabled_pasv_timeout
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 1444, in tearDown
    close_client(self.client)
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/__init__.py", line 136, in close_client
    assert resp.startswith('221'), resp
AssertionError: 226 Transfer complete.

======================================================================
FAIL: pyftpdlib.test.test_functional_ssl.TestTimeoutsTLSMixin.test_disabled_port_timeout
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/test_functional.py", line 1444, in tearDown
    close_client(self.client)
  File "/home/giampaolo/svn/pyftpdlib/pyftpdlib/test/__init__.py", line 136, in close_client
    assert resp.startswith('221'), resp
AssertionError: 226 Transfer complete.

----------------------------------------------------------------------
Ran 221 tests in 7.652s

FAILED (failures=12, errors=4, skipped=3)
codecov[bot] commented 1 year ago

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (923d933) 69.93% compared to head (dae0608) 70.02%. Report is 3 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #614 +/- ## ========================================== + Coverage 69.93% 70.02% +0.09% ========================================== Files 9 9 Lines 3609 3610 +1 ========================================== + Hits 2524 2528 +4 + Misses 1085 1082 -3 ``` | [Files](https://app.codecov.io/gh/giampaolo/pyftpdlib/pull/614?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Giampaolo+Rodola) | Coverage Δ | | |---|---|---| | [pyftpdlib/handlers.py](https://app.codecov.io/gh/giampaolo/pyftpdlib/pull/614?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Giampaolo+Rodola#diff-cHlmdHBkbGliL2hhbmRsZXJzLnB5) | `70.85% <0.00%> (+0.16%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.