This Drupal 7 module allows the site administrator to create permissions that do absolutely nothing by default. They are useful for views permission-based access control, among other things. Unlike Custom Permissions, this module does not include page access control.

sandbox
git clone --recursive --branch 7.x-1.x http://git.drupal.org/sandbox/Gaelan/1798428.git dummy_permission
Ventral.org PAreview
Simplytest.me

Review Bonus

Comments

j4’s picture

Hi,

As per the ventral review, the readme.txt is missing. read this link to see how to add one: http://drupal.org/node/447604

Found 2 errors:

FILE: ...sites/all/modules/pareview_temp/test_candidate/dummy_permissions.module
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
149 | ERROR | Files must end in a single new line character

Line 138: The $message argument to drupal_set_message() should be enclosed within t() so that it is translatable.

drupal_set_message("Saved");

All the best with your project!
Jaya

j4’s picture

Hi again,

I also tested the project on a drupal 7 test environment and found that I am unable to add users to the "trusted users". How do we add that?

Thanks
jaya

rob holmes’s picture

Status: Needs review » Needs work

Hi there,

Just a couple of things.

Lines 107,116,122,126 Should have the title wrapped in a t() function.

Line 117, the description should use the t() function.

Missing return type from docblocks in dummy_permissions_list_form, dummy_permissions_add_form

Add a link to the permissions list form from the modules .info file
e.g. configure = admin/people/permissions/dummy_permissions

You should be able to remove the variable 'dummy_permissions' during a hook_uninstall.

Gaelan’s picture

@j4 Can you explain what you mean by "trusted users?"

Gaelan’s picture

Added (Markdown!) README.txt.

j4’s picture

Hi Gaelan,

Whn we try to add a new dummy permission, there is a checkbox for trusted users only. I assume by that you mean authenticated users. I am wondering whether that functionality can be changed to selection of some users only...so that I can have my view visible not to all users of a particular role but only to some particular users. Makes sense?

Thanks!
Jaya

Gaelan’s picture

Trusted users only = restrict access.

j4’s picture

Sorry if i am seeming dumb! :) When we say restrict access, how do i restrict it to say user 3 alone? Suppose I create 2 views, one for user 3 and one for user 4. And i want to show view 3 only to user 3 and view 4 only to user 4. If i could select which trusted users I have in mind in the "add new dummy permission" it would be a very useful functionality. In fact for sites with hundreds of users of different roles, it would even be nice if we could have a role filtering first and then the user filtering.

I am just testing this out for review purposes and dont actually have a need for this module currently, but do see great potential, hence my comments. Please do let me know if you had some other reason for the conception of the module.

Thanks

Gaelan’s picture

Status: Needs work » Needs review

@Rob Holmes:
I fixed most of the problems you mentioned. Although I didn't add the return value to the Doxygen for the form handlers, I updated the Doxygen to follow Drupal's Doxygen Standards.

Gaelan’s picture

@j4:

All this module does is adds permissions to the "Permissions" page. You do access control there.

j4’s picture

Hi,

I created a new dummy permission. I was able to use it in the views permissions and configure it in the permissions section of the site also. But was wondering if adding an extra field in the configurations section of which users this permission is applicable to, may make this module really very powerful.

Thank you
Jaya

klausi’s picture

Status: Needs review » Postponed (maintainer needs more info)

This sounds like a feature that should live in the existing config_perms module. Module duplication and fragmentation is a huge problem on drupal.org and we prefer collaboration over competition. Please open an issue in the config_perm issue queue to discuss what you need. You should also get in contact with the maintainer(s) to determine what is needed that this works for you.

If that fails for whatever reason please get back to us and set this back to "needs review".

Robin Millette’s picture

klausi is referring to Custom Permissions, which was originally called Site Configuration Permissions, hence the module file and function names (conf_perms).

#1664386: Pathless custom permissions. seems to disagree.
In fact, it seems like Custom Permissions can do everything Dummy Permission can do, no?

We should have cought this earlier.

Gaelan’s picture

Status: Postponed (maintainer needs more info) » Needs review

In my summary, I wrote:

Unlike Custom Permissions, this module does not include page access control.

Crantok did beat me to a sandbox module that did this. Here are some differences:

  • I have a README.
  • Crantok stores permissions in Just-In-Time Variables; I just use core variables
  • It seems crantok has a better admin screen than me.
koppie’s picture

Status: Needs review » Needs work

I found a few issues:

  1. There's still a master branch in git. You have to delete it; see http://drupal.org/node/1659588
  2. The text in your readme file needs to wrap at 80 characters.
  3. Your readme and module files need to end with a blank line

For more information: http://ventral.org/pareview/httpgitdrupalorgsandboxgaelan1798428git . I recommend you run your code through PAReview before you request another review.

This is a really handy looking module and I think you're pretty close to getting it approved.

klausi’s picture

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

Closing due to lack of activity. Feel free to reopen if you are still working on this application.

If you reopen this please keep in mind that we are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll 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" (found some problems with the project) or "reviewed & tested by the community" (found no major flaws).

Gaelan’s picture

Status: Closed (won't fix) » Active

Ventral review doesn't report any errors anymore.

Gaelan’s picture

Status: Active » Needs review

Whoops.

delta’s picture

Status: Needs review » Needs work

Hi,

Manual review:
1) You should delete the variables dummy_permissions at the uninstall of the module. http://api.drupal.org/api/drupal/modules!system!system.api.php/function/...

That's all, this modules works great, thanks.

Gaelan’s picture

Status: Needs work » Needs review

@delta Done.

Gaelan’s picture

Just made PAReview happy again.

delta’s picture

Manual review:
1) in your add dummy permissions form, you need to add a validate on the field machine name.
2) in drupal core you have a functionnality: when a new drupal permission is created by a module, these permissions is assigned to the user_admin_role, that can be set via the variable :
variable_set('user_admin_role', $admin_role->rid);
i think you need to emulate this functionnality, when a new permission is created via your user interface. For the moment that doesn't works. (only for your module permission 'Administer Dummy Permissions', because the permission is added to the admin_role on the module installation).

That's all

Gaelan’s picture

Done.

Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 1.03 KiB, done.
Total 9 (delta 6), reused 0 (delta 0)
To git@git.drupal.org:sandbox/Gaelan/1798428.git
   0a26c87..a02a6ce  7.x-1.x -> 7.x-1.x
Gaelan’s picture

Fixed coding standards & made the validation actually work.

delta’s picture

Status: Needs review » Needs work

l.176 .module

$admin_role = variable_get("user_admin_role");
user_role_grant_permissions($admin_role, array($machine_name));

You need to add a default value to the variable_get(),
and test this value before calling user_role_grant_permissions().
Some drupal installations may not have an user_admin_role in that case your call to user_role_grant_permission will failed.

Otherwise that's looks ok.

kscheirer’s picture

Status: Needs work » Reviewed & tested by the community

You should remove the .gitignore file from the repo.

Gaelan’s picture

Done.
EDIT: Yes, this means that both #28 and #29 are done.

delta’s picture

l.176 .module
your test is wrong $admin_role is always set.

  $admin_role = variable_get("user_admin_role");
  // here admin_role == null or a role id
delta’s picture

double post

Gaelan’s picture

@delta isset returns false for NULL.

Gaelan’s picture

Fixed ventral review (again).

Gaelan’s picture

Issue summary: View changes

made sandbox real link. put clone in code tag.

Gaelan’s picture

Issue summary: View changes

Add 1/3 of a review bonus.

Gaelan’s picture

Issue summary: View changes

Updated issue summary.

Gaelan’s picture

Issue tags: +PAreview: review bonus

Just got a review bonus! See summary. Also added simplytest.me/ventral.org links to summary.

Gaelan’s picture

Just got a review bonus! See summary. Also added simplytest.me/ventral.org links to summary.

klausi’s picture

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

manual review:

  1. no edit form for existing dummy permissions?
  2. dummy_permissions_list_form(): this is vulnerable to XSS exploits if I enter a permission description like <script>alert('XSS');</script>. You need to sanitize all user provided text before printing, or (as in this case) mark the permission that is able to inject malicious stuff as 'restrict access' => TRUE. I guess Drupal does not expect to have malicious stuff in permission descriptions, so I think the only proper way to solve this is to restrict this permission. This is a security blocker.

Poor Gaelan, you were so close! As soon as the security issue is fixed I promise to approve you.

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

klausi’s picture

Issue tags: +PAreview: security

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

Gaelan’s picture

Fixed security issue.

~/D/dummy_permissions 7.x-1.x → git push
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 347 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To git@git.drupal.org:sandbox/Gaelan/1798428.git
   ffc6814..7d27e6e  7.x-1.x -> 7.x-1.x
Gaelan’s picture

Status: Needs work » Needs review

I'm not sure how I implement a table of actions (edit/delete), but if I knew how, I would be happy to add an edit feature.

klausi’s picture

Status: Needs review » Needs work

That fix now protects your own page from exposing an XSS risk, but as I said: the permission description is also displayed on admin/people/permissions for example and it is not filtered there. So we still have an XSS threat here as Drupal does not expect user provided stuff in permissions and their descriptions. The only sane way out here is to mark 'administer dummy permissions' as 'restrict access' => TRUE. Defining new permission is a pretty heavy admin task anyway (like administering Views for example), so that should not be of any harm?

As I can still exploit the security issue this has to go back to needs work.

Gaelan’s picture

Is there a reason why I can't use check_plain in hook_permission?

klausi’s picture

Yes: "When handling data, the golden rule is to store exactly what the user typed. When a user edits a post they created earlier, the form should contain the same things as it did when they first submitted it. This means that conversions are performed when content is output, not when saved to the database." from https://drupal.org/node/28984

What's the problem with 'administer dummy permissions' as 'restrict access' => TRUE?

Gaelan’s picture

Status: Needs work » Needs review

Pushed restrict access. Should I still check_plain in hook_permission?

klausi’s picture

Status: Needs review » Fixed

check_plain() in hook_permission() is bad, since nothing is printed there to the user. And the escaped text would be saved to the database which violates the golden rule of handling data.

So 'restrict access' on its own is enough.

Thanks for your contribution, Gaelan!

I 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.

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.

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

Anonymous’s picture

Issue summary: View changes

Complete review bonus and link to Simplytest.me and Ventral.org.