Synopsis
This is a Drupal Commerce module and implements the Products, Feeds and Reports APIs from Amazon MWS:
- Amazon Marketplace Web Service
- Amazon Marketplace Web Service (Amazon MWS) Developer Guide
- Selling on Amazon Guide to XML
The module sandbox can be found here as of current: https://www.drupal.org/sandbox/splendidles/2629252 with the following page with instruction on how to clone the module: https://www.drupal.org/project/2629252/git-instructions
This module currently supports Feeds, Reports and Products, with the ability to sync local quantities to and from Amazon, upload/delete products and relationships, view simple reports and stock adjustments. All feeds are configured with a JSON config file (All products are synchronized by SKU so SKUs must be unique). The README file can be viewed via Drupals Help system, which uses the parsedown library to make it nicer to view. This module has so far:
- Feeds, Reports, Products feed integration, more APIs could be added but weren't deemed necessary, as each API from Amazon needs modification to work properly. They have been included in the libraries directory of the module.
- Simple Reporting, which cross references local products with remote products.
- Sample Feed Generator, to turn the JSON feed definitions into XML for debugging and visual clarification.
Requirements
- Elysia Cron
- Drupal Commerce
Known Problems
- When renaming SKUs locally, delist them first, or make the changes on Amazon to make sure items stay in sync.
- When uploading to Amazon, Amazon tends to make assumptions on what the product you're uploading is if it detects a similar product or a pre-listed product. For the vast majority of instances, this is down to a duplicate UPC code, either the code is a duplicate of one of your own or another sellers, so for instance an item that is a Yoyo might get mixed up with a Toaster on upload because the UPC code you're using matches another sellers. The only way to correct this is to delist and fix locally before relisting, or to contact Amazon and submit a request to update the items info if you're certain Amazon has made a mistake. To make this easy to see which items have the wrong description, use the reporting portion of this module and run an Active Listing Report. This will show you any reports that have a differing description, a lot of the time these are correct with slight adjustments to the title as the product already exists, sometimes they are completely different.
- All items are matched by SKU when syncing. If you already have items on Amazon, those SKUs will need to match locally to sync. Check the modules reports system and run one of the reports to see which SKUs you have on Amazon that don't match locally.
- At the moment only one display type per product type is configured to work, this hasn't been tested with multiple product type and display type, so if your product and display setup is super complicated, you can expect a large JSON file and possibly issues. This is because logic at the moment is taking the first display type listed per product. Hopefully this can change in future.
- Alternate SKUs, when using a different SKU from the main SKU, haven't fully been tested and aren't being used in production for the original project this module was intended for. They do work when viewing the Sample Feed Generator, but haven't been used live.
Installing
The following must be cloned into the modules libraries directory in a subdirectory called "nonapod". So "libraries/nonapod". If you are using Composer however, you can simply do a composer install to install Array2XML and the AmazonMWS libraries. You will need to still manually install parsedown however. Both of the following need to be installed to work properly.
- Modified Amazon MWS APIs: Reports, Feeds, Products - to make everything work. This is required.
- Array2XML: This is a very lightly modified version of the library created by Lalit Patel at http://www.lalit.org/lab/convert-php-array-to-xml-with-attributes
Clone the following into the sites/all/libraries directory:
- parsedown - to prettify the README.txt file in Drupal's Help module, if this isn't installed, the README.txt won't display when viewing the help page.
Clone the following into the sites/all/libraries directory:
Restrictions
- This module syncs products by SKU, SKUs must match or else they won't sync.
- Only one product display node type per product type for now.
Similar Projects
- Commerce Amazon Fulfillment "This project adds Amazon Fulfillment shipping capability to Drupal commerce"
- Amazon Store"This is an implementation of the Amazon Product Advertising API (formerly Amazon Associates Web Service, or AAWS) for Drupal"
Manual reviews of other projects
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | coder-results.txt | 179.61 KB | klausi |
Comments
Comment #2
splendidles commentedComment #3
PA robot commentedGit clone command for the sandbox is missing in the issue summary, please add it.
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 #4
Helgi Andri Jónsson commentedHi splendidles,
I just reviewed your module.
Individual user account
You appear to follow the Individual user accounts guidelines.
Duplication
Your module seams unique.
Master Branch
Your sandbox has a master branch
Licensing
The Amazon MWS MarketplaceWebService libraries are licensed with Apache License 2.0. I am not sure it is possible to license those under GPL version 2.0 as specified on http://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses:
Apache License, Version 2.0 (#apache2)
This is a free software license, compatible with version 3 of the GNU GPL.
Please note that this license is not compatible with GPL version 2, because it has some requirements that are not in that GPL version. These include certain patent termination and indemnification provisions. The patent termination provision is a good thing, which is why we recommend the Apache 2.0 license for substantial programs over other lax permissive licenses.
Readme.txt
I think your Readme file needs a seperate Requirements and Installation section.
Security Code
Your module appears to use db_select, etc safely.
Coding Style
I noticed that your lines become long in most files. Please consider breaking them accross a few lines to make them more readable.
Best Regards,
Helgi.
Comment #5
PA robot commentedClosing 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.
Comment #6
kschisler commentedThis is a huge module. Reviewed as much as I could though. Very nice job!!! Moving to RTBC.
Automated Review
[Best practice issues identified by pareview.sh http://pareview.sh/pareview/httpgitdrupalorgsandboxsplendidles2629252git big list here. Should probably be addressed.
Note that perfect adherence to Drupal Coding Standard is NOT a reason to block an application, except for total disregard of them. However, modules should follow them as closely as possible.
Manual Review
Could use a few more of the required headers of the README template... README.txt is very detailed though. This doesn't seem like a huge issue.
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.
This review uses the Project Application Review Template.
Comment #7
kschisler commentedComment #8
grinder3011 commentedHi splendidles,
You seem to be missing some basics on this project application page which is a link to the sandbox of your project and a git clone command for reviewers who would want to download and test your project. Changing this to Needs work.
Comment #9
grinder3011 commentedComment #10
PA robot commentedClosing 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.
Comment #11
splendidles commentedComment #12
splendidles commentedComment #13
splendidles commentedComment #14
splendidles commentedCleaned up and addressed the feedback provided. Readme changed, libraries removed and require cloning into libraries except for Array2XML.inc etc
Comment #15
splendidles commentedComment #16
splendidles commentedArray2XML is now no longer bundled and must be cloned into the modules libraries directory from https://github.com/nonapod/Array2XML/ this has been added to the description above and the README.txt file.
Comment #17
splendidles commentedComment #18
PA robot commentedProject 1: https://www.drupal.org/node/2792673
Project 2: https://www.drupal.org/node/2642870
As successful completion of the project application process results in the applicant being granted the 'Create Full Projects' permission, there is no need to take multiple applications through the process. Once the first application has been successfully approved, then the applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue. With this in mind, your secondary applications have been marked as 'closed(duplicate)', with only one application left open (chosen at random).
If you prefer that we proceed through this review process with a different application than the one which was left open, then feel free to close the 'open' application as a duplicate, and re-open one of the project applications which had been closed.
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #19
splendidles commentedComment #20
smccabe commentedClosed other duplicate and re-opening this one as it is nearly done and the other one is brand new.
Comment #21
fbailey commentedEvan already addressed this, but the getFieldValue function in commerce_amazon_mws.Mapping.php still has that foreach loop that doesn't do anything.
The only other big thing I noticed is in commerce_amazon_mws.reports.inc and commerce_amazon_mws.tasks.inc you make a lot of use of a "magic" number. Specifically in:
Other than that the code looks good to me.
Comment #22
splendidles commentedThanks Francis, I've removed the empty foreach loop from the Mapping class and removed the magic number instances.
Comment #23
splendidles commentedComment #24
klausiGit errors:
Review of the 7.x-1.x-dev branch (commit a6667b2):
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:
There is a security vulnerability in this module and as part of our Git admin training I'm assigning this to visabhishek so that he can take a look. If he does not find anything in one week I'm going to post vulnerability details.
Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #25
visabhishek commented@klausi : Thanks for this assignment
I have manually reviewed the code, found the below issues.
Form elements - #value of #type markup and item need to be safe.
Some examples are :
Table $rows values requires sanitization :
Ex: function commerce_amazon_mws_reports_display_report
$row['item-name'] should be passed through filter_xss() or filter_xss_admin() function to sanitize the values.
$row['request_id'] should be passed through filter_xss() or filter_xss_admin() function to sanitize the values.
Comment #26
klausi@visabhishek: thanks for taking a look.
Form elements: you are only suggesting to wrap user facing things in t(), which is good advice to keep things translatable, but is not a security risk. Only static strings controlled by the module author are used in your example, so there is no XSS threat? Or did I miss something?
commerce_amazon_mws_reports_display_report(): yes, it looks like row['item-name'] is user provided text which needs to run through check_plain() for sanitization. Same for $product->title which is printed unsanitized to table markup here, so that is also an XSS vulnerability. @splendidles make sure to read https://www.drupal.org/node/28984 again. Note that I think check_plain() is more appropriate here because we don't want any HTML tags rendered in request IDs or item IDs or product titles.
Then there is also a CSRF vulnerability. admin/reports/commerce_amazon_mws/delete does not confirm user intent, see http://epiqo.com/en/all-your-pants-are-danger-csrf-explained and https://docs.acquia.com/articles/protecting-your-drupal-module-against-c...
Comment #27
klausiThen there are also lots of untranslated strings in the module like 'The report with id: ' . $report_id . ' does not exist'. Make sure that all user facing text runs through t() for translation.
Comment #28
cornifex commented@visabhishek
@klausi
Hey guys, thanks for the thorough review.
I've made some commits over the last week or so and I think I've resolved all the issues that have been brought up since splendidles last commit.
Here's a general overview of what was done:
7.x-1.x.t()where needed.check_plain()orfilter_xss()as recommended.admin/reports/commerce_amazon_mws/deleteto avoid CSRF. If the token doesn't exist, access is denied.Comment #29
visabhishek commentedHi cornifex,
You covered most of the things. Some quick reviews points which are still pending :
1:Please delete all variable on hook_uninstall()
EX:
2: Please wrap user facing things in t(), i can see unwrapped text on so many places
EX : function commerce_amazon_mws_admin_form()
3: All JavaScript code MUST be declared inside a closure wrapping the whole file and this closure MUST be in strict mode.
https://www.drupal.org/docs/develop/standards/javascript/javascript-codi...
Comment #30
cornifex commentedThanks, visabhishek!
Newest changes:
t().'use strict';inside closure.Comment #31
joshmillerAutomated Review
There's a lot of issues found ... lots of comment formatting and nit picks. #2831865: Change formatting to adhere to Drupal Standards
Note that perfect adherence to Drupal Coding Standard is NOT a reason to block an application, except for total disregard of them. However, modules should follow them as closely as possible.
Manual Review
This review uses the Project Application Review Template.
Comment #32
joshmillerAfter I posted this comment, cornifex invited me to look a little deeper into the two major issues I located in my last review:
1. GPL issue with included 3rd party libraries.
Turns out, these have been removed for awhile. The issue hasn't been updated, but they have been gone for months
2. t() missing on strings
Turns out, all t()'s that I thought were missing were in database schema instances and hook_menu()s ... both are exempt from those requirements.
That leaves the code formatting issues, which are all admittedly nitpicky and minor requirements around documenting parameters and functions. And, as the review template suggests, this is not enough to remove the need for the project from a full project.
Therefore, I deem this project RTBC'ed.
Comment #33
klausimanual review:
Comment #34
PA robot commentedClosing 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.