gitlab-org--gitlab-foss/app/controllers/import/base_controller.rb
James Lopez 68e31c098e Merge branch 'fix/gh-namespace-issue' into 'security-10-4'
[10.4] Fix GH namespace security issue
2018-02-09 12:16:28 -06:00

17 lines
443 B
Ruby

class Import::BaseController < ApplicationController
private
def find_or_create_namespace(names, owner)
names = params[:target_namespace].presence || names
return current_user.namespace if names == owner
group = Groups::NestedCreateService.new(current_user, group_path: names).execute
group.errors.any? ? current_user.namespace : group
rescue => e
Gitlab::AppLogger.error(e)
current_user.namespace
end
end