Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

EZP-29539: Deleting object will remove all subtree items even when user does not have permission to delete them #2536

Merged
merged 3 commits into from
Feb 27, 2019

Conversation

pawbuj
Copy link
Contributor

@pawbuj pawbuj commented Feb 1, 2019

Question Answer
JIRA issue EZP-29539
Bug/Improvement yes
New feature no
Target version 7.2
BC breaks no
Tests pass yes
Doc needed no

Checking permission to remove content for all elements in the subtree.

TODO:

  • Implement feature / fix a bug.
  • Implement tests.
  • Fix new code according to Coding Standards ($ composer fix-cs).
  • Ask for Code Review.

$this->settings = $settings + array(
//'defaultSetting' => array(),
);
$this->settings = $settings + array(//'defaultSetting' => array(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->settings = $settings + array(//'defaultSetting' => array(),
$this->settings = $settings;

eZ/Publish/Core/Repository/TrashService.php Show resolved Hide resolved
@@ -294,7 +301,8 @@ public function findTrashItems(Query $query)

foreach ($query->sortClauses as $sortClause) {
if (!$sortClause instanceof SortClause) {
throw new InvalidArgumentValue('query->sortClauses', 'only instances of SortClause class are allowed');
throw new InvalidArgumentValue('query->sortClauses',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, fix CS

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, such changes shouldn't be in PR until they are necessary to fix a bug 😉


$contentRemoveCriterion = $this->permissionCriterionResolver->getPermissionsCriterion('content', 'remove');

if ($contentRemoveCriterion === false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe

Suggested change
if ($contentRemoveCriterion === false) {
if (is_bool($contentRemoveCriterion)) {
return $contentRemoveCriterion;
}

?

Copy link
Member

@adamwojs adamwojs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit/integration tests are missing also CI failure is related.

@@ -63,15 +69,16 @@ public function __construct(
RepositoryInterface $repository,
Handler $handler,
Helper\NameSchemaService $nameSchemaService,
array $settings = array()
array $settings = array(),
PermissionCriterionResolver $permissionCriterionResolver
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no BC promise for constructors so please move $permissionCriterionResolver before $settings

@@ -12,6 +12,8 @@
use eZ\Publish\API\Repository\Repository as RepositoryInterface;
use eZ\Publish\API\Repository\Values\Content\Content;
use eZ\Publish\API\Repository\Exceptions\UnauthorizedException as APIUnauthorizedException;
use eZ\Publish\Core\REST\Client\Values\Content\ContentInfo;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use eZ\Publish\Core\REST\Client\Values\Content\ContentInfo;

return false;
}

$contentRemoveCriterion = $this->permissionCriterionResolver->getPermissionsCriterion('content', 'remove');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any scenario that this can return true?

Copy link
Contributor Author

@pawbuj pawbuj Feb 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to docs, yes

/**
* Get criteria representation for a permission.
*
* Will return a criteria if current user has limited access to the given module/function,
* however if user has either full or no access then boolean is returned.
*
* @param string $module
* @param string $function
*
* @return bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
*/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And that was my point ;)

@pawbuj pawbuj force-pushed the EZP-29539 branch 3 times, most recently from d17ca05 to eee0379 Compare February 6, 2019 07:38
Copy link
Contributor

@andrerom andrerom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, but as this is bug it might be something that should be backported further back?

@@ -23,6 +24,10 @@
use eZ\Publish\API\Repository\Values\Content\Trash\SearchResult;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
use eZ\Publish\API\Repository\Values\Content\Query\SortClause;
use eZ\Publish\API\Repository\PermissionCriterionResolver;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\LogicalAnd as CriterionLogicalAnd;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\LogicalAnd as CriterionLogicalAnd;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;

in many places in the kernel it is used like this

@ViniTou ViniTou changed the title EZP-29539: Deleting object will remove all subtree items even when us… EZP-29539: Deleting object will remove all subtree items even when user does not have permission to delete them Feb 6, 2019
@lserwatka
Copy link
Member

@barbaragr @pawbuj what is the status here?

@barbaragr
Copy link

@lserwatka as Andre said: it might be something that should be backported further back, so I'm waiting for possibility to test on v 1.7. @pawbuj promised to let me know when it will be ready.

@lserwatka
Copy link
Member

lserwatka commented Feb 19, 2019

@andrerom but does it really make sense to back-port it to 1.7? 1.x is in SPA architecture, with zero permissions check, this might require work on frontend side to handle those exceptions properly. I don't see any benefit here especially that report was related to 2.x only.

@andrerom
Copy link
Contributor

andrerom commented Feb 19, 2019

@lserwatka The way I read this it's a kernel bug affecting all use of the application, api's and UI, it can also be argued to be security issue. Did QA uncover any major 1.x UI issues happening with this? I would assume that is more in regards to how we handle this in REST API which is maybe anyway a todo here on this PR(?)

@lserwatka
Copy link
Member

@andrerom we managed to reproduce it in 1.x too, unfortunately. @pawbuj could you change target branch to 6.7?

@pawbuj pawbuj changed the base branch from 7.2 to 6.7 February 20, 2019 21:00
@ezrobot

This comment has been minimized.

@pawbuj pawbuj force-pushed the EZP-29539 branch 2 times, most recently from f3f2a69 to 63f3721 Compare February 25, 2019 13:57
@micszo micszo self-assigned this Feb 27, 2019
Copy link
Member

@micszo micszo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retest OK on eZ Platform EE v1.7.8.
On v1.13.4 retesting before merge is blocked by http-cache dependencies.
Adding v2 test status in second PR.

@lserwatka lserwatka merged commit f2a100d into 6.7 Feb 27, 2019
@lserwatka lserwatka deleted the EZP-29539 branch February 27, 2019 14:06
@lserwatka
Copy link
Member

Could you merge it up?

@micszo micszo removed their assignment Feb 27, 2019
@micszo
Copy link
Member

micszo commented Feb 27, 2019

Retest OK on eZ Platform EE v1.13.4.

@pawbuj
Copy link
Contributor Author

pawbuj commented Feb 27, 2019

merged

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Development

Successfully merging this pull request may close these issues.

10 participants