Closed (fixed)
Project:
Drupal.org security advisory coverage applications
Component:
module
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
22 Jun 2014 at 17:09 UTC
Updated:
20 Aug 2014 at 14:31 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxMiroslavBanov2290641git
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then 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
miroslavbanov commentedFixed testbot issues and reviewed another project application:
https://www.drupal.org/node/2287545#comment-8907779
Comment #3
acausing commentedKindly pin-down all items from here:
http://pareview.sh/pareview/httpgitdrupalorgsandboxmiroslavbanov2290641git
1. Please remove the master branch but making sure you have the correct branch setup first take a look https://www.drupal.org/node/1127732
2. README.txt https://www.drupal.org/node/447604 and follow this README.txt standard template
3. Please take some time to make your project page follow tips for a great project page.
cheers,
-Albert
Comment #4
miroslavbanov commentedThanks for the review.
There were only a couple of warnings for line longer than 80 characters, and they are now fixed.
Master branch deleted.
Readme added. It is detailed enough for such a simple module.
I made a couple adjustments to the project page. I think it is good enough for such a simple module. There isn't much to say.
Comment #5
acausing commentedThe changes are looking good.
1. Cleaned PAReview
2. Checked
3. README.txt could have TOC and Maintainer section but all good.
4. Project page has the image now and looking good.
Currently you have 1 Project review: Review Bonus, just reminding you that adding another two will speed-up further reviews and hopefully to full project soon.
Goodluck Mate!
Comment #6
miroslavbanov commentedAdding another review.
Comment #7
miroslavbanov commentedAdding another review.
Comment #8
miroslavbanov commentedAdding review bonus tag.
Comment #9
nuezHi MiroslavBanov,
First of all thank you for your contribution.
Automated Review
No issues found
Manual Review
A description of your module for my own understanding: Your module adds a 'fake' button to the beginning of the form that will be triggered upon 'enter' (default browser behaviour). If javascript is disabled it will just reload the page, since the browser by default will trigger a click on the first button it finds, which is the newly added but hidden button. If javascript is enabled it will either ignore the 'enter' click with a preventDefault() or trigger another button that was set in the modules UI page.
** Important issue
Comment #10
miroslavbanov commentedHi nuez,
Thank you for the review. The description of my module that you made is very on-point, and I am tempted to use it word for word in the documentation of my module.
As for the specific issues you have with my module, I do not exactly agree, but let's go through them one by one:
This is not true. My module can't do anything without javascript. Without javascript, if I add an applicable button, it will be used, pressed and the from will be submitted. If I don't add one, the next button will be used. I intend for the module to have no effect without javascript.
Could you elaborate on what alternative solution you have in mind that would take half the size and complexity, and will still solve all of the use cases that mine does. You don't need to go into much detail, just the overall idea. For instance, I considered creating the button with javascript, but that doesn't significantly cut the size or complexity. There is the obvious option to bind keydown event on every textfield/select, but that would conflict with the autocomplete.js behavior (I've seen it), and other "simple" solutions that abound. I will have to worry about event order, rather than the trivial problem of button order.
By that same logic, functions are not necessary either.
I don't agree that not using classes and having one big function that does a lot is readable, or the 'drupal way'.
It's not loaded on every page. By putting a file in the module.info
files[], this allows for the file to be parsed, and its classes to be registered, and then to be autoloaded when used, not on every page. You can test it yourself - add a file in module.info, and see if it loads.Which would accomplish the same, but I see no benefit over my current approach.
$wrapper stands for it being a wrapper of the button. I agree that $build is better.
I am not an expert either, but it doesn't appear to me that PHP code injection, or SQL injection is possible there. As you said, maybe someone can review security. I am adding a tag for needing one.
I agree that this is a good idea. In particular, I need to explain the dependency on javascript.
I am marking my this issue as "Needs review". I disagree on the only point that you mark **Important, and I am waiting for clarifications.
Comment #11
nuezHi MiroslabBonav,
Thanks for your quick reply.
Again thanks for your feedback, good luck!
Comment #12
miroslavbanov commentedRight, I agree with your next points, and will work on them. Thanks again for the review.
Comment #13
miroslavbanov commentedFixed a number of issues:
Comment #14
spficklin commentedWorks correctly on my site. Pareview.sh reports no problems and I see no conflicts with the checklist: https://www.drupal.org/node/1587704. I'm switching status to "Reviewed & tested by the community" but I do have some comments for consideration:
1) The install file pre-populates the form_ids of existing node types when the module is installed. But it left me a bit confused because I saw some of the expected form_ids but not all. Forms that are not for node types are missing. This was overcome by the box that let me add the form id I wanted. But I had to search to find the correct form_id. Perhaps the list of forms on the configure page should be empty at first and the site admin can add them as needed. Or, perhaps there should be instructions that indicate that only forms for node types are automatically added. Also, to help the user, perhaps you could add the form_id as text at the bottom of the form if the user has a given permission. This way the user doesn't have to dig around to find the form_id and it wouldn't show up for other users looking at the form.
2) I like a bit more inline documentation, especially if there are control structures (if, while, etc.) Just one liner's explaining what is going on so I don't have to study the code so closely.
3) In regards to the discussion on whether to use a class.... I do agree that it is probably not necessary since it is really only used by one function and the code from it could be placed in that function. But that's just my preference.
Comment #15
miroslavbanov commented@spficklin
1) Don't want to over-complicate things, but I may still do something about easier picking of correct form_id, if I think of anything.
2) Added some comments to the
form_default_button_form_alter()function. There may be need to comment other parts as well, but this one place is probably the most important.3) I'm thinking of changing that part, but I don't want to do that just for aesthetic reasons, or preferences.
Comment #16
mpdonadioAutomated Review
Review of the 7.x-1.x (1e2e08e) branch:
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
Manual Review
(*) form_default_button_settings() is XSS prone. Enter
<script>alert('XSS')</script>as the form ID, and click save. When the page refreshes you will get the alert.The config path should be in the .info file.
A hook_help() would be nice.
Do you need to module_implements_alter to make sure your form alter runs last?
The labels in $button_default_action_options() need to be translated. Remove the commented out option for release.
For form.form-default-button-wrapper, why can't you just use the standard .element-invisible class? If not, comment needed.
The form_default_button_form_alter() is a simple, static query. You can use db_query() w/ a placeholder here. Also elsewhere.
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
Please don't remove the security tag, we keep that for statistics and to show examples of security problems.
Comment #17
miroslavbanov commented@mpdonadio
Thanks for the review.
Fixed XSS problems.
Done.
This is not necessary. Even if it doesn't run last, it should still work.
Agreed. Will add one when I have time.
Done.
Reason is that I would like to avoid setting "display: none" by mistake. Added comment.
Will fix that when I have more time.
Comment #18
klausimanual review:
form_default_button_settings_submit(): check_plain() is wrong here: "When handling data, the golden rule is to store exactly what the user typed. When a user edits a post they created earlier, the form should contain the same things as it did when they first submitted it. This means that conversions are performed when content is output, not when saved to the database." from https://www.drupal.org/node/28984 . Instead, you should use check_plain() when you display the form_id. Even better in your case: create a validation callback to make sure that a form ID can only have alphanumeric characters and underscores, see https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.h...
Setting this back to needs work because it is important that you understand where to use sanitisation functions and where not. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #19
miroslavbanov commented@klausi
Thanks for the review. This is correct that I have to enforce valid Form IDs and show a validation error, rather than doing check_plain in submit to convert them to plain text. I didn't think about it carefully.
Also converted db_select() to db_query() as per comment #16.
Comment #20
alvar0hurtad0Manual Review
Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: I found some snippets than implements similar funcionality to include on the template but no module doing it for all forms.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: I think it follows the licensing requirements
3rd party code
Yes: I didn't found any 3rd party code so it's ok.
README.txt
Yes: It's not exacly the template, but it's very similar and clear.
Code long/complex enough for review
Yes: All code files (all but README.txt) has 438 lines of code in addition.
Secure code
Yes. : I checked al SQL querys and all of then use de database API. Didn't found any cross site, scripting possibility.
In addition I must say that the module works fine.
Comment #21
miroslavbanov commentedComment #22
miroslavbanov commentedComment #23
miroslavbanov commentedComment #24
mpdonadioAssigning to myself for next review, which will likely be tomorrow morning.
Comment #25
mpdonadioAutomated Review
Review of the 7.x-1.x branch (commit 94c3401):
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
Manual Review
I think your JS behavior may need to use the context that is passed in and/or the .once() functionality to prevent it from running more than once when AJAX events happen.
Still think a hook_help() would be nice.
Evelement level validation would be better for the form_id, rather than a global validator.
I don't really like your FormDefaultButtonElement() class. It doesn't really do much on its own without the method parameters that get passed in. It almost seems like the ClassesWithoutOo antipattern.
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
Blocking issues from my previous review have been addressed, and blocking issue from #18 has been addressed via validating the form_id (and improper check_plain has been removed). Explicitly tested both the form_id textfield and configuration textfields for XSS.
Not seeing anything to prevent RBTC. Assinging to @heddn for a second look.
Comment #26
miroslavbanov commented@mpdonadio
Thanks for the review and for RTBCing this.
I am using context already.
var $form = $('form#' + form_id, context);Then when I call
$form.find('xyz')I obviously don't need context.I agree completely.
I think it is fine just like this.
I removed it and replaced with a 'inc' file and two helper methods in it. I just have this irrational fear that this will be the cause of the issue going back to "Needs work". Why there was a class in the first place - I originally thought it would be doing more. Should have remembered YAGNI principle.
Comment #27
heddnComment #28
miroslavbanov commented@heddn
Thanks for the review. I have corrected the problems, here are the details:
Not sure if you mean that I should make them in one line or one per line. Changing them to one value per line.
I know it works without the brackets, and it also works without quotes. I am leaving it with quotes only.
Thanks for correcting my typo. I wish Netbeans could have some decent plugin for spellcheck, but couldn't find one.
I actually borrowed the idea from another module. I saw like you did, that it wouldn't work anywhere else, but I thought it was OK because it is meant to be used only there. As you say, I should have made a separate file - you really can spend time debugging such issues. Fixed.
I also tried to use "theme_table" but I had to make the form deeper and more nested to make it work, and I preferred a theme function.
Comment #29
kaarePlenty of custom template-reviews in this issue so I won't repeat that. These are some random thoughts and feedback, none of which are show-stoppers, mostly nitpicks. Not like the security issue mpdonadio found in #16, which is a rather important one to "get".
event.keyCode == 13).form_default_button.theme.inc? Isn't it enough to include the theme within theform_default_button.admin.incfile? It's not like anyone ever will override this theme, realistically, so if the.admin.incis included, so will the.theme.inc.form_default_button.admin.inc:22:Is the
WHERE 1necessary? Am I missing something here?form_default_button.admin.inc:26:"existing-$button_conf->form_id"doesn't read well, and is repeated several times down the form. I'd extract this to a separate var before to improve readability:Comment #30
miroslavbanov commentedHi @kaare,
Thanks for the review. If you think that the problems found are not stoppers, than you could change status of the application to "Reviewed".
The problem with
event.keyCode == 13and similar JS event capture techniques is that other modules are doing the exact same thing. I've seen it conflict, it is impossible to be safe, it introduces another thing to consider and maintain, and as new modules are added, it may break, and resolving such conflicts in JS events is pretty damn time-consuming. One example where this may conflict is the autocomplete textfields, but in reality there are so many other examples. This was already suggested in comment #9. Half the developers that see this implementation have the knee-jerk reaction of suggesting a "much simpler" javascript event capture. I've already considered this possibility, and have also had it implemented in a project.There is a very good case for a javascript-only solution where the fake button is added with javascript though.
I didn't find a [D7] module doing this. Maybe I should make a Q&A to defend myself on why I implemented it in this way.
You make a good point. I agree that it is not necessary to have this permission, and I will later remove this.
In comment #27, this application was made "Needs work", because the theme function was in form_default_button.admin.inc, and this was considered a misuse of Drupal theme API.
No, it's not. I will remove it later.
I will look at it later when I have time and maybe fix it.
Comment #31
kaare@MiroslavBanov: My only close to show-stopping issue was the solution's architecture, and your points are valid. I've used the few lines of javascript myself on an other project, but will consider this solution for later. The rest is just nitpicks or conflicting with other reviews. Seems fine by me, so marking as rtbc.
Comment #32
kaareCome to think about it. The exact solution of the problem should be documented and your points about conflicting event handling should be addressed on the project homepage and README.txt. This makes this module more interesting for site builders to investigate upon.
Comment #33
miroslavbanov commentedYou're right. I will explain why this solution was chosen. There already is a section the describes how the module works, just need to explain why. The technique is interesting as an example of how to preemptively avoid getting into trouble.
Comment #34
heddnSome clarification about the theme comment in #2290647-27: [D7] Form default button. The theme definition could have stayed in the admin.inc (although a little strange). The important thing was to list the 'file' in the theme definition.
@kaare, your questions about use #2290647-29: [D7] Form default button and follow-up in #2290647-32: [D7] Form default button did a good job of describing what I was mulling over in my head. The addition of the use case for why to use this module are extremely helpful and make this module way more compelling. Updates to the README and project page are indeed a good thing.
However, seeing no further blockers...
Thanks for your contribution, MiroslavBanov !
I updated your account so you can 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 stay 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 #35
klausiLet's keep this as fixed, it will auto-close in 2 weeks.
Comment #36
miroslavbanov commentedThanks @heddn for promoting the project
And thanks to everyone that helped me by reviewing.
Later today, I will do the adjustments from #30, and will add the add to the documentation as per #32, #33, #34. I will also move the theme function to the admin.inc and will adjust the 'file' value to point to it.
I improved my knowledge of what can be relevant as developer-oriented documentation, which is sure to be useful in the future.