security: fixed issues with exposing repository names using global PR redirection link

logic.

- Since redirect was created to repository which linked to the PR, users who
didn't have permissions to those repos could still see the name in the url generated.
This commit is contained in:
Marcin Kuzminski 2019-11-07 13:21:42 +01:00
parent de0032cf5d
commit 1addb7b6e2

View file

@ -25,7 +25,7 @@ from pyramid.view import view_config
from rhodecode.apps._base import BaseAppView
from rhodecode.lib import helpers as h
from rhodecode.lib.auth import (LoginRequired, NotAnonymous)
from rhodecode.lib.auth import (LoginRequired, NotAnonymous, HasRepoPermissionAny)
from rhodecode.model.db import PullRequest
@ -66,6 +66,13 @@ class AdminMainView(BaseAppView):
pull_request_id = pull_request.pull_request_id
repo_name = pull_request.target_repo.repo_name
# NOTE(marcink):
# check permissions so we don't redirect to repo that we don't have access to
# exposing it's name
target_repo_perm = HasRepoPermissionAny(
'repository.read', 'repository.write', 'repository.admin')(repo_name)
if not target_repo_perm:
raise HTTPNotFound()
raise HTTPFound(
h.route_path('pullrequest_show', repo_name=repo_name,