Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions providers/ftp/src/airflow/providers/ftp/hooks/ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,5 +313,7 @@ def get_conn(self) -> ftplib.FTP:
else:
self.conn = ftplib.FTP_TLS(params.host, params.login, params.password, context=context) # nosec: B321
self.conn.set_pasv(pasv)
# Without prot_p() ftplib transfers file payloads over cleartext sockets even though the control connection is TLS.
self.conn.prot_p()

return self.conn
8 changes: 8 additions & 0 deletions providers/ftp/tests/unit/ftp/hooks/test_ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,11 @@ def test_ftps_encoding_extra(self, mock_ftp_tls):
hook = FTPSHook("ftp_encoding")
hook.get_conn()
assert any(call.kwargs.get("encoding") == "cp1251" for call in mock_ftp_tls.mock_calls)

@mock.patch("ftplib.FTP_TLS")
def test_ftps_enables_protected_data_channel(self, mock_ftp_tls):
from airflow.providers.ftp.hooks.ftp import FTPSHook

hook = FTPSHook("ftp_passive")
conn = hook.get_conn()
conn.prot_p.assert_called_once_with()
Loading