Closed (won't fix)
Project:
Drupal.org security advisory coverage applications
Component:
module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
3 Aug 2012 at 12:54 UTC
Updated:
9 Apr 2013 at 22:25 UTC
Module Description:
This module allows you to select which assets (CSS and JS) files you want to include or exclude in individual pages.
The module rewrites the page header by adding or removing the assets, based on rules defined by the admin.
My motivation for developing this module was to reduce Drupal pages footprint by removing unnecessary JS/CSS from pages that don't use them.
Project page: http://drupal.org/sandbox/adenot/1711614
GIT: git clone http://git.drupal.org/sandbox/adenot/1711614.git selective_assets
Drupal 7.
Thanks!
Comments
Comment #1
patrickd commentedwelcome
It seems that
http://drupal.org/project/context
http://drupal.org/project/context_addassets/
provides very similar functionality. Could you describe how your module differs?
We prefer collaboration over competition, therefore we want to prevent having duplicating modules on drupal.org.
If the differences between these modules are not too fundamental for patching the existing one, we would love to see you joining forces and concentrate all power on enhancing one module. (If the existing module is abandoned, please think about taking it over).
You are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
As installation and usage instructions are quite important for us to review, please take a moment to make your project page follow the tips for a great project page. Also have a look at the guidelines for in-project documentation.
Also, NEVER use ?> at the end of your php files.
An automated review of your project has found some issues with your code; As coding standards make sure projects are coded in a consistent style we please you to have a look at the report and try to fix them. Anyway, note that issues found are possibly false positives and fixing all issues is not a requirement for getting through the application process.
Report: http://ventral.org/pareview/httpgitdrupalorgsandboxadenot1711614git
We do really need more hands in the application queue and highly recommend to get a review bonus so we can come back to your application sooner.
regards
Comment #2
adenot commentedHi patrickd,
thanks for you time reviewing the module.
Comparing my module to Context AddAssets (and also CSS_Injector), first main difference I can point is that my module can not just add, but remove assets from any page specified by path. Another difference is the ability to add assets from external domains, like CDNs.
From my own experience, Context, although is a very complete module, seems to be an "overkill" if the administrator only needs to add or remove some assets from one or two pages. This happened to me before, when developing a site for a financial institution, we decide to hard-code the header changes needed in specific pages. Firstly because we couldn't find a module that could remove assets from a page and secondly because we prefer to only add modules when they are very necessary and the ones with a lighter footprint (i.e. modules made for solving one problem).
I do understand that collaboration over competition is very important and I am looking forward to contribute with other modules.
From your feedback, I've done:
Regards,
Allan.
Comment #3
patrickd commentedOkay, but maybe we should spend some more time searching for a similar module, I somehow can't believe that this doesn't exist yet ;)
don't forget to switch back to needs review if your ready
Comment #4
adenot commentedFound one: http://drupal.org/project/stylestripper
But seems to strip Styles only and no Drupal 7 version.
Yes, it's hard to believe that there is no module to provide this control over page assets, that's why I built one :)
Comment #5
adenot commentedFor reviewers:
We are researching for modules that might be similar to the one I've asking for approval, if you know about one, please post here so we can continue the review process, otherwise please indicate that you could not find any similar module. Thanks.
Comment #6
adenot commentedHi patrickd,
has been 2 weeks before your last update, please let me know if there is anything I need to work on my module or kindly approve it.
Regards.
Comment #7
patrickd commentedI'm sorry for the delay!
There are about 100 other applications waiting for review and only a hand full of active reviewers.
We do really need more hands in the application queue and highly recommend to get a review bonus so we can come back to your application sooner.
Comment #8
Milena commentedIn your .install file you have some commented mysql code. Please, remove it.
In your .module file
You do not need to include selective_assets.inc as long as you have 'file' element in your hook_menu()
Your class probably should be added as files[] in your .info file rather than including it here.
In your selective_assets.admin.inc you have:
'#empty' => t('No rules available. <a href="@link">Add an asset rule</a>.', array('@link' => url('admin/config/selective_assets/add'))),I believe you should use l() function instead of a href.
is_int function is sufficient. If $pid is null is_int() returns false.
variable_get('clean_url', 0)This is a user input. You should make sure it is safe. I think this is a security issue.
In your selective_assets.inc
/* print_r(drupal_get_schema('selective_assets'));exit(); */Please, remove any commented code.
In your class file
You check for extension by substr function:
PHP has its own method of checking extensions (and protocol also)
$ext = pathinfo($asset, PATHINFO_EXTENSION);I'm still pretty new in reviewing modules, so if any of above issues is mistakenly pointed and application should not go into needs work status please, feel free to change.
Comment #9
adenot commentedHi Milena,
thanks for your review. My comments are below.
I don't agree that the SQL schema comment should be removed since it's very useful for developers to read the database schema in SQL language that they might be more familiar with. But I am removing it so the module can get approval.
The 'file' element does not support multiple files, thus I moved the include_once of selective_assets.inc (database functions) to selective_assets.admin.inc file, where it makes more sense to only include when admin operations need to change the database.
Also, the class is now included using files[] in the info file.
Fixed. but please have a look on [drupal core]/modules/path/path.admin.inc around line 82. :)
Fixed.
variable_get is not a user input, but a query in database's variable table. Again, [drupal core]/modules/path/path.admin.inc line 131 has the same code.
Using pathinfo will make the code longer and more complex, as 2 lines of code will be required to check the extension, also pathinfo will try to break down the path into its parts, which is unnecessary and more resource consuming.
If you are happy with those changes, please recommend approval or approve the module.
Comment #10
adenot commentedupdating status.
Comment #11
Milena commentedHello,
Its coding standard that you should not include any commented code in your module. There is an option to look into the table schema through some application or database itself. It is not an application blocker though.
a link was not an application blocker. Even in Drupal core there are some things that not follow coding standards. It is good though that you know something about core :)
// drupal_clear_path_cache($rule['url']);This should also be removed.But as I said before it is not an application blocker.
I like your code, there is no security issues in my opinion and you know how to use Drupal API. It's RTBC for me :)
Comment #12
adenot commentedHi Milena, thanks very much for your update! Glad you liked my code :)
Comment #13
adenot commentedComment #14
adenot commentedRaising the priority. More than 4 weeks since last update without an approval :(
Comment #15
cubeinspire commentedVery nice module and interesting use of the API !
automatic review (coder)
selective_assets.admin.inc
severity: normalLine 71: String concatenation should be formatted with a space separating the operators (dot .) and the surrounding terms
severity: normalLine 71: missing space after comma
'#empty' => t('No rules available.')." ".l(t('Add an asset rule'),'admin/config/selective_assets/add'),severity: normalLine 92: else statements should begin on a new line
} else {automatic review (PAReview.sh)
There are more than 30 code standard problems.
http://ventral.org/pareview/httpgitdrupalorgsandboxadenot1711614git
manual review
1. This is vulnerable to XSS exploits. The url is user provided input and needs to be sanitized before printing into HTML. See http://drupal.org/node/28984 . Please check if there are other variables to parse before output.
Writting
<script>alert('hello');</script>as the url on Home » Administration » Configuration » Selective Assetspopups an alert.
The security issue is a blocker so I set needs work again.
Comment #16
adenot commentedhello logicdesign,
Thanks for your time on reviewing my module.
Most of the issues in the automatic review are now fixed.
About the issue on XSS I fixed by stripping tags when the form is submitted, preventing users to enter html code.
Hopefully the module is now ready for the public :)
Allan.
Comment #17
cubeinspire commentedConcerning XSS attacks the rule is to parse the data on the output, not on the reception.
Another unsafe function could hook the value and change it with unsafe value after, then the "sanitation" you made would be broken.
Comment #18
adenot commentedHi logicdesign,
I added strip_tags when the form is submitted now.
Thanks,
Allan.
Comment #19
anton-staroverov commentedHi adenot,
1) There are still some issues at http://ventral.org/pareview/httpgitdrupalorgsandboxadenot1711614git
2) selective_assets.admin.inc, line 9: As I remember you should start include paths from DRUPAL_ROOT in Drupal 7 accordings to standard. Check that again please.
3) selective_assets.install: it's minor but I think it's better to use 'path' instead of 'url' for column name containing a path to match.
4) UI: Do you plan to have some predefined rules?
5) UI: I also think there should be an ability to enable and disable individual rules like you can enable and disable views and blocks.
Comment #20
adenot commentedHi Tony,
Thanks for you time on reviewing my module.
1. The issues encountered in the Pareview are minors, so it shouldn't be a reason for rework.
2. I don't think it's necessary to use DRUPAL_ROOT since the include is relative to the module, DRUPAL_ROOT will give me the root, and not the module folder.
3. Again that shouldn't be a blocker.
4. Not at the moment, as the module gets approval I can get some feedback from the users and implement this feature if required.
5. Thanks for the suggestion, as the module gets approval I will be happy to accept this as a feature request.
Comment #21
aritra.ghosh commentedHii,
I think you cannot RTBC your own application.
Please wait form someone else to review your project and RTBC your application if everything is all right.
Also Please try to participate in Review Bonus programme and review 3 other applications. This will make this process faster and a git admin will look at your project right away.
Changing the status to needs review.
Thanks,
Aritra.
Comment #22
adenot commentedHi Aritra,
The reason I changed to RTBC is because that was the previous status before further reviews were made. Considering that the module is in review for more than 3 months, I don't see a reason for keeping it in "needs review" status.
Is this a requirement that I need to review other 3 projects to get my module approval? My understanding is that this would accelerate the proccess but not prevent the module for getting an approval if I don't do it.
Regards,
Allan.
Comment #23
aritra.ghosh commentedHii Adenot,
First of all it is certainly not a requirement to review 3 projects but that does certainly accelerate the process, at least so was in my case. Considering your application is in queue for 3 months, I would certainly advise you in favour of it since it took just over 2 weeks in my case. But definitely that is not the requirement.
Secondly, after previous RTBC state,some issues were pointed out and you worked on fixing them. So again you need to change the status to needs review. When other reviewers find the changes have been appropriately made they will RTBC your application, but you yourself cannot.
Thanks,
Aritra.
Comment #24
jibranJust a little correction
'#empty' => t('No rules available. <a href="@link">Add an asset rule</a>.', array('@link' => url('admin/config/selective_assets/add'))),this is actually right and doing this'#empty' => t('No rules available.')." ".l(t('Add an asset rule'),'admin/config/selective_assets/add'),is so very wrong.For further info please consult Dynamic or static links and HTML in translatable strings
Comment #25
adenot commentedFixed.
Comment #26
adenot commentedChanging to previous status and removing security tag as it was fixed.
Comment #27
anwar_maxYou cannot change the status of your application to RTBC as mentioned by aritra.ghosh and you cannot remove security tag.
Comment #28
adenot commentedEverything is fixed and in review for 5 months, I can't understand why the module is not approved.
Comment #29
martin mayer commentedHi adenot!
The automated review found this:
Pareview found some issues: http://ventral.org/pareview/httpgitdrupalorgsandboxadenot1711614git-7x-1x
The errors in SelectiveAssetsAddRemove.class.inc mean that you must write comments before each function. I understand your frustration about the long review time, but this are real errors and I am afraid I must set the status to "needs work" for this. The upside is, it is easy to solve this issue :-)
The warnings in .module mean, that there is no need to document the parameters of a hook, because they are already documented in the Drupal API documentation. You should delete the @param comments.
As it is already very late now, I will finish the review for today. I will come back to you with the code review very soon.
Cheers
Martin
Comment #30
martin mayer commentedHi adenot!
As I promised yesterday, here is my module test and code review:
The module configuration should become accessible through the configuration page. You should add the configuration link to one of the available categories. Therefore, in hook_menu
should become something like this:
When I tried to remove the style.css of bartik from a certain page, I could do it by writing style.css into the "Exclude assets" field. It did not work when I specified the whole path /themes/bartik/css/style.css with the leading "/" as you describe in your README.txt. It worked only without the leading "/". I think you should change this in your README.txt.
Apart from that the module looks fine. I read through your code and it seems very well. I think after this corrections it should be promoted to reviewed and tested by the community.
Just for your information: You wrote in #9 "The 'file' element does not support multiple files". You can use more than one files[] directives in a .info file. Look at the .info files of this core modules as examples:
modules\field\field.info
modules\openid\openid.info
modules\search\search.info
modules\system\system.info
But in your case it seems ok to use include_once for selective_assets.inc.
Comment #31
PA robot commentedClosing due to lack of activity. Feel free to reopen if you are still working on this application.
I'm a robot and this is an automated message from Project Applications Scraper.