-
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
Fix absolute path #848
Fix absolute path #848
Conversation
There was conflict with 'assets:install --symlink', which cause the NotLoadableException. It searchs in web but the realpath was returned the path in src/.../. That path was outside the defined root path (/web by default).
Fix absolute path
Thanks for contributing! |
I'm fine with merging this in principle and releasing a patch level, especially as it should fix #846, but this has broken the tests introduced in #775 and I would also prefer to hear from @robfrawley first. |
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.
Failing tests
I'm 👎 on this. Changing if (!($absolutePath = realpath($this->rootPath.DIRECTORY_SEPARATOR.$path))) { to if (!($absolutePath = realpath($this->rootPath).DIRECTORY_SEPARATOR.$path)) { Removes the ability to ensure the image path is within the root path. Again, you simply have to set a data root in the bundle configuration if you require files outside the default. Also, you might as well change the line to $absolutePath = $this->rootPath.DIRECTORY_SEPARATOR.$path; and remove the call to Moreover, this change breaks already-fixed bugs which would cause |
Also, can you clarify what you intended to describe @raphaChoquet? The description you gave doesn't make sense to me as
|
I wanted to say i have used the command assets:install with option -symlinks. Then the realpath resolve 'bundles/app/img/my-image.png' by 'src/AppBundle/Resources/public/img/my-image.png'. This cause exception 'Source image invalid "%s" as it is outside of the defined root path'. I suppose we need to define a function to determinate if $path is in the root_path without destroying the symlinks. Perhaps you considerate symlink as a security fail ? Sorry for my english, i'm not have a good level ^^' |
@raphaChoquet Don't worry about your English; it's absolutely fine! ;-) I'll spend some time with this over the weekend to see if we can't allow for an array of data roots, or define an alternate realpath function that handles this more gracefully. I get where you are running into problems, but the issue with allowing symbolic links blindly is the ability for unintentionally following routes to other, possibly secure, paths on the entire filesystem. @antoligy Any ideas or guidance on which of the above possible solutions you think may be better to implement? |
@antoligy @davidromani @adaniloff @raphaChoquet @picks44 Alternatively to all other previously mentioned paths forward, perhaps we should create a liip_imagine:
loaders:
default:
filesystem:
resolve_sym_links: false |
See #846 (comment) for a possible solution. |
Closing as this breaks unit tests. Please feel free to re-open a new PR if you can provide an implementation that doesn't break the requirements of this component. I suggest you see if #851 fixes your issue. |
👍 |
There was conflict with 'assets:install --symlink', which cause the NotLoadableException. It searches in web but the realpath was returned the path in src/.../. That path was outside the defined root path (/web by default).