Please find details of a simple module that uses NZ Post's Ratefinder API to provide shipping quotes (extends Ubercart's uc_quote)

Project page
https://drupal.org/sandbox/southweb/2224413

Git
http://drupalcode.org/sandbox/southweb/2224413.git

CommentFileSizeAuthor
#7 paraview.png89.94 KBsouthweb
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

southweb’s picture

Issue summary: View changes
PA robot’s picture

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.

TR’s picture

Status: Needs review » Postponed

There is no code in the git repository for your project. Please add your code to the repository and then set the issue status back to "Needs review".

southweb’s picture

Ok thanks

southweb’s picture

Status: Postponed » Needs review

I have added files to the GIT sandbox.

Note to self- use ssh with GIT URLs and set origin master on first PUSH.

PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxsouthweb2224413git

I'm a robot and this is an automated message from Project Applications Scraper.

southweb’s picture

FileSize
89.94 KB

Not quite sure how I can view these errors. The link sent me to a form to test the code, but then asked for a URL.

Neither

http://drupalcode.org/sandbox/southweb/2224413.git

or

ssh://drupalcode.org/sandbox/southweb/2224413.git

Were considered a valid repository host.

Great concept though. Have uploaded attached error screen.

TR’s picture

The URL seems to be working now - I was able to click the link in #6 and see the errors. BTW the correct form of the URL is http://git.drupal.org/sandbox/southweb/2224413.git - the examples for the input textfield in your image show this form.

One thing that pareview didn't point out was that you put all your files into a uc_ratefinder subdirectory - you don't need to / shouldn't do that. Put everything at the top level of the repository.

southweb’s picture

I have created and started using the 7.x-1.x branch but seem unable to delete the master (see errors below)

Also paraview now spits out over a hundred or so pedantic formatting errors. Is there a tool to tidy up some php code in order to meet its formatting requirements?

Thanks

remote: error: By default, deleting the current branch is denied, because the next
remote: error: 'git clone' won't result in any file checked out, causing confusion.
remote: error:
remote: error: You can set 'receive.denyDeleteCurrent' configuration variable to
remote: error: 'warn' or 'ignore' in the remote repository to allow deleting the
remote: error: current branch, with or without a warning message.
remote: error:
remote: error: To squelch this message, you can set it to 'refuse'.
remote: error: refusing to delete the current branch: refs/heads/master
To ssh://southweb@drupalcode.org/sandbox/southweb/2224413.git
! [remote rejected] master (deletion of the current branch prohibited)
error: failed to push some refs to 'ssh://southweb@drupalcode.org/sandbox/southweb/2224413.git'

southweb’s picture

Status: Needs work » Needs review
TR’s picture

Status: Needs review » Needs work

The error messages don't mean much without knowing what commands you used to try to remove the branch. The parreview page gives you a link to the procedure to remove the master branch - if you follow those instructions it should work just fine. If it doesn't, then the instructions need to be fixed.

Drupal, like any other organization, has its own coding standards. Many of these are the result of long experience on how to avoid well-known coding problems, many are so that the module works with our automated tools (like the documentation generator), but some are just so that we share a common language and can use, maintain, and contribute to the code developed by others in this large community. Part of the instructions for apply for git permissions on drupal.org tell you how to check your code against the Drupal coding standards, and ask you to ensure your code complies before you submit your application. Once you have fixed your coding standards it will be a lot easier for the volunteer reviewers to examine your code and approve your application.

While there are a bunch of PHP beautifiers available online, I don't know of any specifically designed for Drupal code. In my opinion, because your module is small it would be quick and easy to make these changes by hand. In doing so you would learn what needs to be done, which will greatly benefit you when writing other modules or contributing to Drupal.

You still need to move the code out of the subdirectory. Take a look at some other project repositories if you're unsure what iyours should look like.

southweb’s picture

Status: Needs work » Needs review

pareview errors address. Note: a nice module called coder gets you about 75% of the way there.

files moved to parent

branch changed - see details below:

mac02:git andrew$ git push origin 7.x-1.x
southweb@drupalcode.org's password:
Total 0 (delta 0), reused 0 (delta 0)
To ssh://southweb@drupalcode.org/sandbox/southweb/2224413.git
* [new branch] 7.x-1.x -> 7.x-1.x

inders’s picture

Status: Needs review » Needs work

something reported by coder module about security:

uc_ratefinder.module

severity: criticalreview: security_dsmLine 157: Potential problem: drupal_set_message() only accepts filtered text, be sure to use check_plain(), filter_xss() or similar to ensure your $variable is fully sanitized. (Drupal Docs) [security_dsm]
    drupal_set_message($result, 'warning', FALSE);
southweb’s picture

Status: Needs work » Needs review

Added check_plain

santiwww’s picture

Status: Needs review » Needs work

There's a master branch configured as default and also a 7.x-1.x branch.
The 7.x.-1.x should be set as default and the master branch should be deleted.
Follow these steps to do it properly: https://drupal.org/node/1127732
Variable names in .install file are incorrect, causing some of them still remains after uninstalling module.

southweb’s picture

Status: Needs work » Needs review

Have updated the .install file to delete the correct variable names. Well spotted

Hopefully I have done the correct steps with regard Git. I'm an SVN user from way back to am still struggling a little here.

See session below.

mac02-3:git andrew$ git commit uc_ratefinder.install 
[7.x-1.x eac20cc] Change name of variables to delete
 1 file changed, 4 insertions(+), 4 deletions(-)
mac02-3:git andrew$ git status
On branch 7.x-1.x
Your branch and 'origin/master' have diverged,
and have 1 and 2 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

nothing to commit, working directory clean
mac02-3:git andrew$ git pull
southweb@drupalcode.org's password: 
Merge made by the 'recursive' strategy.
 uc_ratefinder.info   | 1 +
 uc_ratefinder.module | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
mac02-3:git andrew$ git status
On branch 7.x-1.x
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)

nothing to commit, working directory clean
mac02-3:git andrew$ git checkout 7.x-1.x
Already on '7.x-1.x'
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)
mac02-3:git andrew$ git branch -D master
Deleted branch master (was adae862).
mac02-3:git andrew$ git push origin :master
southweb@drupalcode.org's password: 
remote: error: By default, deleting the current branch is denied, because the next
remote: error: 'git clone' won't result in any file checked out, causing confusion.
remote: error: 
remote: error: You can set 'receive.denyDeleteCurrent' configuration variable to
remote: error: 'warn' or 'ignore' in the remote repository to allow deleting the
remote: error: current branch, with or without a warning message.
remote: error: 
remote: error: To squelch this message, you can set it to 'refuse'.
remote: error: refusing to delete the current branch: refs/heads/master
To ssh://southweb@drupalcode.org/sandbox/southweb/2224413.git
 ! [remote rejected] master (deletion of the current branch prohibited)
error: failed to push some refs to 'ssh://southweb@drupalcode.org/sandbox/southweb/2224413.git'
southweb’s picture

Ping

gisle’s picture

Since this is a sandbox project, it can safely be deleted. I think the simplest way to sort out the mess is to do the following:

  1. Delete your sandbox. (Press the Edit tab, and then the Delete button at the bottom of the screen.)
  2. Set up a shiny, new sandbox. However, do not follow the instructions under "Version control" for setting up this repository for the first time. Instead:
  3. Make a note of the number identifying your sandbox. In this example, I'll use 1234567.
  4. In your local repo, give the following commands (remember to replace the number identifying your sandbox with the actual number):
git checkout 7.x-1.x
git remote rm origin
git remote add origin southweb@git.drupal.org:sandbox/southweb/1234567.git
git push origin 7.x-1.x

(The last two commands are the same as the last two commands in the instructions under "Version control" for setting up this repository for the first time.)

You should now have a sandbox that is correctly set up, with all your commits inside it.

Finally, update your issue summary so that the link to the sandbox and the git clone command refers to this new sandbox.

(Being a SVN veteran myself before moving to git, I know how you feel. But git grows on you!)

gwprod’s picture

You can't delete the master branch, because it's set as default in your project. Go into Version Control, change to 7.x-1.x, and save. Then try deleting master.

southweb’s picture

Thanks for the instructions gisle! I will try this if gwprod's solution doesn't work.

gwprod, when you say "go into Version Control" what do you mean? I am using command line Git. What would be the commands to use?

cheers

gwprod’s picture

@southweb

on your sandbox project page, go to the Version Control tab, and set your Default Branch to 7.x-1.x

southweb’s picture

Thanks for above advice. Have changed default branch to 7.x-1.x and committed the change to fix the variable names again (#15)

Hopefully this time.

gwprod’s picture

You're still supposed to delete the Master branch.

southweb’s picture

Master removed!

For anyone following this who is new/struggling with GIT I downloaded a wonderful tool (SourceTree) that enabled me to view then delete remote branches.

southweb’s picture

Ping

southweb’s picture

ping

southweb’s picture

ping

southweb’s picture

ping

southweb’s picture

ping

er.pushpinderrana’s picture

Status: Needs review » Needs work
Issue tags: +PAreview: security

@southweb, thankyou for your contribution.

Automated Review

Best practice issues identified by pareview.sh / drupalcs / coder. Yes, http://pareview.sh/pareview/httpgitdrupalorgsandboxsouthweb2224413git reported few minor issues.

FILE: /var/www/drupal-7-pareview/pareview_temp/uc_ratefinder.module
--------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------
5 | ERROR | [ ] Doc comment short description must end with a full stop
122 | ERROR | [x] Whitespace found at end of line
179 | ERROR | [ ] Type hint "array" missing for $products
179 | ERROR | [ ] Type hint "array" missing for $details
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Not Sure: Does not cause module duplication and fragmentation. As I am unable to test functionality of this module so can't say whether any similar module already exist or not. As I googled not found any similar one.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements
3rd party code
Yes: Follows the guidelines for 3rd party code.
README.txt/README.md
(+) No: Follows the guidelines for in-project documentation and the README Template. Similarly project page (https://www.drupal.org/sandbox/southweb/2224413) also contains very few information that need to be extended. Also where this menu path defined in your module admin/store/settings/quotes (enable quote method here)
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
NoYes. If "no", list security issues identified.
  1. (*) uc_ratefinder_ratefinder: this is vulnerable to XSS. uc_ratefinder_api_key variable value coming form user provided input and this is passing directly to curl request, you need to sanitize it before passing further, make sure to read https://www.drupal.org/node/28984 again. As per klausi comment in #31, making correction.
  2. (+) uc_ratefinder_menu: "'access arguments' => array('configure quotes')," that permission is not defined by your module in hook_permission()? Also the permission name does not really fit? As per klausi comment in #31, correcting this and moving to below list because still unable to find defined permissions in your module.

Thanks Klausi for correcting me.

Coding style & Drupal API usage
  1. (*) Unable to enable this module, Is this module dependencies are correct?
    No release history was found for the requested project (uc_quote).     [warning]
    
    No release history was found for the requested project (uc_order).     [warning]
    
    Module uc_ratefinder cannot be enabled because it depends on the         [error]
    
    following modules which could not be found: uc_quote,uc_order
  2. hook_help() is missing in your module.
  3. (+) uc_ratefinder_admin_method_edit_form: what is the use of $mid = 0 param here. Also doc missing of this function. Why are you writing separate submit function as you are saving form values through varibale_set() that can be easily achieved through system_settings_form(). Also what is the use of if (preg_match('/^ratefinder_.*/', $key)) {?
  4. uc_ratefinder_ratefinder(): Instead of using json_decode(), should use drupal_json_decode().
  5. Add configure = admin/store/settings/quotes/methods/ratefinder in your .info file to make it directly accessible from module page.
  6. Also it would be good to keep your uc_ratefinder_admin_method_edit_form() in separate admin.inc file.
  7. In uc_ratefinder_ratefinder() function you are using PHP cURL to send http get request, I would recommend you to use drupal_http_request() to hit the external URL.
  8. What is the need of using @ in this code if (@$rates['status'] != 'success') {, add your comment on this.
  9. (+) uc_ratefinder_menu: "'access arguments' => array('configure quotes')," that permission is not defined by your module in hook_permission()? Also the permission name does not really fit?

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.

As I am not a git administrator, so I would recommend you, please help to review other project applications to get a review bonus. This will put you on the high priority list, then git administrators will take a look at your project right away :-)

Thanks Again!

klausi’s picture

Issue tags: -PAreview: security

Don't sanitize variables when you pass them to cURL. It will issue a HTTP request to some other site, but it will not print anything to HTML. Therefore sanitization would be wrong here.

Also the permission question is technically not a security issue. If people use permissions that are not defined then that is not a security issue because the system will just not grant access on permissions that don't exist (only user 1 will always pass user_access()).

So I'll remove the security tag for now since those 2 things are not vulnerabilities. Feel free to add it if you find other exploits.

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.