Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
be35c93a
Commit
be35c93a
authored
Mar 22, 2022
by
John Mason
Committed by
Heinrich Lee Yu
Mar 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add BlocksUnsafeSerialization to Namespace
Changelog: changed
parent
3480111a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
2 deletions
+29
-2
app/models/namespace.rb
app/models/namespace.rb
+5
-0
config/feature_flags/development/block_namespace_serialization.yml
...ature_flags/development/block_namespace_serialization.yml
+8
-0
lib/gitlab/import_export/fast_hash_serializer.rb
lib/gitlab/import_export/fast_hash_serializer.rb
+1
-1
lib/gitlab/import_export/json/streaming_serializer.rb
lib/gitlab/import_export/json/streaming_serializer.rb
+1
-1
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+14
-0
No files found.
app/models/namespace.rb
View file @
be35c93a
...
...
@@ -15,6 +15,7 @@ class Namespace < ApplicationRecord
include
Namespaces
::
Traversal
::
Recursive
include
Namespaces
::
Traversal
::
Linear
include
EachBatch
include
BlocksUnsafeSerialization
# Temporary column used for back-filling project namespaces.
# Remove it once the back-filling of all project namespaces is done.
...
...
@@ -660,6 +661,10 @@ class Namespace < ApplicationRecord
# Use SHA2 of `traversal_ids` to account for moving a namespace within the same root ancestor hierarchy.
"namespaces:{
#{
traversal_ids
.
first
}
}:first_auto_devops_config:
#{
group_id
}
:
#{
Digest
::
SHA2
.
hexdigest
(
traversal_ids
.
join
(
' '
))
}
"
end
def
allow_serialization?
(
options
=
nil
)
Feature
.
disabled?
(
:block_namespace_serialization
,
self
,
default_enabled: :yaml
)
||
super
end
end
Namespace
.
prepend_mod_with
(
'Namespace'
)
config/feature_flags/development/block_namespace_serialization.yml
0 → 100644
View file @
be35c93a
---
name
:
block_namespace_serialization
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/82661
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/355553
milestone
:
'
14.9'
type
:
development
group
:
group::global search
default_enabled
:
false
lib/gitlab/import_export/fast_hash_serializer.rb
View file @
be35c93a
...
...
@@ -92,7 +92,7 @@ module Gitlab
def
simple_serialize
subject
.
as_json
(
tree
.
merge
(
include:
nil
,
preloads:
nil
))
tree
.
merge
(
include:
nil
,
preloads:
nil
,
unsafe:
true
))
end
def
serialize_includes
...
...
lib/gitlab/import_export/json/streaming_serializer.rb
View file @
be35c93a
...
...
@@ -37,7 +37,7 @@ module Gitlab
def
serialize_root
(
exportable_path
=
@exportable_path
)
attributes
=
exportable
.
as_json
(
relations_schema
.
merge
(
include:
nil
,
preloads:
nil
))
relations_schema
.
merge
(
include:
nil
,
preloads:
nil
,
unsafe:
true
))
json_writer
.
write_attributes
(
exportable_path
,
attributes
)
end
...
...
spec/models/namespace_spec.rb
View file @
be35c93a
...
...
@@ -2230,4 +2230,18 @@ RSpec.describe Namespace do
expect
(
namespace
.
storage_enforcement_date
).
to
be
(
nil
)
end
end
describe
'serialization'
do
let
(
:object
)
{
build
(
:namespace
)
}
it_behaves_like
'blocks unsafe serialization'
context
'when feature flag block_namespace_serialization is disabled'
do
before
do
stub_feature_flags
(
block_namespace_serialization:
false
)
end
it_behaves_like
'allows unsafe serialization'
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment