-
Notifications
You must be signed in to change notification settings - Fork 17
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
Flysystem integration #23
Conversation
…ectly in the dependencies
…d FileStorage A few tweaks to the file abstraction layer have been incorporated as well. There currently is a very naive implementation of resumable upload with streams in there as it is extremely vulnerable for DOS attacks. This is due to it having to retrieve the full file and writing it with some extra data back again to some unknown remote for each chunk that gets uploaded. Next commit fixes this.
… but it works for now.
…witches through env var TEST_ENV between Gaufrette and Flysystem, also moved both Gaufrette and Flysystem to require-dev and suggest in composer.json, lock file is unchanged and includes both I have looked around at test listeners, having multiple test suits with different environment variables etcetara bottom line PHPUnit is unflexible in this and so it is required to run PHPUnit twice...
dda737c
to
122deff
Compare
Indeed, that's a large PR! Can you first run |
I would definitely be amazed if you can send a (different) PR regarding the DoS vulnerability you are talking about! |
be34b87
to
5dac507
Compare
5dac507
to
a1a78f4
Compare
Done! |
Not meaning to rush you but how is it going? |
Thank you @NinoFloris! I'll probably refactor a little bit later that's a already good enough. Really appreciate the hard work 👍 |
Ok this is a big PR, but it essentially allows users of this bundle to choose which filesystem abstraction layer they'd like to use.
As we are using Flysystem that is how this PR came to be...
I have tried to keep everything within logical commits and rebased heavily to keep it that way, I hope you are able to review this in the coming weeks.
Enjoy!
P.S.
There still is quite a big DOS vulnerability with resumable uploads (and multipart/related in a lesser way), especially with Gaufrette because of its lack of stream support the entire file is read into ram on each chunk upload. What an attacker could very easily do is upload 98 MB of a 100 MB file and thereafter keep sending requests or keep uploading chunks of 1 byte each, which will totally overwhelm the server in ram, compute and transfer time. This could also literally cost you money if it is attached to an expensive storage location with high transfer fees.
I have a local stash which tries to mitigate the ram and transfer time issues by using a storage as a designated 'temp storage' that is used across resumes, that could default to a local folder. This is of course much faster to read and gaufrette and flysystem both have stream support for local files so are therefore able to stream this file, I stream them into a stream copy which can be used for seek + write type of actions. This copying from stream to stream happens in the runtime with 8KB chunks at a time and once the stream reaches 'maxmemory' it overflows into a file on disk. Therefore never reaching more than the allotted memory.
Just let me know if you are interested in such an addition and I'll whip it into shape for a PR!