Hi when I setting protection to user alfa, he has protection from deletion. It is working fine when I try delete this user over his account, this prevent deletion. BUT when I try delete this user over VBO he is delete!

Comments

megachriz’s picture

Title: VBO do not respect UserProtect settings » Protection doesn't work with Views Bulk Operations
Version: 6.x-1.5 » 7.x-1.x-dev
Issue summary: View changes
Related issues: +#2172017: Bulk operations does not respect entity access

Marked #2277347: Protection doesn't work with Views Bulk Operations as a duplicate.

I can confirm that this bug is in the 7.x-1.x version also.

megachriz’s picture

StatusFileSize
new4.35 KB

The attached patch applies user protection when executing the following Views Bulk Operation actions from within a view:

  • Cancel user account
  • Modify user roles

I tried to also apply protection for the action "Modify entity values", but for some reason that doesn't work yet.

Technical: even if I supply a validation handler for the vbo action form for "Modify entity values", the validation function doesn't get called. This is not the case for the other two actions.

megachriz’s picture

Status: Active » Needs review
megachriz’s picture

Priority: Major » Critical
StatusFileSize
new5.57 KB
new2.52 KB

I figured out how to protect the "Change value" action too now. The validation handler needed to move to the submit button. I also completed the checks for the "Change value" action: first a check against all edits is done, then a check for each property is done (theme, language and fields are ignored).

This is actually a pretty critical issue, so bumping to critical.

megachriz’s picture

I've tested with VBO further and wrote some automated tests for this issue. So I found out that the previous patch didn't fix the whole problem. In some cases users could still be blocked or canceled with VBO.

Here are two new patches: one with tests only (to be sure they fail without the fix) and one with the test + the fix. Phew, took me a while to get everything right.

The last submitted patch, 5: userprotect-vbo-support-1635520-5-tests-only.patch, failed testing.

megachriz’s picture

Some minor changes. I think this is ready.

  • MegaChriz committed fb5344f on 7.x-1.x
    Issue #1635520 by MegaChriz: fixed protection does not work with Views...
megachriz’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Needs review » Patch (to be ported)

Committed #7.

Someone wants to create a patch for the 6.x-1.x version?

Stevel’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Priority: Critical » Normal
Status: Patch (to be ported) » Needs review
StatusFileSize
new429 bytes

Although there are tests for VBO now, they are not run because VBO is missing from the test environment. Adding test_dependencies[] in the info file.

Stevel’s picture

StatusFileSize
new429 bytes

Re-uploading patch, because it seems testbot didn't take the file.

Stevel’s picture

Note that this patch returns green, but that doesn't mean that the VBO tests work (in fact, they don't. I get 9 fails, 1 exception), because the "test_dependencies" are resolved before the patch is applied. But by committing this, at least the fails can show up for the testbot.

  • MegaChriz committed 894e2f9 on 7.x-1.x authored by Stevel
    Issue #1635520 by Stevel: Tests for VBO protection are not executed by...
megachriz’s picture

Great catch, Stevel. Yes, I noticed too that tests are failing on VBO.

Previously, the tests did work, because test dependencies are declared on userprotect_test.info. Later the testbot was changed to only look at the 'main' module for test dependencies and ignore submodules.

Committed #11, with a small difference. Dependencies should be declared in the form {project}:{module} as noted on https://www.drupal.org/docs/7/creating-custom-modules/writing-module-inf....

Do you want to take care of the test failures?

Stevel’s picture

StatusFileSize
new489 bytes

This patch seems to solve the issues.

Stevel’s picture

@MegaChriz: did you bypass the "waiting for branch? I could not find an option to do that. I posted about that on #2866130: "Waiting for branch to pass" can't be circumvented anymore. Could you wait committing this until @drumm or someone from the infrastructure team could take a look at that?

megachriz’s picture

@Stevel: yes, I forced the test to not wait for branch tests to pass.

Strange that VBO calls the table 'views_entity_user'. Is this always the case on a VBO enabled user view or can the table have other names as well?

megachriz’s picture

@Stevel
I'll wait with committing the patch.

Stevel’s picture

I'm finding some "'views_entity_' . $type" constructs in both entity and views, so it might be a more general approach taken there. Also, the tests work also by leaving out the test for == 'users', but I let that in just to be sure (perhaps older versions of VBO / Views / entity). Out for today, feel free to commit :)

megachriz’s picture

The 'view_entity_' . $entity_type thing was added in #1334374: Re-use generic entity views table and is present since the 7.x-3.4 release of VBO. So that means we should keep the case for 'users' if we want to keep compatibility with VBO 7.x-3.3.

Stevel’s picture

StatusFileSize
new694 bytes

I updated the patch with a comment explaining why the two tables names are checked. As the issue with the 'bypass' is solved, no need to wait any longer.

  • MegaChriz committed 3397561 on 7.x-1.x authored by Stevel
    Issue #1635520 by Stevel: Fixed protection for Views Bulk Operation...
megachriz’s picture

Status: Needs review » Fixed

Fantastic! Committed #21.

I wonder though if we should judge this change as a security issue?

Status: Fixed » Closed (fixed)

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