This module provides a way to hide absolute paths to files from the
page source, even if your Drupal instance is using the Public download method.
For example, when an anonymous user clicks on a file path altered
by Hide Filepah, they're asked to login first and then redirected to the file.
It especially comes in handy if you want users to be prompted to login first
before viewing or downloading files. You can show them
an access denied, or 404 page. There's also the option for a module developer
to hook into the processes and do their own thing.
Note: This is not a security module since you can still hit the direct file path and gain access if you can construct the path manually. But it does play a little off of "security through obscurity".
Hide Filepath Sandbox Project page
Git
git clone --branch 7.x-1.x git.drupal.org:sandbox/eriknewby/1861422.git
Project Reviews:
http://drupal.org/node/1976534#comment-7338482
http://drupal.org/node/1510564#comment-7333654
http://drupal.org/node/1266460#comment-7333630
http://drupal.org/node/1998762#comment-7434058
http://drupal.org/node/1995434#comment-7433670
http://drupal.org/node/1982026#comment-7433694
Comments
Comment #1
PA robot commentedWe are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #2
tmctighe commentedErik,
The module installed, configured, and worked simple and easy. The video helps to easily understand!
1. This module has a couple minor pareview errors: (http://ventral.org/pareview/httpgitdrupalorgsandboxeriknewby1861422git)
2. Coding standards: A couple points:
In hide_filepath.install you initiate variables however do not implement a hook_uninstall to remove those variables.
Also, the db_query should be changed to a db_update (see: http://api.drupal.org/api/drupal/includes%21database%21database.inc/func...)
3. The module appears to support image fields and the video module - it would be good to list this on the Project page. In general, separating that first paragraph on the project page into sections "Use Case Scenario" and "Features" might help users understand what the module does.
(Also, the functionality for hiding videos did not work for me on a clean installation.)
Otherwise the module looks good!
Comment #3
eriknewby commentedThanks for reviewing tmctighe.
Updated:
Will also update the project page.
As for supporting the video module, though some of the code is in place, I haven't documented it yet since I would like to treat that as a second release feature.
Given that, I may pull it out of the branch and place it in a separate dev branch.
Comment #4
pranit84FILE: /var/www/drupal-7-pareview/pareview_temp/hide_filepath.install
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
29 | ERROR | Missing function doc comment
--------------------------------------------------------------------------------
Comment #5
eriknewby commentedThanks pranit84.
I've fixed the function doc comment.
Comment #6
eriknewby commentedComment #6.0
eriknewby commentedupdated wording, and added branch to git repo
Comment #6.1
eriknewby commentedadding project reviews
Comment #7
eriknewby commentedadding review bonus
Comment #8
klausimanual review:
Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #9
eriknewby commentedExcellent! Thank you so much for the valuable and helpful feedback, klausi
I will report back soon once I've had a chance to rework these items.
FYI, this is definitely not meant to be a security module. Simply to provide a little obfuscation to file paths and provide the admin a few configurable options.
Since my description may have been unclear, I will make sure that is clearly stated on the project page.
Thanks again!
Comment #10
eriknewby commentedI've finally had some time to make some updates to the module based on klausi's feedback.
1. Added a disclaimer to the README and project page about this *not* being an actual security module
2. removed juggling of module waits in favor of hook_module_implements_alter()
3. Added note that currently "node" is the only supported entity.
4. Added module_api file
5. Replace "und" with LANGUAGE_NONE
6. Removed unnecessary check_plain()
7. updated form to use drupal_get_form and directly invoke form builder
8. removed empty function hide_filepath_settings_validate()
Comment #11
eriknewby commentedhttp://drupal.org/node/1998762#comment-7434058
http://drupal.org/node/1995434#comment-7433670
http://drupal.org/node/1982026#comment-7433694
adding review bonus.
Comment #12
ayesh commentedSome minor suggestions:
In hide_filepath.install:18 : It's better if you use the a tag in the t() function. This makes is less confusing to translators.
Ex:
Using the a tag directly makes it much easier to translate the string, and that's the recommended way (There was a doc file describing it but couldn't find it yet).
hide_filepath.module:38: You are implementing hook_form_FORM_ID_alter.
hide_filepath.module:180: UID is an integer.
hide_filepath_settings.inc: Is there any reason why you didn't use system_settings_form() ?
Comment #13
eriknewby commented@Ayesh,
Thanks! That tag based url in t() is new to me. Cool! I've added it.
Fixed the function comment
Fixed the integer in the if statement.
Could you elaborate on why/how to use system_settings_form()? I'd be happy to, I just don't think I understand what I did vs. what you are suggesting.
Thanks again!
Comment #14
nsuit commentedI enabled your module, set the settings to "Access denied for Anonymous" users, but when I as anonymous clicked on the file link in my node it still loaded the file. Let me know if I misunderstood the purpose of the module.
Minor issue, Code_sniffer found two space issues.
FILE: .../nathalie/Sites/drupal-7.20/modules/hide_filepath/hide_filepath.install
--------------------------------------------------------------------------------
FOUND 2 ERROR(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
20 | ERROR | Line indented incorrectly; expected 2 spaces, found 1
21 | ERROR | Line indented incorrectly; expected 2 spaces, found 0
--------------------------------------------------------------------------------
Comment #15
eriknewby commentedHey nsuit,
Thanks for taking a look. I've fixed the indentation issue you listed.
As for your Anonymous access issue, did you have a chance to look through the README? I'm specifically wondering if you missed this step:
Without that step, any and all file fields will continue to function as normal.
Comment #16
eriknewby commentedComment #17
ayesh commentedWhat I mentioned was actually to make use of the system_settings_form() function from core, that adds the proper "Save configuration" button and does the variable_set part for you.
Change
return $form;withreturn system_settigns_form($form);.This will add a submit button and a handler that saves values using variable_set. Variable names are taken from the $form_state['values'] array (thus, the key from the $form array).
This is all you need in the hide_filepath_settings.inc:
You don't need to add a submit button and/or a submit handler.
Also pay attention to the variable_get() call, that we have a second parameter which returns in case the value is not set. variable_get function requires parameters by default - the variable name and a value to return in case the value is not set already.
Module worked well for me, and really nice work there. Good luck!
Comment #18
eriknewby commentedExcellent explanation, @Ayesh! Thanks for taking the time. Much appreciated.
I've updated the .inc with system_settigns_form(); and will use this approach from here on out in other projects as well :)
Comment #18.0
eriknewby commentedadding review
Comment #18.1
eriknewby commentedadding more project reviews to topic (also listed in comments)
Comment #19
jared_sprague commentedNice work Erik! This looks RTBC to me!
Comment #20
klausiComment #21
klausiPerformed a manual code walkthrough with Erik here at Drupalcon, no critical blockers left.
manual review:
Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Assigning to cubeinspire as he might have time to take a final look at this.
Comment #22
eriknewby commentedAfter speaking with klausi at Drupalcon Portland, I've updated the following per his suggestions
1. Removed the nasty hook_init() hacking and replaced with a clean hook_menu() :)
2. Fixed the naming of hide_filepath_api.php (examples will be added at a later time)
3. Removed check_plains and exits: that were unnecessary
Number one was the most important here. This makes sure hide_filepath actually gets called on pages where its needed, rather than every single page.
Thanks again klausi.
Comment #23
klausino objections for more than a week, so ...
Thanks for your contribution, eriknewby!
I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
Comment #24.0
(not verified) commentedupdating description to include "note"