-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix(LockedField): prevent purge of lockedField without authorization on the linked object entity #18353
base: 10.0/bugfixes
Are you sure you want to change the base?
Fix(LockedField): prevent purge of lockedField without authorization on the linked object entity #18353
Conversation
…on the linked object entity
Seems correct, could you add a test please? |
Co-authored-by: Cédric Anne <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are failing.
if ( | ||
$item->getFromDB($this->fields['items_id']) //not a global lock | ||
&& $item->isEntityAssign() | ||
&& !Session::haveAccessToEntity($item->getEntityID(), $item->isRecursive()) // no access to main item entity | ||
) { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a lack of checks for the purge right, I guess there is the same lack of checks for the creation and the update right. Could you fix that too ?
$item = new $lock->fields['itemtype'](); | ||
if ( | ||
$item->getFromDB($lock->fields['items_id']) //not a global lock | ||
&& $item->isEntityAssign() | ||
&& !Session::haveAccessToEntity($item->getEntityID(), $item->isRecursive()) // no access to main item entity | ||
) { | ||
return false; | ||
} | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks pretty similar to what is done in the canPurgeItem()
method. You should probably move it into a private function canAccessItemEntity(string $itemtype, int $items_id): bool
method.
Checklist before requesting a review
Please delete options that are not relevant.
Description
GLPI does not respect the current user's permissions when deleting (purging) a
LockedField
.This allows a
LockedField
linked to an object from another entity to be deleted.I am also questioning the handling of
global
LockedFields
.Currently, anyone with the
UPDATE
permission can delete a global lock (with or without thisPR
), regardless of the entity, as theLockedField
object does not include anentities_id
.Screenshots (if appropriate):