Support unknown file sizes in streaming encryption to fix SFTP timeouts#32
Conversation
Updated the encryption layer to correctly handle plaintext streams with unknown sizes (indicated by -1). This is required for SFTP clients that start uploads without declaring the total file size upfront. Changes: - dcfs/crypto/cipher.py: ciphertext_size_for_plaintext now returns -1 instead of raising ValueError when input is -1. - dcfs/crypto/stream.py: EncryptingFileMessage updated to skip size-based capping and correctly read from inner streams when size is -1. - tests/test_crypto/test_repository.py: added integration test for streaming uploads with unknown size and updated fake repository. - tests/test_crypto/test_cipher.py: added unit test for unknown size arithmetic. Co-authored-by: VulcanoSoftware <113239901+VulcanoSoftware@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
The issue was that the encryption layer (
EncryptingFileMessageandciphertext_size_for_plaintext) raised aValueErrorwhenplaintext_sizewas-1, which occurs when an SFTP client starts an upload without specifying the file size. This caused the upload task to fail immediately, leading to connection timeouts on the client side.I modified the cryptographic arithmetic and the streaming wrapper to support unknown file sizes by treating
-1as a sentinel for an infinite/unknown stream. I also added comprehensive tests to verify that these "size-less" streams can be encrypted and decrypted correctly.PR created automatically by Jules for task 14649539708529037240 started by @VulcanoSoftware