Closed (fixed)
Project:
Drupal.org security advisory coverage applications
Component:
module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
20 Oct 2011 at 05:40 UTC
Updated:
6 Aug 2018 at 08:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
elc commentedThank you for taking the time to submit your project for review. Before it can have a full code review, there are quite a few things that need to be addressed.
Projects submitted to this queue are meant to be release ready and demonstrate that you are ready to manage a project up to the highest standards. We all want quality modules on d.o and getting them means taking time and care to ensure that every module you create now and in the future will meet or exceed those standards. Please see Best practices for creating and maintaining projects, and Tips for ensuring a smooth review. Review process for Full Project Applications: What to Expect
drupal_set_message("Your feed settings have been saved. Data has been change accordingly.");These values are used DIRECTLY in HTML output without any kind of processing. Only 'administer site configuration' can edit, but use input must always be processed. Administrator is subject to XSS attacks, just like anyone else. Strings also used directly in HTTP requests.
- no it doesn't.
This can also be compressed to one line. No need to keep separate.
$query = "SELECT * FROM socialmediafeed_post ORDER BY time DESC LIMIT $displaycount";This one is stupendously unsafe .. you're actually letting a foreign site dictate exactly what to put in your database without any kind of validation.
Please look at db_placeholders and db_query documentation.
Thu Oct 20 01:31:55 2011 -0400 39abaa7 Second commit.Wed Oct 19 23:04:09 2011 -0400 bbe4b1a Third commit.
Wed Oct 19 11:22:21 2011 -0400 2ed144a Initial commit.
A small review.
When you have addressed all these issues, please set the issue back to 'needs review'. If you have any questions, please don't hesitate to ask.
Comment #2
BPI commentedMade many modifications.
Comment #3
elc commentedFor example - the socialmediafeed_settings_form()'s validate and submit functions. The validation function:
This does NOTHING, and even lies to the user since nothing has been saved at this point.
Also, this has a great example of useless validation; you are running check_plain() on a static string. That dsm should be cut down the following, and actually moved to the end of the submit handler:
The validation function should be going through every user input, making sure that it's valid, and if it's not, calling form_set_error() on it so that the user is presented with an error and and oppertunity to change their input.
The submission function isn't even called until this validation function has been passed without form_set_error being called.
eg. socialmediafeed_facebook_profile_id should no doubt be an string of digits and letters only, so if someone enters "Frank Sinatra", your validation function should reject based on this and tell them that they need to be entering only digits for that field.
.. but considering you just turn it into an array 10 lines later .. what's the point of using a class at all???
(function name is also not correct)
Indenting is still a bit all over the place, but at least there aren't any tabs in there any more. You still need to fix these up.
Please revist all the points from my previous post to make sure you have addressed them all, along with all of the ones in here before changing back to 'needs review'.
Comment #4
BPI commentedUpdated the module to accommodate your recommendations. Let me know what you think!
Comment #5
klausiComment #6
elc commentedYou shouldn't have to do this .. in this particular instance, if you don't want anything with xss exploits in it, then don't allow them through the validation function.
This is still wrong. It's a table name and it might have a prefix.
You have cached the data pulled from the social sites in your own set of tables which is good for speeding up that part.
BUT, every page load causes a whole series of queries on data you know is not going to be changed. The data is only updated when cron is run which means you can cache the output going to your blocks for at least that amount of time. If you use permanent caching then you reduce N queries down to 1.
see cache_set, cache_get.
The project application/review queue is not meant to be a massive hurdle. If you follow the instructions for submitting your project, use the Drupal API where you can, and heed the advice of other reviewing your code, it should be a fast and painless process. Everyone wants quality modules when they come to d.o, and for that to happen, everyone creating new projects has to ensure that they are the best they can be and they follow the best practices for security, and coding. We want your current and future contributions to be the best they can be!
Please ensure you address all of the issues raised in all posts. Either in code, or in text.
Comment #7
BPI commentedThanks guys for your comments. I will take my time cleaning this up and send it back shortly.
Comment #8
BPI commentedI fixed everything listed with the exception of the caching.
1. Code - I removed the filter_xss function because now Im dicating exactly what each input field needs in the validate function. I also added the brackets to TRUNCATE sql statement to keep it compatible with prefixing.
2. checking return values - I now in my implementation of hook_cron, each data retrieval function only runs if its necessary variables are set.
3. requirements - I am now requiring SimpleXML to be installed before the module can install.
4. caching and logic flaws? - I am only running one database query to build the block function so this seems unnecessary.
5. security - My validate function for my form limits user input and my database functions filter the individual data values before they reach the database.
Let me know what you think.
Comment #9
klausiplease go through my comments in #5 one more time, at least 2 of them still apply.
Comment #10
BPI commentedThanks Klausi. I must have missed your message. I've addressed all of your flags. Let me know what you think.
- .DS_Store is now included.
- README updated previously.
- Removed all third party scripts.
- Removed space below doc block.
- Fixed spacing issues.
- Added function doc blocks where they were missing.
- I wrote this module using curl before I knew of the drupal_http_request() function. I'm hoping to add it in a later release after adequately testing to see if it suits my needs.
Comment #11
jthorson commentedBPI,
Regarding #10 ... did you forget to 'git push'? I checked the first three items from #5, and all three issues are still present.
(And I supsect that .DS_Store should be 'excluded', not 'included'.)
Comment #12
elc commented@jthorson You've been bitten by the "master being full of old files" bug!
@BPI
Based on commit 6a8a4db84ed0b9277bccac0e0ce9a03b12e682b6, Sun Nov 6 21:09:40 2011 -0500
Moving from a master branch to a version branch.
Comment #13
BPI commentedThanks guys for your suggestions. Here are my comments.
master branch
I cleaned the master branch and added a readme file that tells the user to use version branches.
security issues
I'm unsure what you mean by this. I'm manually setting the field names and don't see how that is a security issue.
table handling
Everywhere a table is used in SQL transaction is wrapped in brackets which I thought was the solution.
3rd party code
There is no 3rd party code used here.
indenting
Fixed these indentation instances.
Comment #14
elc commentedThis is pretty close to ready, but it does have a few issues. The first two are should be considered functionality bugs, and the others are Coding Standards issues.
ditto twitter
ditto youtube
ditto foursquare
if (!$myterms)is indented once more than it needs to be.Comment #15
BPI commentedUpdated. Let me know what you think. Thanks
hook_menu - updated the permission name and enforced the correct argument.
socialmediafeed_facebook - updated database recording query to use drupal_write_record on all insert functions.
css/socialmediafeed.css - fixed spacing and tabbing issues.
js/socialmediafeed_form.js - fixed spacing and tabbing issues.
readme.txt vs README.txt - update the readme file to be README.
hook_schema - updated the schema function to not translate.
socialmediafeed_youtube - fixed indenting issues here.
Comment #16
elc commentedNo further blockers, but these recommendations still stand for the module and can be dealt with at some point. Setting to RTBC for review by someone else.
highly recommended
merely recommended
.. and then commit it. It's still lower case in all branches. Windows will not rename a file on the drive via the GUI if you keep the same name and only change the case.
Comment #17
BPI commentedOk. I will make these changes on my next rollout. Now how do I get this project out of sandbox?
Comment #18
klausiThere are still files other than README.txt in the master branch, make sure to remove them. See also step 5 in http://drupal.org/node/1127732
Review of the 6.x-1.x 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. Go and review some other project applications, so we can get back to yours sooner.
manual review:
Comment #19
BPI commentedThanks Klausi. Here is what I did.
1. Updated the README.txt on the master branch and renamed the one on the version branch.
2. Addressed the drupal code sniffer results and ran it through Coder on minor.
3. Replaced all CURL instances with drupal_http_request.
4. Updated comments for the socialmediafeed_settings_form() callback to make better sense.
5. I currently have it this way for organizational purposes just but kept it consistent in all 4 applications (Facebook, Twitter, Youtube, Foursquare).
Comment #20
BPI commentedComment #21
BPI commentedHey klausi, I know you are swamped with these applications but its been a couple of weeks and the last few reviews implied this is basically done. Can you take one last look at it? Thanks!
Comment #22
klausiSorry, I can only find time for applications with a review bonus, see #1410826: [META] Review bonus.
Comment #23
elc commentedIn the function socialmediafeed_facebook, you first ask for an access token from graph.facebook.com but not once do you check that the result is valid or has been trimmed correctly. If this has an error, it will just continue one throwing errors and attempt to access resources that do no exist.
In socialmediafeed_twitter you don't catch any errors potentially caused by new SimpleXMLElement($buffer->data) (or check that there is something to parse in the first place) and again the errors are ignored.
Ditto youtube. foursquare.
Errors and timeouts do happen. Stick a firewall rule in place to block the traffic going to one or all of these places and see what kind of fun errors turn up, or just code with failure as an option.
Comment #24
BPI commentedThanks for that ELC! I've addressed the issues you've raised. Let me know what you think!
Comment #25
elc commentedIt looks like it is pretty much ready to go. There is one rather large outstanding issue though. The use of die() has adverse flow on effects and should not be used for this kind of situation (no other cron tasks will happen, none of the exit functions are called, silent failure).
While this might work, it should not be used at this level. SimpleXMLElement will also throw exceptions and throw errors if it does not get its way.
SimpleXMLElement will throw an excepting and raise E_WARNINGs for every error it encounters in the XML. It needs a try/catch around it and to have the errors suppressed. If it doesn't end up with valid XML at the end (in the catch), then no further processing should happen.
http://www.php.net/manual/en/simplexmlelement.construct.php
I ran the coder review over the module just for fun to see if someone would be bouncing it for that and there are quite a few things it has picked up. Since the code is readable and this is well into the manual review process, these are in no way blocking issues, I leave them as an advisory of things that could be fixed up.
http://ventral.org/pareview/httpgitdrupalorgsandboxblueprintinteractive1...
Anyway, the handling of the XML looks to be the last sticking point as the rest look good. Sorry I missed the error handling on the XML before as I did not check how it handled errors until it had the die() next to it.
Comment #26
BPI commentedYou are absolutely correct. The die function is just as bad as throwing an exit in there. I've removed it and added the try/catch statement in both instances of the simplexml. Let me know how you feel about it. Thanks!
Comment #27
elc commentedThe die is gone, and the handling of the result looks good enough beyond that. Nothing else was changed beyond that so the rest of the module still stands and ready to RTBC.
There are still a lot of coding standards issues in there that you should look at at some point.
For future reference
From here, another git admin will have to do one more final review the module and if they find no issues, set it to "fixed" and grant git vetted status. If they find any issues, it'll be set to "needs work" with appropriate instructions.
Comment #28
klausiReview of the 6.x-1.x 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. Get a review bonus and we will come back to your application sooner.
manual review:
Comment #29
BPI commentedMade updates per your revision notes.
1. I left this function as is because I needed to make more processing after the variables are set but will keep this in mind the future.
2. I've updated all links with the link function.
3. This image is an externally hosted image so this function will not work.
4. Sanitized the output of all of data.
As for the code itself, I ran through coder and coder tough love.
Thanks Klausi!
Comment #30
lucascaro commentedHi @BPI, I've ran pareview.sh and it's still seeing some errors:
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. Get a review bonus and we will come back to your application sooner.
(attached a .txt file with the rest of the output)
Make sure you have pushed your latest changes to the repository and that you use the latest -dev of drupal code sniffer so you see all the errors.
1. about point number 1, keep in mind that you can add your own processing to system_settings_form using $form['#submit'][] = 'your_callback', so potentially you could make it easier to maintain by not having to set all variables.
3. according to http://api.drupal.org/api/drupal/includes!theme.inc/function/theme_image/6:
so you should be able to use theme('image') for external images as long as you set $getsize to FALSE.
Comment #31
jthorson commentedI'd also recommend the changes as identified in comment #30.
However, the sanitization issues from #28 appear to have been addressed ... and perhaps excessively in some cases. ;)
Given this, bumping back to RTBC.
Comment #32
jthorson commentedComment #33
avpadernoComment #34
klausi@kiamlaluno: Please provide this message if you approve an application (see http://groups.drupal.org/node/184389 ):
Thanks for your contribution, BPI! Welcome to the community of project contributors on drupal.org.
I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.
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.
As you continue to work on your module, keep in mind: Commit messages - providing history and credit and Release naming conventions.
Thanks to the dedicated reviewer(s) as well.
Comment #35.0
(not verified) commentedCorrected git URL.
Comment #36
avpadernoComment #37
avpadernoComment #38
avpaderno