diff options
author | Sean McGivern <sean@gitlab.com> | 2017-03-28 11:09:44 +0000 |
---|---|---|
committer | DJ Mountney <david@twkie.net> | 2017-03-29 19:18:38 -0700 |
commit | 91f43587a8c05a5c2955f0b5c464f03688552cb6 (patch) | |
tree | dba32618ae3452ae117df78184ad38d3b5ff26b1 /app | |
parent | 60c0c0f3d08aa2c2a5be68aa784a86304fdb9c99 (diff) | |
download | gitlab-ce-91f43587a8c05a5c2955f0b5c464f03688552cb6.tar.gz |
Merge branch 'jej-group-name-disclosure' into 'security'
Prevent private group disclosure via parent_id
See merge request !2077
Diffstat (limited to 'app')
-rw-r--r-- | app/finders/group_finder.rb | 17 | ||||
-rw-r--r-- | app/services/groups/update_service.rb | 8 | ||||
-rw-r--r-- | app/views/shared/_group_form.html.haml | 2 |
3 files changed, 26 insertions, 1 deletions
diff --git a/app/finders/group_finder.rb b/app/finders/group_finder.rb new file mode 100644 index 00000000000..24c84d2d1aa --- /dev/null +++ b/app/finders/group_finder.rb @@ -0,0 +1,17 @@ +class GroupFinder + include Gitlab::Allowable + + def initialize(current_user) + @current_user = current_user + end + + def execute(*params) + group = Group.find_by(*params) + + if can?(@current_user, :read_group, group) + group + else + nil + end + end +end diff --git a/app/services/groups/update_service.rb b/app/services/groups/update_service.rb index 4e878ec556a..1d65c76d282 100644 --- a/app/services/groups/update_service.rb +++ b/app/services/groups/update_service.rb @@ -1,6 +1,8 @@ module Groups class UpdateService < Groups::BaseService def execute + reject_parent_id! + # check that user is allowed to set specified visibility_level new_visibility = params[:visibility_level] if new_visibility && new_visibility.to_i != group.visibility_level @@ -22,5 +24,11 @@ module Groups false end end + + private + + def reject_parent_id! + params.except!(:parent_id) + end end end diff --git a/app/views/shared/_group_form.html.haml b/app/views/shared/_group_form.html.haml index 7974eb67f0f..8869d510aef 100644 --- a/app/views/shared/_group_form.html.haml +++ b/app/views/shared/_group_form.html.haml @@ -1,4 +1,4 @@ -- parent = Group.find_by(id: params[:parent_id] || @group.parent_id) +- parent = GroupFinder.new(current_user).execute(id: params[:parent_id] || @group.parent_id) - group_path = root_url - group_path << parent.full_path + '/' if parent - if @group.persisted? |