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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
4c7665f2
Commit
4c7665f2
authored
Nov 28, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pad encryption keys with UTF-8 0 instead of \0 char
parent
b7f35e89
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
8 deletions
+8
-8
lib/gitlab/utils.rb
lib/gitlab/utils.rb
+1
-1
spec/config/settings_spec.rb
spec/config/settings_spec.rb
+4
-4
spec/lib/gitlab/utils_spec.rb
spec/lib/gitlab/utils_spec.rb
+3
-3
No files found.
lib/gitlab/utils.rb
View file @
4c7665f2
...
...
@@ -28,7 +28,7 @@ module Gitlab
end
end
truncated
+
(
"
\0
"
*
(
bytes
-
truncated
.
bytesize
))
truncated
+
(
'0'
*
(
bytes
-
truncated
.
bytesize
))
end
# Append path to host, making sure there's one single / in between
...
...
spec/config/settings_spec.rb
View file @
4c7665f2
...
...
@@ -24,7 +24,7 @@ describe Settings do
it
'expands db key base secret to 12 bytes'
do
expect
(
described_class
.
attr_encrypted_db_key_base_12
)
.
to
eq
((
'a'
*
10
)
+
(
"
\0
"
*
2
))
.
to
eq
((
'a'
*
10
)
+
(
'0'
*
2
))
end
end
...
...
@@ -53,7 +53,7 @@ describe Settings do
end
it
'expands db key base secret to 32 bytes'
do
expanded_key_base
=
(
'a'
*
10
)
+
(
"
\0
"
*
22
)
expanded_key_base
=
(
'a'
*
10
)
+
(
'0'
*
22
)
expect
(
expanded_key_base
.
bytesize
).
to
eq
32
expect
(
described_class
.
attr_encrypted_db_key_base_32
)
...
...
@@ -84,7 +84,7 @@ describe Settings do
it
'does not use more than 32 bytes'
do
db_key_base
=
described_class
.
attr_encrypted_db_key_base_32
expect
(
db_key_base
).
to
eq
'❤❤❤❤❤❤'
+
(
"
\0
"
*
14
)
expect
(
db_key_base
).
to
eq
'❤❤❤❤❤❤'
+
(
'0'
*
14
)
expect
(
db_key_base
.
bytesize
).
to
eq
32
end
end
...
...
@@ -99,7 +99,7 @@ describe Settings do
it
'does not use more than 32 bytes'
do
db_key_base
=
described_class
.
attr_encrypted_db_key_base_32
expect
(
db_key_base
).
to
eq
((
'❤'
*
10
)
+
(
"
\0
"
*
2
))
expect
(
db_key_base
).
to
eq
((
'❤'
*
10
)
+
(
'0'
*
2
))
expect
(
db_key_base
.
bytesize
).
to
eq
32
end
end
...
...
spec/lib/gitlab/utils_spec.rb
View file @
4c7665f2
...
...
@@ -134,7 +134,7 @@ describe Gitlab::Utils do
transformed
=
described_class
.
ensure_utf8_size
(
'a'
*
10
,
bytes:
32
)
expect
(
transformed
.
bytesize
).
to
eq
32
expect
(
transformed
).
to
eq
((
'a'
*
10
)
+
(
"
\0
"
*
22
))
expect
(
transformed
).
to
eq
((
'a'
*
10
)
+
(
'0'
*
22
))
end
end
...
...
@@ -151,7 +151,7 @@ describe Gitlab::Utils do
it
'backfills string with null characters'
do
transformed
=
described_class
.
ensure_utf8_size
(
'❤'
*
6
,
bytes:
32
)
expect
(
transformed
).
to
eq
'❤❤❤❤❤❤'
+
(
"
\0
"
*
14
)
expect
(
transformed
).
to
eq
'❤❤❤❤❤❤'
+
(
'0'
*
14
)
expect
(
transformed
.
bytesize
).
to
eq
32
end
end
...
...
@@ -160,7 +160,7 @@ describe Gitlab::Utils do
it
'truncates string to 32 characters and backfills it if needed'
do
transformed
=
described_class
.
ensure_utf8_size
(
'❤'
*
18
,
bytes:
32
)
expect
(
transformed
).
to
eq
((
'❤'
*
10
)
+
(
"
\0
"
*
2
))
expect
(
transformed
).
to
eq
((
'❤'
*
10
)
+
(
'0'
*
2
))
expect
(
transformed
.
bytesize
).
to
eq
32
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