Module-Description
SWTOR - Star Wars The Old Republic - Server Status
swtor_server_status module
Category: "Games and Amusements"

The module provides a block displaying SWTOR (Star Wars The Old Republic) server status information.
These game server status informations are very popular and displayed on gamer-, guild-, clan-websites.
There are multiple options for selecting the game-server-locale/game-server-name, for displaying additionally guild link, render wrapper elements, setting the caching time etc.

Links
Project Page: http://drupal.org/sandbox/aw030/1913016
Git Repo: git clone --branch 7.x-1.x http://drupal.org/sandbox/aw030/1913016.git swtor_server_status

Drupal Version
Drupal 7

Notes
- Automated code review using http://ventral.org/pareview/ gives only a false positive, but there is NO /e flag used in regular expressions.
- I dont't know why there isnt' already a swtor server status module since the game release, please let me know if it's forbidden from drupal side, SWTOR recommend spreading the data to build up a big outer-game-community.
- The way getting the data is recommended, if - perhaps in future - a server status api is released i will immediately switch over.
- Please contact me or comment for feedback, help or info, you're very welcome!

Review Bonus
http://drupal.org/node/1881052#comment-7049764
http://drupal.org/node/1913236#comment-7049628
http://drupal.org/node/1912952#comment-7049888
http://drupal.org/node/1898112#comment-7073862
http://drupal.org/node/1917624#comment-7073720
http://drupal.org/node/1913236#comment-7073356
http://drupal.org/node/1908884#comment-7075774

CommentFileSizeAuthor
#6 xss-exploit-1914458-6.patch512 bytesklausi

Comments

rob.barnett’s picture

This looks fun. You should also run your code through the coder module. It found some nitpicking white space issues but also a possible security issue with your use of preg_match on line 57 in the .module

aw030’s picture

Ok, thx, i will try the Coder module this evening and fix the whitespace-issues.
=> The whitespace-issues thrown by the "Coder" module has been fixed.

The security issue warning is only thrown by the PAreview script on ventral.org,
but it seems to be an issue with these automated-review-scripts (CodeSniffer),
see: http://drupal.org/node/1847730.

False positive: The /e-flag is NOT used in this module here
(--->the review-script only don't recognize well the modifiers of the regular expression and gives a false positive)

sylus’s picture

I just did a quick review and it found a few more whitespace issues.

FILE: /mnt/www/html/pareviewsh/pareview_temp/swtor_server_status.module
--------------------------------------------------------------------------------
FOUND 4 ERROR(S) AFFECTING 4 LINE(S)
--------------------------------------------------------------------------------
  12 | ERROR | Whitespace found at end of line
  14 | ERROR | Whitespace found at end of line
  33 | ERROR | Whitespace found at end of line
 266 | ERROR | Whitespace found at end of line
--------------------------------------------------------------------------------

Otherwise I looked at the code and it is very succinct and solves the desired use case well.

My only question would be at:

http://drupalcode.org/sandbox/aw030/1913016.git/blob/refs/heads/7.x-1.x:...

 341       '' => t('English'),
 342       'de' => t('German'),
 343       'fr' => t('French')),

Are these the only languages provided by SWTOR?

aw030’s picture

Thx for your review, too.

The whitespaces are now fixed:
No errors in Coder module and only the false-positive at ventral.org,
see the latest version running through script here:
http://ventral.org/pareview/httpgitdrupalorgsandboxaw0301913016git

Languages: Yes, the only languages supported/provided for the status server
informations are these three languages (if you visit swtor.com, you
will see the option for this 3 languages at the top of the page).

aw030’s picture

Issue tags: +PAreview: review bonus

I forgot to set the review bonus tag...

klausi’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus +PAreview: security
StatusFileSize
new512 bytes

Thank you for your reviews. When finishing your review comment also set the issue status either to "needs work" (you found some problems with the project) or "reviewed & tested by the community" (you found no major flaws).

manual review:

  1. swtor_server_status.info: the commented out lines should be removed to avoid confusion?
  2. "file_get_contents($swtor_status));": many drupal environments have remote file inclusion disabled, so this will not work. Use drupal_http_request() instead.
  3. "'access arguments' => array('administer content'),": wrong permission? This has nothing to do with nodes, so it does not seem appropriate. Use "administer site configuration" or provide your own permission instead.
  4. "variable_get('swtor_server_status_guild_show', '0')": all variables defined by your module need to be removed in hook_uninstall().
  5. swtor_server_status_form(): use system_settings_form() here then you don't need swtor_server_status_form_submit().
  6. "@author aw030 mail@aw030.de": we don't use @author tags in Drupal, you can give credit in README.txt
  7. swtor_server_status_block_view(): this is vulnerable to XSS exploits. The third party retrieved data has to be treated as untrusted user provided input and has to be sanitized before printing. Please read http://drupal.org/node/28984 again. Attached is a patch that simulates an XSS attack by overriding the retrieved data with a malicious javascript snippet.

Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

aw030’s picture

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

Thx a lot for your very helpful review!
Ok in my future reviews i will manipulate the issue status,
i dont't knew that i am permitted to do this.

All issues mentioned above are fixed now

1. Cleaned up the .info file.
2. drupal_http_request() now in use.
3. Permissions set to "administer site configuration"
4. Added a _uninstall hook in new .install file
5. system_settings_form() now in use.
6. @author tags removed.
7. I agree to that, and as mentioned in the article http://drupal.org/node/28984,
I have used now check_plain() on every value.

After reviewing 3 other projects i will re-add the bonus tag,
and for now i will remove the "PAReview: security"-tag
(i hope this is correct, because the xss-issue is fixed...)

klausi’s picture

Issue tags: +PAreview: security

Please don't remove the security tag, we keep that for statistics and to show examples of security problems.

klausi’s picture

Issue summary: View changes

*for better understanding

aw030’s picture

Issue summary: View changes

Added 3 other reviews for review bonus

klausi’s picture

Assigned: Unassigned » dman
Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus

manual review:

  • swtor_server_status_getdata(): I think you should not do sanitization with cehck_plain() here but in swtor_server_status_block_view() where it is actually used for printing. It is best pratice to keep data unaltered internally and then sanitize it only when necessary on output.

But otherwise looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

Assigning to dman as he might have time to finally approve this.

dman’s picture

Installed OK.
User review:
I'd like to see the project detail (as shown on the modules admin page) use the full name instead of the acronym in the description, thought that's mainly because I found it hard to find and unfamiliar

SWTOR Server Status
SWTOR Server Status block module.

- didn't really take advantage of the description field to describe anything :-)

Installation instructions on the project page were good.

I expected the options for configuring the block would be at the block configuration screen ( admin/structure/block/manage/swtor_server_status/swtor_server_status/configure ) - I think that would be a tidier place for this if there is only to be one block. It's just one click away if using the inline edit tools that are on by default in D7.
However, really good and reasonably clear admin UI options (considering I don't know this system at all!)

Perhaps you could have the css display options ON by default in first install, and provide the option to disable or override them later, instead of vice versa.

Code review:

I'm puzzled that immediately after starting to use SimpleXMLElement to parse server responses, you then switch to use substr() to get data out of it, but I'll let that slide.

You *appear* to be using check_plain in most of the data fields I can see. So it's currently probably OK, but it's a vector to remain vigilant about.

Instead of iterating through all servers looking for their names each time

foreach ($swtor_server_status['data'] as $k => $item) {
      if ($server_name_compare == $item['name']) {

I would have just indexed the data array by the server name at the time. You have the label available when you are creating the array.

Good use of translation throughout.
I'd expect that the display (and the work you've done to toggle the wrapper elements etc) could easily be delegated to a theme.tpl instead of using the render array anf #type=html_tag so heavily, ...but it's fine as is.
eg

        $block['content']['swtor_guild_link'] = array(
          '#theme' => 'html_tag',
          '#tag' => 'a',
          '#attributes' => array(
            'class' => 'swtor-guild-link',
            'href' => variable_get('swtor_server_status_guild_link', '#'),
          ),
          '#value' => variable_get('swtor_server_status_guild', 'MyGuild'),
        );

... we usually just use l() for that :-)

I notice that the provided css ONLY gets included if the 'guild' option is added. That's a little unexpected. Is it by design?

OK. Code is fine. Behavior is fine,. the issues above (especially the XSS) have been addressed.
Looks good to go by me.

@aw030 , you should now have the ability to promote your sandbox to a full project.

To copy & paste Klausi's standard welcome message:
----------------------
Now that this experimental project has been promoted, you'll need to update the URL of your remote repository or reclone it.

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 get 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.
----------------------
Thanks Klausi too.
.dan.

klausi’s picture

Status: Reviewed & tested by the community » Fixed

dman updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.

aw030’s picture

Thanks a lot to all involved! I am very pleased about that!
I'll will fix the recommendations from comments #10 / #11 in the next steps, update the project page (description) and the documentation.

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

review-link added