Replace pysftp with paramiko, lift paramiko ceiling to <6#683
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #683 +/- ##
==========================================
- Coverage 83.44% 83.38% -0.06%
==========================================
Files 14 14
Lines 610 614 +4
==========================================
+ Hits 509 512 +3
- Misses 101 102 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request replaces the unmaintained pysftp dependency with direct paramiko usage in the (s)ftp download strategy, enabling paramiko>=4 and lifting the upper constraint to <6 to resolve the DSSKey import breakage and unblock dependency auditing.
Changes:
- Reworked
SFTPStrategy.get()to useparamiko.SSHClient+open_sftp()instead ofpysftp.Connection. - Updated the SFTP strategy unit test to mock
paramiko.SSHClient/SFTP behavior instead ofpysftp. - Updated project/developer tooling: removed
pysftp, raisedparamikoceiling to<6, and addedtypes-paramikofor mypy.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
oteapi/strategies/download/sftp.py |
Replace pysftp connection logic with paramiko (SSHClient + open_sftp) and add a URL host/path guard. |
tests/strategies/download/test_sftp.py |
Replace pysftp-based mocks with paramiko-style SSH/SFTP client mocks and patching. |
pyproject.toml |
Drop pysftp, widen paramiko constraint to <6, and remove pysftp-specific warning filter. |
.pre-commit-config.yaml |
Add types-paramiko to mypy hook dependencies for better type-checking of the new calls. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Squash commit message: Title Body |
pysftp 0.2.9 imports DSSKey from paramiko at module load time, but paramiko 4.0 removed DSSKey entirely. Replace the three pysftp calls in sftp.py with equivalent paramiko.SSHClient usage, remove pysftp from dependencies, and add types-paramiko to the mypy hook.
d5951f6 to
1c52c66
Compare
Summary
Replace the unmaintained
pysftpdependency with directparamikocalls in the SFTP download strategy, and update the paramiko version constraint from<4to>=4,<6.pysftp 0.2.9importsDSSKeyfrom paramiko at module load time; paramiko 4.0 removedDSSKey, causing anImportErrorwheneverparamiko>=4is installed.This also resolves the
pip-auditCVE-2026-44405 advisory that was blocked by the oldparamiko<4pin.Motivation
Fixes #682
Dependabot PR #678 tried raising
paramiko<4to<6, but all pytest jobs failed with:pysftp 0.2.9is unmaintained (last release 2016) and will never be updated.No maintained PyPI fork exists.
The entire role of
pysftpin this codebase is a thin wrapper around three paramiko calls, making a direct replacement straightforward.Changes
oteapi/strategies/download/sftp.pyimport pysftpwithimport paramikopysftp.CnOpts(hostkeys=None)+pysftp.Connection(...)withparamiko.SSHClientused as a context manager withAutoAddPolicy(equivalent host-key behaviour;# nosec B507added as the lax policy is intentional)sftp.get(path, localpath=Path(...))withsftp.get(path, str(localpath))url.hostandurl.pathso bothNoneand empty-string values raise a clear error; the message exposes only host and path (not credentials)tests/strategies/download/test_sftp.pyMockSFTPConnection(patchingpysftp.Connection) withMockSSHClient+MockSFTPClient(patchingparamiko.SSHClient)pyproject.tomlpysftp~=0.2.9from dependenciesparamiko<4→paramiko>=4,<6(lower bound ensures we're past theDSSKeyremoval and the CVE; upper bound guards against future breaking changes in 6.x)filterwarningsentry for pysftp'sHostKeyswarning (no longer needed).pre-commit-config.yamltypes-paramikoto the mypy hook'sadditional_dependenciesso mypy can type-check paramiko calls.gitignore.claude/to avoid accidentally committing Claude Code session filesTest Plan
pre-commit run -apasses with no modificationstest_celery_remoteRabbitMQ 4.x issue addressed separately in PR Pin RabbitMQ broker image to 3.x in Celery tests #681pip-auditpasses — CVE-2026-44405 resolved byparamiko>=4