summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2019-01-25 16:44:05 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2019-01-25 16:44:05 +0000
commit40d9900404f9ff4a396dc263954b46387874ff15 (patch)
tree23fdc4d5b667be5d5ef448de29d7952e25b29dfa /lib
parent4d2a666c743d2ae2f068d1975dc9cf8f21b97c51 (diff)
parent19f9666abf847efd4a5cb50d38faee77f91ec233 (diff)
downloadgitlab-ce-40d9900404f9ff4a396dc263954b46387874ff15.tar.gz
Merge branch 'security-import-project-visibility' into 'master'
[master] Fix Imported Project Retains Prior Visibility Setting See merge request gitlab/gitlabhq!2734
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/import_export/project_tree_restorer.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/gitlab/import_export/project_tree_restorer.rb b/lib/gitlab/import_export/project_tree_restorer.rb
index a56ec65b9f1..51001750a6c 100644
--- a/lib/gitlab/import_export/project_tree_restorer.rb
+++ b/lib/gitlab/import_export/project_tree_restorer.rb
@@ -107,7 +107,7 @@ module Gitlab
def project_params
@project_params ||= begin
- attrs = json_params.merge(override_params)
+ attrs = json_params.merge(override_params).merge(visibility_level)
# Cleaning all imported and overridden params
Gitlab::ImportExport::AttributeCleaner.clean(relation_hash: attrs,
@@ -127,6 +127,13 @@ module Gitlab
end
end
+ def visibility_level
+ level = override_params['visibility_level'] || json_params['visibility_level'] || @project.visibility_level
+ level = @project.group.visibility_level if @project.group && level > @project.group.visibility_level
+
+ { 'visibility_level' => level }
+ end
+
# Given a relation hash containing one or more models and its relationships,
# loops through each model and each object from a model type and
# and assigns its correspondent attributes hash from +tree_hash+