-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Update the unencrypted file size when closing streams #35649
Conversation
Signed-off-by: Julius Härtl <jus@bitgrid.net>
/backport to stabel25 |
/backport to stable24 |
Backporting only to 24/25 as in general this requires #31966 to work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 wow, nice catch!
@icewind1991 @PVince81 Any hint on where the best place for a test case of this would be? To reproduce this I used the following plain code snippets:
Beforearray(3) { ["size"]=> int(8192) ["unencrypted_size"]=> int(0) ["encrypted"]=> bool(true) } array(3) { ["size"]=> int(74592) ["unencrypted_size"]=> int(0) ["encrypted"]=> bool(true) } Afterarray(3) { ["size"]=> int(8192) ["unencrypted_size"]=> int(0) ["encrypted"]=> bool(true) } array(3) { ["size"]=> int(65536) ["unencrypted_size"]=> int(65536) ["encrypted"]=> bool(true) } |
@juliushaertl it seems there's a matching test class that might be useable for a unit test: tests/lib/Files/Stream/EncryptionTest.php for integration tests, it seems we don't have encryption there. another idea would be to simply add code like your snippet above either the storage tests or stream tests, and rely on https://github.com/nextcloud/server/blob/master/.github/workflows/s3-primary.yml#L59 to have them run on S3. maybe we should copy that workflow to also have one with encryption enabled ? |
…ty content Signed-off-by: Julius Härtl <jus@bitgrid.net>
f6d6898
to
59ae6e9
Compare
Apparently the webdav API didn't trigger those issues, but maybe because they interact a bit differently with the file system apis through the view directly. I adjusted the unit tests accordingly to have some basic coverage so we can get this in, but at some point dedicated integration tests with encryption might be nice to have. |
The backport to stabel25 failed. Please do this backport manually. |
/backport to stable25 |
Summary
This PR fixes two issues related to primary object storage and master key encryption, both related to apps using the PHP Nodes api for file access.
77edd36 makes sure that the proper unencrypted size is written into the filecache when writing to a file through the putContent method. This for example is done by Collabora to save a file. Without updating the unencrypted size any follow up download would cause a BadSignature error.
f6d6898 Addresses a similar issue when a newFile was created with empty content. In this case the encryption stream writes just the header to the file but never updates the isEncrypted flag on it, so when creating a new empty file in the text app the encrypted content is returned to the user instead of the decrypted one.
Checklist