Skip to content
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

Merged
merged 8 commits into from
Sep 10, 2016
Merged

Conversation

NinoFloris
Copy link
Contributor

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!

…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.
…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...
@NinoFloris NinoFloris force-pushed the feature/flysystem-integration branch from dda737c to 122deff Compare August 19, 2016 02:00
@sroze
Copy link
Owner

sroze commented Aug 19, 2016

Indeed, that's a large PR! Can you first run php-cs-fixer on your branch and update the .travis.yml configuration file to run the tests with your matrix of TEST_ENV (that I would rename to TEST_FILESYSTEM) ?

@sroze
Copy link
Owner

sroze commented Aug 19, 2016

I would definitely be amazed if you can send a (different) PR regarding the DoS vulnerability you are talking about!

@NinoFloris NinoFloris force-pushed the feature/flysystem-integration branch from be34b87 to 5dac507 Compare August 19, 2016 12:18
@NinoFloris NinoFloris force-pushed the feature/flysystem-integration branch from 5dac507 to a1a78f4 Compare August 19, 2016 12:20
@NinoFloris
Copy link
Contributor Author

Done!

@NinoFloris
Copy link
Contributor Author

Not meaning to rush you but how is it going?

@sroze
Copy link
Owner

sroze commented Sep 10, 2016

Thank you @NinoFloris! I'll probably refactor a little bit later that's a already good enough. Really appreciate the hard work 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants