Skip to content
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 get reviewers' bug #32415

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

lunny
Copy link
Member

@lunny lunny commented Nov 4, 2024

This PR rewrites GetReviewer function and move it to service layer.

Reviewers should not be watchers, so that this PR removed all watchers from reviewers. When the repository is under an organization, the pull request unit read permission will be checked to resolve the bug of #32394

Fix #32394

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Nov 4, 2024
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 4, 2024
@lunny lunny added type/bug backport/v1.22 This PR should be backported to Gitea 1.22 and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 4, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Nov 4, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Nov 5, 2024
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 5, 2024
@github-actions github-actions bot added the modifies/api This PR adds API routes or modifies them label Nov 5, 2024
@lunny lunny marked this pull request as ready for review November 6, 2024 06:27
Comment on lines 57 to 59
if repo.Owner.Visibility.IsLimited() && doerID == 0 {
return nil, fmt.Errorf("permission denied")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

permission check in services? not in router?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, why not. Because we need to load something and then check.

Copy link
Contributor

@yp05327 yp05327 Nov 7, 2024

Choose a reason for hiding this comment

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

First of all, the permission check I said above is the permission of access, not the permission of edit/update/create
For the access permission, if I understand correctly, the access control is in router or the handler, not in service.
The correct logic should be something like this I think:
router -> handler -x> services -> ...
↑ or ↑
access check

Copy link
Contributor

@yp05327 yp05327 Nov 7, 2024

Choose a reason for hiding this comment

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

And the permission check can be in another way, instead of finding all possible users and then check whether doer is in the results or not, just check whether user has the permission to access the repo(and PR?) directly.

Copy link
Member Author

Choose a reason for hiding this comment

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

services/pull/reviewer.go Outdated Show resolved Hide resolved
Copy link
Contributor

@jackHay22 jackHay22 left a comment

Choose a reason for hiding this comment

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

👍

@wxiaoguang wxiaoguang removed the backport/v1.22 This PR should be backported to Gitea 1.22 label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PR reviewers list contains invalid options
5 participants