-
Notifications
You must be signed in to change notification settings - Fork 379
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
[Loader] Abstract filesystem resource locator and legacy insecure locator implementation #866
[Loader] Abstract filesystem resource locator and legacy insecure locator implementation #866
Conversation
Note that the |
61e9a1c
to
5b47c80
Compare
Thoughts as to whether we want to offer a file locator (optional) implementation that is less secure, but allows symbolic links? @antoligy @cedricziel |
Binary/Loader/FileSystemLoader.php
Outdated
$dataRoots | ||
) { | ||
$this->mimeTypeGuesser = $mimeTypeGuesser; | ||
public function __construct(MimeTypeGuesserInterface $mimeGuesser, ExtensionGuesserInterface $extensionGuesser, $dataRoots, $secureLocator = true) |
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.
Might be worth keeping this to multiple lines for readability?
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.
Yeah, fair enough. I hate multi-line constructors (unless it's well past 120 characters). That said, I know many are big on it (and an 80 character line limit). I'll revert. ;-) 👍
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.
I wouldn't mind them so much if we could typehint on primitives... Grr... 😛
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.
Seems like a good answer to this issue, without introducing too much complexity for future maintenance, so I'm happy with this!
My opinion is that it's worth adding the InsecureFileLoader, that way we can document that this practice is not recommended, without breaking existing deployments. Happy for a test suite to appear in a future PR just so we can verify that this works, but I see it should function the same way as before we improved resolution. |
Went ahead and resolved the conflict (loving that you can do this now!)- Janky commit but it should be resolved by a squash! |
@antoligy Thanks for the conflict resolution! Since you're on board with this approach, I'm gonna go ahead and add the tests to this PR tonight before merging (I don't like the idea of adding any new code without comprehensive tests ;-). Should we release |
Yeah that sounds like a good idea and I think so, as it addresses probably the only repeat complaint since 1.7.0 was released! |
Right, sounds good. 👍 I'll get the tests implemented. Of note, I was just granted collaborator access to the avalanche123/Imagine repository today, so that should help us push items that effects this bundle upstream in the future. |
I think that it is a very good idea. Thank you so much guys. |
3bcea00
to
a2edd2e
Compare
@antoligy Can you give this an additional once-over. I moved some stuff around, created a deprecation layer for |
e5e043f
to
69952e1
Compare
69952e1
to
f708b36
Compare
@davidromani Before merging this, I'd like to confirm it does resolve your symbolic link issue. Can you patch your vendor release of this bundle with the PR and write back confirming proper functionality? To apply this PR as a patch, you must perform the following: # install the `master` from source
cd vendor/liip; rm -fr imagine-bundle
git clone https://github.com/liip/LiipImagineBundle.git imagine-bundle
cd imagine-bundle
# apply this PR as a patch
curl -L https://github.com/liip/LiipImagineBundle/pull/866.diff | patch -p1
# clear your cached assets
rm -fr web/path/to/cached/images/ Then enable the new liip_imagine :
loaders:
default:
filesystem:
locator: filesystem_insecure |
@robfrawley Yes, it works! Thank you so much!! |
Nice work all! 🙂 |
@davidromani The 1.7.2 release has just been published and you can immediately upgrade by calling composer via |
Abstract file locator, specifically
FileSystemLocator
andFileSystemInsecureLocator
, outside of their respective "loader" classes to allow for multiple implementations of resource resolution. This includes an insecure resource locator version that allows symbolic links to be passed and blindly followed with no regard as to where they might point. This fixes environments that rely on deploy tools using symbolic links.The question is, do we want to offer this functionality? @antoligy @cedricziel @davidromani