Skip to content

Conversation

Rom1-B
Copy link
Contributor

@Rom1-B Rom1-B commented Oct 1, 2025

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

  • It fixes !39340

It checks that the recipient user has the necessary permissions to view the documents in private follow-ups before attaching them to the notification.

NB: rework of #17544

Screenshots (if appropriate):

@Rom1-B Rom1-B changed the base branch from 11.0/bugfixes to 10.0/bugfixes October 1, 2025 12:15
@cedric-anne cedric-anne added this to the 10.0.21 milestone Oct 1, 2025
@Rom1-B Rom1-B marked this pull request as ready for review October 3, 2025 09:47
@cconard96
Copy link
Contributor

Seems to replace #17544

$user_id = ($user->getFromDBbyEmail($current->fields['recipient']))
? $user->getID()
: null;
$doc_crit = $item->getAssociatedDocumentsCriteria(true, $user_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you could use the User object here instead of sending the id?
This would avoid loading the same user twice in a row.

src/User.php Outdated
Comment on lines 7032 to 7049
$iterator = $DB->request([
'SELECT' => 'rights',
'FROM' => 'glpi_profilerights',
'JOIN' => [
'glpi_profiles_users' => [
'ON' => [
'glpi_profilerights' => 'profiles_id',
'glpi_profiles_users' => 'profiles_id',
],
],
],
'WHERE' => [
'glpi_profilerights.name' => $module,
'glpi_profilerights.rights' => ['&', $right],
'glpi_profiles_users.users_id' => $this->getID(),
],
]);

Copy link
Contributor

Choose a reason for hiding this comment

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

One last security concern: when the rights for an user are loaded, we do an additional operation by calling cleanProfile():

Image

Wouldn't something like that be needed here too, to make sure we don't load rights that are out of scope for the profile interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just an SQL SELECT, no profile is loaded, so I don't think it's necessary to reload the profile. Or am I misunderstanding your comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking about the logic from cleanProfile, not reloadCurrentProfile itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants