reconquest / atlassian-external-hooks

External Hooks plugin for Atlassian Bitbucket
https://external-hooks.reconquest.io
Other
44 stars 37 forks source link

ExternalPreReceiveHook.onReceive calls PermissionService.hasAnyUserPermission with global permissions #3

Closed mheemskerk closed 10 years ago

mheemskerk commented 10 years ago

https://github.com/ngsru/atlassian-external-hooks/blob/master/src/main/java/com/ngs/stash/externalhooks/hook/ExternalPreReceiveHook.java#L52

calls PermissionService.hasAnyUserPermission with SYSADMIN and ADMIN. The contract on hasAnyUserPermission only allows resource permissions to be queried (PROJECT* or REPO*). If you provide a global permission, an IllegalArgumentException is thrown.

The whole check can be collapsed into a single call permissions.hasRepositoryPermission(currentUser, repo, Permission.REPO_ADMIN) because PROJECT_ADMIN, ADMIN and SYSADMIN all imply REPO_ADMIN

seletskiy commented 10 years ago

Resolved in #4