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
d777dc3a
Commit
d777dc3a
authored
Feb 19, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-02-19
parents
e8a37e6a
586816ae
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
272 additions
and
46 deletions
+272
-46
app/models/key.rb
app/models/key.rb
+3
-4
app/services/issues/move_service.rb
app/services/issues/move_service.rb
+2
-1
changelogs/unreleased/40552-sanitize-extra-blank-spaces-used-when-uploading-a-ssh-key.yml
...tize-extra-blank-spaces-used-when-uploading-a-ssh-key.yml
+5
-0
changelogs/unreleased/41949-move.yml
changelogs/unreleased/41949-move.yml
+5
-0
changelogs/unreleased/sh-fix-geo-error-500-gpg-commit.yml
changelogs/unreleased/sh-fix-geo-error-500-gpg-commit.yml
+5
-0
lib/gitlab/gpg/commit.rb
lib/gitlab/gpg/commit.rb
+3
-1
lib/gitlab/ssh_public_key.rb
lib/gitlab/ssh_public_key.rb
+22
-6
spec/factories/keys.rb
spec/factories/keys.rb
+93
-23
spec/lib/gitlab/gpg/commit_spec.rb
spec/lib/gitlab/gpg/commit_spec.rb
+25
-1
spec/lib/gitlab/ssh_public_key_spec.rb
spec/lib/gitlab/ssh_public_key_spec.rb
+58
-3
spec/models/key_spec.rb
spec/models/key_spec.rb
+29
-7
spec/services/issues/move_service_spec.rb
spec/services/issues/move_service_spec.rb
+22
-0
No files found.
app/models/key.rb
View file @
d777dc3a
...
...
@@ -36,9 +36,8 @@ class Key < ActiveRecord::Base
after_destroy
:refresh_user_cache
def
key
=
(
value
)
value
&
.
delete!
(
"
\n\r
"
)
value
.
strip!
unless
value
.
blank?
write_attribute
(
:key
,
value
)
write_attribute
(
:key
,
value
.
present?
?
Gitlab
::
SSHPublicKey
.
sanitize
(
value
)
:
nil
)
@public_key
=
nil
end
...
...
@@ -100,7 +99,7 @@ class Key < ActiveRecord::Base
def
generate_fingerprint
self
.
fingerprint
=
nil
return
unless
self
.
key
.
present
?
return
unless
public_key
.
valid
?
self
.
fingerprint
=
public_key
.
fingerprint
end
...
...
app/services/issues/move_service.rb
View file @
d777dc3a
...
...
@@ -50,7 +50,8 @@ module Issues
new_params
=
{
id:
nil
,
iid:
nil
,
label_ids:
cloneable_label_ids
,
milestone_id:
cloneable_milestone_id
,
project:
@new_project
,
author:
@old_issue
.
author
,
description:
rewrite_content
(
@old_issue
.
description
)
}
description:
rewrite_content
(
@old_issue
.
description
),
assignee_ids:
@old_issue
.
assignee_ids
}
new_params
=
@old_issue
.
serializable_hash
.
symbolize_keys
.
merge
(
new_params
)
CreateService
.
new
(
@new_project
,
@current_user
,
new_params
).
execute
...
...
changelogs/unreleased/40552-sanitize-extra-blank-spaces-used-when-uploading-a-ssh-key.yml
0 → 100644
View file @
d777dc3a
---
title
:
Sanitize extra blank spaces used when uploading a SSH key
merge_request
:
40552
author
:
type
:
fixed
changelogs/unreleased/41949-move.yml
0 → 100644
View file @
d777dc3a
---
title
:
Remember assignee when moving an issue
merge_request
:
author
:
type
:
fixed
changelogs/unreleased/sh-fix-geo-error-500-gpg-commit.yml
0 → 100644
View file @
d777dc3a
---
title
:
Fix Error 500 when viewing a commit with a GPG signature in Geo
merge_request
:
author
:
type
:
fixed
lib/gitlab/gpg/commit.rb
View file @
d777dc3a
...
...
@@ -60,7 +60,9 @@ module Gitlab
def
create_cached_signature!
using_keychain
do
|
gpg_key
|
GpgSignature
.
create!
(
attributes
(
gpg_key
))
signature
=
GpgSignature
.
new
(
attributes
(
gpg_key
))
signature
.
save!
unless
Gitlab
::
Database
.
read_only?
signature
end
end
...
...
lib/gitlab/ssh_public_key.rb
View file @
d777dc3a
...
...
@@ -21,6 +21,22 @@ module Gitlab
technology
(
name
)
&
.
supported_sizes
end
def
self
.
sanitize
(
key_content
)
ssh_type
,
*
parts
=
key_content
.
strip
.
split
return
key_content
if
parts
.
empty?
parts
.
each_with_object
(
"
#{
ssh_type
}
"
).
with_index
do
|
(
part
,
content
),
index
|
content
<<
part
if
Gitlab
::
SSHPublicKey
.
new
(
content
).
valid?
break
[
content
,
parts
[
index
+
1
]].
compact
.
join
(
' '
)
# Add the comment part if present
elsif
parts
.
size
==
index
+
1
# return original content if we've reached the last element
break
key_content
end
end
end
attr_reader
:key_text
,
:key
# Unqualified MD5 fingerprint for compatibility
...
...
@@ -37,23 +53,23 @@ module Gitlab
end
def
valid?
key
.
present?
SSHKey
.
valid_ssh_public_key?
(
key_text
)
end
def
type
technology
.
name
if
valid
?
technology
.
name
if
key
.
present
?
end
def
bits
return
unless
valid
?
return
if
key
.
blank
?
case
type
when
:rsa
key
.
n
.
num_bits
key
.
n
&
.
num_bits
when
:dsa
key
.
p
.
num_bits
key
.
p
&
.
num_bits
when
:ecdsa
key
.
group
.
order
.
num_bits
key
.
group
.
order
&
.
num_bits
when
:ed25519
256
else
...
...
spec/factories/keys.rb
View file @
d777dc3a
...
...
@@ -5,6 +5,10 @@ FactoryBot.define do
title
key
{
Spec
::
Support
::
Helpers
::
KeyGeneratorHelper
.
new
(
1024
).
generate
+
' dummy@gitlab.com'
}
factory
:key_without_comment
do
key
{
Spec
::
Support
::
Helpers
::
KeyGeneratorHelper
.
new
(
1024
).
generate
}
end
factory
:deploy_key
,
class:
'DeployKey'
factory
:personal_key
do
...
...
@@ -18,38 +22,104 @@ FactoryBot.define do
factory
:rsa_key_2048
do
key
do
<<~
KEY
.
delete
(
"
\n
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dMzJiocs33ESFqXid6ezOtVdDwXHJQRxKGalW1kBbFAPjtMxlD
bf559+7qN2zfCfcQsgTmNAZ7O+wltqJmyLv5i4QqNwPDvyeBvJ4C+770DzlcQtpkflKJ
X+O7i8Ylq34h6UTCTnjry+dFVm1xz97LPf7XuzXGZcAG/eGUNQgxQ2bferKnrpYOXx6c
ocSRj9W54nrRFMWuDeOspWp4MoYK0FRMfDQYPksUayGUnm1KQTGuDbB0ahRNCOm8b3tf
P9Z+vjANAkqenzDuXCpz2PU/Oj6/N/UAAAAhAPOLyut12Mjcp3eUXLe1xSoI5IRXSLso
W9no93dcFNprAAABAQCLhpqKY+PNcwbhhPruL+f+uROghHzDwRNX+e231F4wHHeDDomf
WyLVFj31XrHdDXZnS9tTTj5D2XWLovSSxYb3H7earTctmktL0lQ3HapujzvOkn+VM0pG
s6B3j54+AM3mg50KZdYWxxv+v/lb6oEcsCjfKNyRIx/5pqX6XI3dxl9MMIxrfVWpkNX+
FI68v1LVV61DC9PkNyEHU0v9YBOfrTiS21TIlVIZcSFhuDjg52MekfZAnoKaP7YFJNF3
fdCrXaU3hYQrwB9XdskBUppwxKGhf7O6SWEZhAEfPA9kgxaWHoJvsDz8aca576UNe7BP
mjzo/SLUX+P4uvcaffd+AAABAEqzpmwjzTxB+DV8C+0LnmKf3L/UlQWyGdmhd65rnbkH
GgRMAAkoh4GBOEHL5bznNRmO7X/H6g2fR7SEabxfbvb903KI4nbfFF+3QtnwyIbTBAcH
0893D3bi5rsaJcz+c6lBob2En2nThRciefXUk2oPzCQuDyFIyHLJikqRQVcalHCdQ00c
/H/JkiJedHNqaeU4TeMk8SM53Brjplj/iiJq+ujc5MlEgACdCwWp0BviFACEoYyFaa3R
kc7Xdm9vFpclm9fzgUfPloASA0SkO945in3mIqMfODTb4yRvbjk8If9483fEPgQkczpd
ptBz1VAKg8AmRcz1GmBIxs+Stn0
= dummy@gitlab.com
KEY
end
end
...
...
spec/lib/gitlab/gpg/commit_spec.rb
View file @
d777dc3a
...
...
@@ -49,7 +49,9 @@ describe Gitlab::Gpg::Commit do
end
it
'returns a valid signature'
do
expect
(
described_class
.
new
(
commit
).
signature
).
to
have_attributes
(
signature
=
described_class
.
new
(
commit
).
signature
expect
(
signature
).
to
have_attributes
(
commit_sha:
commit_sha
,
project:
project
,
gpg_key:
gpg_key
,
...
...
@@ -58,9 +60,31 @@ describe Gitlab::Gpg::Commit do
gpg_key_user_email:
GpgHelpers
::
User1
.
emails
.
first
,
verification_status:
'verified'
)
expect
(
signature
.
persisted?
).
to
be_truthy
end
it_behaves_like
'returns the cached signature on second call'
context
'read-only mode'
do
before
do
allow
(
Gitlab
::
Database
).
to
receive
(
:read_only?
).
and_return
(
true
)
end
it
'does not create a cached signature'
do
signature
=
described_class
.
new
(
commit
).
signature
expect
(
signature
).
to
have_attributes
(
commit_sha:
commit_sha
,
project:
project
,
gpg_key:
gpg_key
,
gpg_key_primary_keyid:
GpgHelpers
::
User1
.
primary_keyid
,
gpg_key_user_name:
GpgHelpers
::
User1
.
names
.
first
,
gpg_key_user_email:
GpgHelpers
::
User1
.
emails
.
first
,
verification_status:
'verified'
)
expect
(
signature
.
persisted?
).
to
be_falsey
end
end
end
context
'commit signed with a subkey'
do
...
...
spec/lib/gitlab/ssh_public_key_spec.rb
View file @
d777dc3a
...
...
@@ -37,11 +37,60 @@ describe Gitlab::SSHPublicKey, lib: true do
end
end
describe
'.sanitize(key_content)'
do
let
(
:content
)
{
build
(
:key
).
key
}
context
'when key has blank space characters'
do
it
'removes the extra blank space characters'
do
unsanitized
=
content
.
insert
(
100
,
"
\n
"
)
.
insert
(
40
,
"
\r\n
"
)
.
insert
(
30
,
' '
)
sanitized
=
described_class
.
sanitize
(
unsanitized
)
_
,
body
=
sanitized
.
split
expect
(
sanitized
).
not_to
eq
(
unsanitized
)
expect
(
body
).
not_to
match
(
/\s/
)
end
end
context
"when key doesn't have blank space characters"
do
it
"doesn't modify the content"
do
sanitized
=
described_class
.
sanitize
(
content
)
expect
(
sanitized
).
to
eq
(
content
)
end
end
context
"when key is invalid"
do
it
'returns the original content'
do
unsanitized
=
"ssh-foo any content=="
sanitized
=
described_class
.
sanitize
(
unsanitized
)
expect
(
sanitized
).
to
eq
(
unsanitized
)
end
end
end
describe
'#valid?'
do
subject
{
public_key
}
context
'with a valid SSH key'
do
it
{
is_expected
.
to
be_valid
}
where
(
:factory
)
do
%i(rsa_key_2048
rsa_key_4096
rsa_key_5120
rsa_key_8192
dsa_key_2048
ecdsa_key_256
ed25519_key_256)
end
with_them
do
let
(
:key
)
{
attributes_for
(
factory
)[
:key
]
}
it
{
is_expected
.
to
be_valid
}
end
end
context
'with an invalid SSH key'
do
...
...
@@ -82,6 +131,9 @@ describe Gitlab::SSHPublicKey, lib: true do
where
(
:factory
,
:bits
)
do
[
[
:rsa_key_2048
,
2048
],
[
:rsa_key_4096
,
4096
],
[
:rsa_key_5120
,
5120
],
[
:rsa_key_8192
,
8192
],
[
:dsa_key_2048
,
2048
],
[
:ecdsa_key_256
,
256
],
[
:ed25519_key_256
,
256
]
...
...
@@ -106,8 +158,11 @@ describe Gitlab::SSHPublicKey, lib: true do
where
(
:factory
,
:fingerprint
)
do
[
[
:rsa_key_2048
,
'2e:ca:dc:e0:37:29:ed:fc:f0:1d:bf:66:d4:cd:51:b1'
],
[
:dsa_key_2048
,
'bc:c1:a4:be:7e:8c:84:56:b3:58:93:53:c6:80:78:8c'
],
[
:rsa_key_2048
,
'58:a8:9d:cd:1f:70:f8:5a:d9:e4:24:8e:da:89:e4:fc'
],
[
:rsa_key_4096
,
'df:73:db:29:3c:a5:32:cf:09:17:7e:8e:9d:de:d7:f7'
],
[
:rsa_key_5120
,
'fe:fa:3a:4d:7d:51:ec:bf:c7:64:0c:96:d0:17:8a:d0'
],
[
:rsa_key_8192
,
'fb:53:7f:e9:2f:f7:17:aa:c8:32:52:06:8e:05:e2:82'
],
[
:dsa_key_2048
,
'c8:85:1e:df:44:0f:20:00:3c:66:57:2b:21:10:5a:27'
],
[
:ecdsa_key_256
,
'67:a3:a9:7d:b8:e1:15:d4:80:40:21:34:bb:ed:97:38'
],
[
:ed25519_key_256
,
'e6:eb:45:8a:3c:59:35:5f:e9:5b:80:12:be:7e:22:73'
]
]
...
...
spec/models/key_spec.rb
View file @
d777dc3a
...
...
@@ -12,6 +12,9 @@ describe Key, :mailer do
it
{
is_expected
.
to
validate_presence_of
(
:key
)
}
it
{
is_expected
.
to
validate_length_of
(
:key
).
is_at_most
(
5000
)
}
it
{
is_expected
.
to
allow_value
(
attributes_for
(
:rsa_key_2048
)[
:key
]).
for
(
:key
)
}
it
{
is_expected
.
to
allow_value
(
attributes_for
(
:rsa_key_4096
)[
:key
]).
for
(
:key
)
}
it
{
is_expected
.
to
allow_value
(
attributes_for
(
:rsa_key_5120
)[
:key
]).
for
(
:key
)
}
it
{
is_expected
.
to
allow_value
(
attributes_for
(
:rsa_key_8192
)[
:key
]).
for
(
:key
)
}
it
{
is_expected
.
to
allow_value
(
attributes_for
(
:dsa_key_2048
)[
:key
]).
for
(
:key
)
}
it
{
is_expected
.
to
allow_value
(
attributes_for
(
:ecdsa_key_256
)[
:key
]).
for
(
:key
)
}
it
{
is_expected
.
to
allow_value
(
attributes_for
(
:ed25519_key_256
)[
:key
]).
for
(
:key
)
}
...
...
@@ -72,16 +75,35 @@ describe Key, :mailer do
expect
(
build
(
:key
)).
to
be_valid
end
it
'accepts a key with newline charecters after stripping them'
do
key
=
build
(
:key
)
key
.
key
=
key
.
key
.
insert
(
100
,
"
\n
"
)
key
.
key
=
key
.
key
.
insert
(
40
,
"
\r\n
"
)
expect
(
key
).
to
be_valid
end
it
'rejects the unfingerprintable key (not a key)'
do
expect
(
build
(
:key
,
key:
'ssh-rsa an-invalid-key=='
)).
not_to
be_valid
end
where
(
:factory
,
:chars
,
:expected_sections
)
do
[
[
:key
,
[
"
\n
"
,
"
\r\n
"
],
3
],
[
:key
,
[
' '
,
' '
],
3
],
[
:key_without_comment
,
[
' '
,
' '
],
2
]
]
end
with_them
do
let!
(
:key
)
{
create
(
factory
)
}
let!
(
:original_fingerprint
)
{
key
.
fingerprint
}
it
'accepts a key with blank space characters after stripping them'
do
modified_key
=
key
.
key
.
insert
(
100
,
chars
.
first
).
insert
(
40
,
chars
.
last
)
_
,
content
=
modified_key
.
split
key
.
update!
(
key:
modified_key
)
expect
(
key
).
to
be_valid
expect
(
key
.
key
.
split
.
size
).
to
eq
(
expected_sections
)
expect
(
content
).
not_to
match
(
/\s/
)
expect
(
original_fingerprint
).
to
eq
(
key
.
fingerprint
)
end
end
end
context
'validate it meets key restrictions'
do
...
...
spec/services/issues/move_service_spec.rb
View file @
d777dc3a
...
...
@@ -232,6 +232,28 @@ describe Issues::MoveService do
end
end
context
'issue with assignee'
do
let
(
:assignee
)
{
create
(
:user
)
}
before
do
old_issue
.
assignees
=
[
assignee
]
end
it
'preserves assignee with access to the new issue'
do
new_project
.
add_reporter
(
assignee
)
new_issue
=
move_service
.
execute
(
old_issue
,
new_project
)
expect
(
new_issue
.
assignees
).
to
eq
([
assignee
])
end
it
'ignores assignee without access to the new issue'
do
new_issue
=
move_service
.
execute
(
old_issue
,
new_project
)
expect
(
new_issue
.
assignees
).
to
be_empty
end
end
context
'notes with references'
do
before
do
create
(
:merge_request
,
source_project:
old_project
)
...
...
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