Closed (fixed)
Project:
Drupal.org security advisory coverage applications
Component:
module
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
6 Sep 2018 at 20:00 UTC
Updated:
26 Oct 2018 at 09:29 UTC
Jump to comment: Most recent
Comments
Comment #2
aporieComment #3
avpadernoComment #4
sumit-k commentedHi Aporie,
Please fix the pareview errors reported.
https://pareview.sh/pareview/https-git.drupal.org-project-ubercart_funds...
Comment #5
avpadernoComment #6
aporieHi bsumit5577,
I have updated the code. Please pull.
There is still some things I don't know how to fix :
How can I fix that ?
Comment #7
avpadernoA function/method name uses the lower camel format when it is, in your case,
preRender().Comment #8
aporieYes, but doing that breaks the handler ... As it is a function from the extended class.
Comment #9
avpadernoIf the class implementing that method is replacing a method another module's class defines, ignore the warning, since you cannot change the method name.
In this case, change the status to Needs review.
Comment #10
aporieOk, thanks.
Comment #11
aporieComment #12
avpadernoPAReview still reports errors. The most important are the following are:
t()norst()should be used directly. The code should use$t = get_t();and$t('string to translate')to get the translation of a string.I will make a manual review later today.
Comment #13
aporieHi kiamlaluno,
Ok I will take a look to the PARreview errors.
Thanks for taking a look to the module after. I hope everything will work well, now it's been a while I didn't take a look at it I have doubt :) (But if I opt-in for security it's because I performed a lot of tests before).
Thanks again.
Comment #14
avpadernoThe LICENSE.txt file needs to be removed.
The code is deleting a persistent variable used by another module, or the variable name is wrong and it should be ubercart_funds_withdrawal_methods.
The database table names should be prefixed by the module name.
Those function calls should not be outside functions.
Block machine names should be prefixed by the module name. The same is true for routers specific to the module (defined in
hook_menu()), and theme functions (defined inhook_theme()). For theme functions, the template name must match the theme name, in Drupal 7. You cannot have site_balance as theme name and ubercart-funds-account-balance as template name.Instead of using a page callback that is calling
drupal_get_form(), the route should use'drupal_get_form'as page callback andarray('ubercart_funds_deposit_funds')as page arguments.The documentation comment should be more descriptive than Definition of _ubercart_funds_get_site_balance(). which is just giving known information (the function name).
What is wrong in that code?
There are standard documentation comments for submission and validation handlers.
That is not the way submission handlers do redirects.
Validation handlers don't return Boolean values; they just set an error message for the form or the form element. Validation handlers then don't return after the first error found.
There isn't the need to give two different error messages (and duplicate code) when it's sufficient to use The value must be a positive integer. as error message.
There isn't any need to compare usernames when it's enough to compare the user IDs.
What happens if the uc_funds_user_funds table doesn't have records for the user?
Is it necessary to use strict comparisons?
Comment #15
aporieHi kiamlaluno,
Haven't forgotten you, I hope I'll have a bit of time this weekend to take a look to your feedbacks.
Thanks BTW for your review.
Comment #16
aporieHi kiamlaluno,
I've started working on the modifications, but have a lot to do on commenting correctly the code.
In the meanwhile, prefixing the blocks name with the module name return a php error : "String data, right truncated: 1406 Data too long for column 'delta' at row 1". I don't want to lose pieces of information on setting the delta name. The name is now : ubercart_funds_admin_site_balance for example. Any idea what I can do about it ?
Comment #17
aporieHello,
I have updated my code. I've done my best to do it correctly but this is my first drupal module (and I guess managing one is far enough).
I have named my blocks "uc_funds_BLOCK_NAME" to avoid the error above. I know we should prefix everything with the module name to avoid conflicts between modules, but when we have a module with a long name (as ubercart_funds) it often ends up with error (and mostly with coding standards), so I don't know what I can do about that ...
Some details to your feedbacks :
--> module_load_include is not the good function to load files in modules. I have used include_once but I'm still not sure of the proper way for doing that.
--> For prefixing block name with module name, see above.
--> What happens if the uc_funds_user_funds table doesn't have records for the user? In the case you shown it's not possible that the user doesn't have a balance record as it is the issuer. The form validation will return an error saying the user doesn't have enough funds to cover the transfer.
I know my code and comments can be improved a lot, but for now what I wanted is a secure module to allow user to make transfers together. If anybody has security advises for me, I'm totally open to them.
I still have some PAReview error and know it (please see comments above) :
Comment #18
aporieComment #19
avpadernomodule_load_include()is the correct function, and it is used from Drupal core modules. You cannot use it outside functions, but the same is true forincludeandinclude_once, which could cause problems when a module file is included by Drupal core (especially in early bootstrap time).What I meant is that
drupal_write_record('uc_funds_user_funds', $issuer_balance, 'uid')only updates an existing record; it doesn't create one if it doesn't exist. If you need to either update an existing record or create it,db_merge()is the function for that task.Comment #20
aporieHey,
There are two ways of creating a new balance record in the db for a user :
- If he makes a deposit (it's a rule because it's triggered after ubercart checkout and was the only way I found)
- If another user transfer him money through a transfer (direct) or an escrow payment (indirect)
After that the user shouldn't be able to make any transaction (so nothing written in the db) and should be ditched out on the form validation step. So in a way it's good that the balance record is key dependent, no ?
In the case you shown it's for an escrow payment (but could happen also for a transfer). When the time comes to write in the db, the issuer (so the user who wants to transfer money) must have an account with money on it and must actually have enough money to cover it.
Comment #21
avpadernoThank you for the explanation.
I didn't see any security issue. I will approve the application later today.
Comment #22
aporieHey,
Thanks ! It's kind of exiting for me. Everything is new.
Comment #23
avpadernoThank you for your contribution!
I am going to update your account so you can opt into security advisory coverage now.
These are some recommended readings to help with excellent maintainership:
You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, 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.
I thank all the dedicated reviewers as well.
Comment #24
avpadernoI apologize for the delay. I planned to approve this application yesterday, but I didn't have time.
Comment #25
aporieHey,
No problem. Thanks you for the links to the documentation. Think it will answer a lot of my questions :)
Yeah if I have time I could give a hand on reviewing other modules, but for now I need to update myself on D8. That's also the point of this module, I'll port it on D8.
Thanks again.