Description

This module allows user-defined user-agents to bypass Drupal Core's page cache. Additionally, when the page cache is bypassed, the existing page cache entry for the page is updated with the latest rendering. See the project page for some sample use-cases.

Project Page

http://drupal.org/sandbox/iamEAP/1418344

Repository

git clone --branch 6.x-1.x http://git.drupal.org/sandbox/iamEAP/1418344.git
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/iamEAP/1418344.git

Versions

Drupal 6.x, 7.x

Background

I've been working with Drupal in site building, theming, and development contexts for nearly three years and have been using PHP and MySQL for work and play back five years prior. I hold bachelor's degrees in Computer Science and Digital Media studies from the University of Denver. I currently work fulltime as a developer on a Drupal website for a software company in Seattle.

I've previously submitted a module to this application queue, but the process took so long that someone else implemented another version of the same thing. I'm an active co-maintainer of the new one now, but hopefully this application goes by faster.

Comments

eugene.ilyin’s picture

Status: Needs review » Needs work

Hello. I spent a Review of your module.
variable_get('ua_cache_bypass_crawler_names'... this is user provided text, I think you need to sanitize it to avoid XSS attacks.

switch ($path) {
case 'admin/help#ua_cache_bypass':
return filter_filter('process', 1, NULL, file_get_contents(dirname(__FILE__) . "/README.txt"));
}

I think IF operator is better for this.

iamEAP’s picture

ua_cache_bypass_crawler_names is never displayed anywhere, so there's no need to filter it for XSS vulnerabilities. It's only used within hook_boot() to test against the user agent string.

eugene.ilyin’s picture

Status: Needs work » Needs review

Okay.
Sorry I missed string

I think IF operator is better for this.

in my previous comment.

iamEAP’s picture

Thanks for the clarification.

In this case, that may be true, given that I'm unlikely to implement other help pages, but this is how core handles help pages and how I've seen it in all of the code examples, so I decided to go with what's standard. See: http://api.drupal.org/api/drupal/developer%21hooks%21core.php/function/h...

Thanks for the reviews.

Robertas’s picture

Status: Needs review » Needs work

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. Get a review bonus and we will come back to your application sooner.

</code></p><code>

FILE: ...w/sites/all/modules/pareview_temp/test_candidate/ua_cache_bypass.module<br>
--------------------------------------------------------------------------------<br>
FOUND 2 ERROR(S) AND 5 WARNING(S) AFFECTING 7 LINE(S)<br>
--------------------------------------------------------------------------------<br>
  9 | WARNING | Format should be "* Implements hook_foo()." or "Implements<br>
    |         | hook_foo_BAR_ID_bar() for xyz_bar()."<br>
 12 | WARNING | Line exceeds 80 characters; contains 87 characters<br>
 19 | ERROR   | Comments may not appear after statements.<br>
 53 | WARNING | Format should be "* Implements hook_foo()." or "Implements<br>
    |         | hook_foo_BAR_ID_bar() for xyz_bar()."<br>
 64 | WARNING | Format should be "* Implements hook_foo()." or "Implements<br>
    |         | hook_foo_BAR_ID_bar() for xyz_bar()."<br>
 72 | WARNING | Format should be "* Implements hook_foo()." or "Implements<br>
    |         | hook_foo_BAR_ID_bar() for xyz_bar()."<br>
 93 | ERROR   | Inline comments must end in  full-stops, exclamation marks, or<br>
    |         | question marks<br>
--------------------------------------------------------------------------------<br>



Source: http://ventral.org/pareview - PAReview.sh online service

klausi’s picture

Status: Needs work » Needs review

No manual review given, and the minor coding style issues do not justify the "needs work" status.

The response time for a review is now approaching 4 weeks. Get a review bonus and we will come back to your application sooner.

iamEAP’s picture

Took care of those style issues because I might as well.

For whomever reviews this next, I was informed by another module developer that the "Implements hook_foo()." style is a Drupal 7 specific style and that the Drupal 6 standard is "Implementation of hook_foo()."

klausi’s picture

As your module represents new code it should go with the most recent version of coding standards where possible. From http://drupal.org/coding-standards :

Drupal coding standards are version-independent and "always-current". All new code should follow the current standards, regardless of (core) version.

Robertas’s picture

Status: Needs review » Needs work

In ua_cache_bypass.module:102
your code:watchdog('cache bypass', 'Page cache was bypassed via user-agent string: !ua', array('!ua' => $_SERVER['HTTP_USER_AGENT']), WATCHDOG_NOTICE);

Superglobal variables, like $_SERVER['HTTP_USER_AGENT'] can be spoofed and used for XSS attack. It needs to be filtered before being inserted into log by watchdog(). Therefore you should use %ua rather than !ua.

iamEAP’s picture

Status: Needs work » Needs review

Great catch, Robertas. Change made. Thanks for the review!

jrockowitz’s picture

In hook_menu() you can remove the ua_cache_bypass_config_page() menu callback and use drupal_get_form().

Instead of

/**
 * Implements hook_menu().
 */
function ua_cache_bypass_menu() {
  $items = array();
  $items['admin/settings/ua_cache_bypass'] = array(
    'title' => 'User-Agent Cache Bypass',
    'description' => 'Configuration for Tableau Crawl Bypass.',
    'access callback' => 'user_access',
    'access arguments' => array('administer ua cache bypass'),
    'page callback' => 'ua_cache_bypass_config_page',
    'file' => 'ua_cache_bypass.admin.inc',
  );
  return $items;
}

You can just use 'drupal_get_form' as the 'page callback' and array('ua_cache_bypass_settings') as the 'page arguments'.

/**
 * Implements hook_menu().
 */
function ua_cache_bypass_menu() {
  $items = array();
  $items['admin/settings/ua_cache_bypass'] = array(
    ...
    'page callback' => 'drupal_get_form',
    'page arguments' => array('ua_cache_bypass_settings'),
    ...
  );
  return $items;
}

BTW, this is a very minor tweak. I have also tested that the code is working as expected using Firefox's User Agent Switcher.

iamEAP’s picture

May as well scrub that extra function call out. Change committed; thanks, Jake.

iamEAP’s picture

Priority: Normal » Critical

Over a month at needs review; marking critical as per workflow rules.

klausi’s picture

Assigned: Unassigned » tim.plunkett
Priority: Critical » Normal
Status: Needs review » Reviewed & tested by the community

Sorry for the delay, but you have not listed any reviews of other project applications in your issue summary as strongly recommended in the application documentation.

manual review:

  1. ua_cache_bypass_install(): no need to set variables here as you can use default values in variable_get() anyway.
  2. ua_cache_bypass_boot(): Are you sure that you need to call "exit" directly and cannot use drupal_exit()?
  3. ua_cache_bypass_log_bypass(): the return statement at the end is not needed, remove it.
  4. ua_cache_bypass_perm(): hook_perm() does not exist in drupal 7 (not a security issues, it just means that no one but user 1 can access the admin page right now).

But that are just minor issues, otherwise this looks RTBC to me. Assigning to tim.plunkett as he might have time to finally approve this.

michelle’s picture

Assigned: tim.plunkett » Unassigned
Status: Reviewed & tested by the community » Fixed

I granted access based on klausi's RTBC. I think that's all that needs to be done? If not, let me know.

klausi’s picture

Thanks for your contribution, iamEAP! Welcome to the community of project contributors on drupal.org.

Michelle has 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.

iamEAP’s picture

Awesome! Thanks for the reviews and advice, everyone.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Adding support for Drupal 7.x.