You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Server computes checksum on read/write file operations #26655
store computed checksum in DB even if no checksum given by client
compute and store checksum in database when using fopen in write mode
Open questions:
always use SHA1 everywhere ?
what if a client sends MD5 checksum, do we then compute both MD5 and SHA1 and use MD5 only for verification and store SHA1 in database ? I'd suggest we limit to only SHA1 for now.
@guruz I'm starting to have the feeling that maybe we shouldn't compute the checksum in the AssemblyStream but instead implement a StreamWrapper that will compute the checksum.
The stream wrapper is then applied for any operation that involves fopen, file_put_contents to make sure that even apps using file APIs will have their file receive a checksum.
The advantage of the stream wrapper is that it will cover most code paths, including chunking ng assembly and also download.
I realise this project has not been touched for quite some time. Feel free
to send patches. I'd rather use SHA2 than SHA1, at least for a new
checksum. It shouldn't be much more expensive.
Basically the goal is to try and always have a checksum value available in the matching oc_filecache column.
Currently we only store one if the client sent one as part of an upload header.
Now we also want the server to verify it at upload time (in Sabre\File that you already know from your chunking PR) and also to compute it when a file is streamed (read/write).
But the code itself should not go in Sabre\File because that's already too high level, too specific
@IljaN you might need to use a similar approach to encryption with a storage wrapper + stream wrapper:
The encryption storage wrapper sets up a stream wrapper (PHP stream wrapper) on fopen. the stream wrapper encrypts In the case of checksum, the stream wrapper would only compute the checksum and store it in oc_filecache in stream_close or so
For checksum verification, I think this should happen later. First let the stream wrapper compute the checksum of whatever has been read or written, and add code that runs later (need to find a good place) and compares that checksum with the expected one from the header
Let's focus on the computing part first.
This is basically the task item "compute and store checksum in database when using fopen in write mode".
I'd also suggest writing the computed checksum into the stream_context, this way the caller of fopen would be able to retrieve it directly without having to go to oc_filecache afterwards.
Activity
PVince81 commentedon Nov 18, 2016
@guruz I'm starting to have the feeling that maybe we shouldn't compute the checksum in the AssemblyStream but instead implement a
StreamWrapperthat will compute the checksum.The stream wrapper is then applied for any operation that involves
fopen,file_put_contentsto make sure that even apps using file APIs will have their file receive a checksum.The advantage of the stream wrapper is that it will cover most code paths, including chunking ng assembly and also download.
@DeepDiver1975
guruz commentedon Nov 21, 2016
Do you mean stream wrapper or stream filter?
Something like https://github.com/bantuXorg/php-stream-filter-hash ? FYI @bantu
PVince81 commentedon Nov 21, 2016
@guruz I'm only familiar with stream wrappers, but if a stream filter does the same then I'm fine with it.
bantu commentedon Nov 21, 2016
PVince81 commentedon Dec 3, 2016
@guruz assigning you for now. Let me know if you need guidance or help.
[-]Server computes checksum on upload/download[/-][+]Server computes checksum on read/write file operations[/+]PVince81 commentedon Jan 26, 2017
Posting what I said in the chat:
Basically the goal is to try and always have a checksum value available in the matching oc_filecache column.
Currently we only store one if the client sent one as part of an upload header.
Now we also want the server to verify it at upload time (in Sabre\File that you already know from your chunking PR) and also to compute it when a file is streamed (read/write).
But the code itself should not go in Sabre\File because that's already too high level, too specific
@IljaN you might need to use a similar approach to encryption with a storage wrapper + stream wrapper:
@IljaN start debugging encryption here: https://github.com/owncloud/core/blob/master/lib/private/Encryption/Manager.php#L256, then dig into the storage wrapper and see what it does on fopen. Basically a storage wrapper intercepts any FS calls and does things, so it has all regular storage methods. Since a storage wrapper intercepts FS calls, it's likely the best place to add something that needs to act on fopen/file_put_contents.
The encryption storage wrapper sets up a stream wrapper (PHP stream wrapper) on fopen. the stream wrapper encrypts In the case of checksum, the stream wrapper would only compute the checksum and store it in oc_filecache in stream_close or so
For checksum verification, I think this should happen later. First let the stream wrapper compute the checksum of whatever has been read or written, and add code that runs later (need to find a good place) and compares that checksum with the expected one from the header
Let's focus on the computing part first.
This is basically the task item "compute and store checksum in database when using fopen in write mode".
PVince81 commentedon Jan 26, 2017
it should actually be possible to copy-paste the encryption storage + stream wrapper code and adjust accordingly
encryption also writes some data (unencrypted size) to the filecache. so for checksum replace that code to write the checksum instead
so not that much new stuff to invent :-)
PVince81 commentedon Jan 26, 2017
I'd also suggest writing the computed checksum into the stream_context, this way the caller of
fopenwould be able to retrieve it directly without having to go to oc_filecache afterwards.109 remaining items
Adding checksum download test #26655
#26655 eventual mimetype error fix
#26655 Webdav returns only one checksum (SHA1)
#26655 Various smaller improvements, additional upload chunked with c…
#26655 strpos bugfix
Files without checksum in oc_filecache get a checksum on first read #…
Revert strpos fix #26655
Caching of file id, and various small fixes #26655
Merge pull request #27097 from owncloud/26655_ComputeChecksum2
bantu commentedon Mar 10, 2017
PVince81 commentedon Mar 10, 2017
@IljaN ^
lock commentedon Jul 31, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.