Closed (fixed)
Project:
Feeds
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
28 Mar 2010 at 19:37 UTC
Updated:
17 Apr 2011 at 22:29 UTC
Jump to comment: Most recent file
Comments
Comment #1
Monkey Master commentedComment #2
alex_b commentedHere is the situation: For security reasons, only files from the site's upload directory are allowed. The reason is that otherwise a user who is allowed to use a file fetcher based importer would be incredibly close to reading any files that on a server that the web server has access to. So I'd like to avoid that.
See
FeedsFileFetcher::sourceFormValidate()how it checks for the file's location if the file is specified directly.I am afraid this is a won't fix. For your specific use case you could consider extending FeedsFileFetcher class. I can't recommend it and you'd need to make sure that users that can access this importer are trusted.
I will document this better in the code.
Comment #3
alex_b commentedBetter comment clarifying security situation: http://drupal.org/cvs?commit=347560
Comment #4
Monkey Master commentedIt's not about FeedsFileFetcher - it's about filefield mapper which uses FeedsEnclosure limited to remote files only - unlike FeedsFileFetcher.
I modified FeedsEnclosure->getFile() to also work with local files in site's upload directory - I don't see a security problem here...
I can also add file_check_location($this->file, file_directory_path()) - like in FeedsFileFetcher::sourceFormValidate() - to prevent using ../ in $this->getValue()
Comment #5
alex_b commentedUm sorry. My only excuse is that it was already late when I reviewed : ) I'll get back to this.
Comment #6
alex_b commented- Improved comments.
- Added checks for location of file targets.
- Working against latest HEAD.
Some assertions of "Mapper: FileField" test are failing.
NW. I won't be able to come back and work on this patch in a while. Will be able to review though...
Comment #7
rjbrown99 commentedTwo more issues related to getFile and paths and filenames. Perhaps we should consolidate all of the getFile stuff to one issue? All of these now have patches as well.
#706908: Enhance filefield mapper to perform more validation on remote URLs
#840350: (Optionally) Transliterate enclosure filenames to provide protection from awkward names
Comment #8
alex_b commented#7 - they're all fairly different: better validation of URLs, transliterate file names and support of local files. Therefore, I wouldn't merge them.
Comment #9
alex_b commentedDidn't mean to change status.
Comment #10
andrewlevine commentedBuilding on Alex's patch from #6
Comment #11
alex_b commentedCouldn't this be muuuch simpler?
Comment #12
andrewlevine commented@alex_b #11
Yes, that looks great. One thing I think is necessary is to add a file_exists() call because file_check_location returns a path even if the file doesn't exist.
Comment #13
alex_b commentedThere you go.
Comment #14
andrewlevine commentedLooks good to me. Feel free to commit now if you're comfortable. Either way I will be testing the patch next week.
Comment #15
andrewlevine commentedI have tested this in my own application (extending FeedsEnclosure to make sure the right file path is passed in) and saving local files works as advertised.
If this passes the tests I believe it's ready
Comment #16
alex_b commentedThis is committed, thank you.
http://drupal.org/cvs?commit=422356
Comment #17
alex_b commentedThis feature is actually broken in beta7, as referenced files get automatically deleted: #919172: Fix enclosure source files deleted
Comment #19
micheleannj commentedCan anyone confirm if this is working in beta10?