Commit 4389f09e authored by Douwe Maan's avatar Douwe Maan Committed by Robert Speicher

Merge branch 'fix/export-att-inclusion' into 'master'

Fix attribute inclusion import/export config ignored in some cases

In the `import_export.yml` file we define the inclusion of some of the attributes. For some reason, this isn't working in certain cases - very unfortunate this includes `user`. This has been introduced in 8.10.3.

Related https://gitlab.com/gitlab-org/gitlab-ce/issues/20802

See merge request !1982
parent 1f6136b7
...@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.10.6 v 8.10.6
- Upgrade Rails to 4.2.7.1 for security fixes. !5781 - Upgrade Rails to 4.2.7.1 for security fixes. !5781
- Fix privilege escalation via project export.
v 8.10.5 v 8.10.5
- Add a data migration to fix some missing timestamps in the members table. !5670 - Add a data migration to fix some missing timestamps in the members table. !5670
......
...@@ -57,19 +57,16 @@ module Gitlab ...@@ -57,19 +57,16 @@ module Gitlab
# +value+ existing model to be included in the hash # +value+ existing model to be included in the hash
# +json_config_hash+ the original hash containing the root model # +json_config_hash+ the original hash containing the root model
def create_model_value(current_key, value, json_config_hash) def create_model_value(current_key, value, json_config_hash)
parsed_hash = { include: value } json_config_hash[current_key] = parse_hash(value) || { include: value }
parse_hash(value, parsed_hash)
json_config_hash[current_key] = parsed_hash
end end
# Calls attributes finder to parse the hash and add any attributes to it # Calls attributes finder to parse the hash and add any attributes to it
# #
# +value+ existing model to be included in the hash # +value+ existing model to be included in the hash
# +parsed_hash+ the original hash # +parsed_hash+ the original hash
def parse_hash(value, parsed_hash) def parse_hash(value)
@attributes_finder.parse(value) do |hash| @attributes_finder.parse(value) do |hash|
parsed_hash = { include: hash_or_merge(value, hash) } { include: hash_or_merge(value, hash) }
end end
end end
......
...@@ -12,7 +12,8 @@ describe Gitlab::ImportExport::Reader, lib: true do ...@@ -12,7 +12,8 @@ describe Gitlab::ImportExport::Reader, lib: true do
except: [:iid], except: [:iid],
include: [:merge_request_diff, :merge_request_test] include: [:merge_request_diff, :merge_request_test]
} }, } },
{ commit_statuses: { include: :commit } }] { commit_statuses: { include: :commit } },
{ project_members: { include: { user: { only: [:email] } } } }]
} }
end end
......
...@@ -7,6 +7,8 @@ project_tree: ...@@ -7,6 +7,8 @@ project_tree:
- :merge_request_test - :merge_request_test
- commit_statuses: - commit_statuses:
- :commit - :commit
- project_members:
- :user
included_attributes: included_attributes:
project: project:
...@@ -14,6 +16,8 @@ included_attributes: ...@@ -14,6 +16,8 @@ included_attributes:
- :path - :path
merge_requests: merge_requests:
- :id - :id
user:
- :email
excluded_attributes: excluded_attributes:
merge_requests: merge_requests:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment