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
c50725fe
Commit
c50725fe
authored
Sep 29, 2017
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address feedback from last code review
parent
c2c35ae7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
16 deletions
+16
-16
app/models/gpg_key.rb
app/models/gpg_key.rb
+5
-0
app/models/gpg_key_subkey.rb
app/models/gpg_key_subkey.rb
+3
-0
app/models/gpg_signature.rb
app/models/gpg_signature.rb
+1
-1
lib/gitlab/gpg.rb
lib/gitlab/gpg.rb
+5
-6
lib/gitlab/gpg/commit.rb
lib/gitlab/gpg/commit.rb
+1
-7
lib/gitlab/gpg/invalid_gpg_signature_updater.rb
lib/gitlab/gpg/invalid_gpg_signature_updater.rb
+1
-2
No files found.
app/models/gpg_key.rb
View file @
c50725fe
...
...
@@ -44,6 +44,7 @@ class GpgKey < ActiveRecord::Base
def
primary_keyid
super
&
.
upcase
end
alias_method
:keyid
,
:primary_keyid
def
fingerprint
super
&
.
upcase
...
...
@@ -53,6 +54,10 @@ class GpgKey < ActiveRecord::Base
super
(
value
&
.
strip
)
end
def
keyids
[
keyid
].
concat
(
subkeys
.
map
(
&
:keyid
))
end
def
user_infos
@user_infos
||=
Gitlab
::
Gpg
.
user_infos_from_key
(
key
)
end
...
...
app/models/gpg_key_subkey.rb
View file @
c50725fe
...
...
@@ -9,6 +9,9 @@ class GpgKeySubkey < ActiveRecord::Base
validates
:gpg_key_id
,
presence:
true
validates
:fingerprint
,
:keyid
,
presence:
true
,
uniqueness:
true
delegate
:key
,
:user
,
:user_infos
,
:verified?
,
:verified_user_infos
,
:verified_and_belongs_to_email?
,
to: :gpg_key
def
keyid
super
&
.
upcase
end
...
...
app/models/gpg_signature.rb
View file @
c50725fe
...
...
@@ -24,7 +24,7 @@ class GpgSignature < ActiveRecord::Base
def
gpg_key
=
(
model
)
case
model
when
GpgKey
then
super
when
GpgKeySubkey
then
write_attribute
(
:gpg_key_subkey_id
,
model
.
id
)
when
GpgKeySubkey
then
self
.
gpg_key_subkey
=
model
end
end
...
...
lib/gitlab/gpg.rb
View file @
c50725fe
...
...
@@ -36,15 +36,14 @@ module Gitlab
def
subkeys_from_key
(
key
)
using_tmp_keychain
do
fingerprints
=
CurrentKeyChain
.
fingerprints_from_key
(
key
)
raw_keys
=
GPGME
::
Key
.
find
(
:public
,
fingerprints
)
grouped_subkeys
=
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
[]
}
fingerprints
=
CurrentKeyChain
.
fingerprints_from_key
(
key
)
raw_keys
=
GPGME
::
Key
.
find
(
:public
,
fingerprints
)
raw_keys
.
each_with_object
(
grouped_subkeys
).
each
do
|
raw_key
,
subkeys
|
raw_keys
.
each_with_object
(
{})
do
|
raw_key
,
grouped_
subkeys
|
primary_subkey_id
=
raw_key
.
primary_subkey
.
keyid
raw_key
.
subkeys
[
1
..-
1
].
each
do
|
subkey
|
subkeys
[
primary_subkey_id
]
<<
{
keyid:
subkey
.
keyid
,
fingerprint:
subkey
.
fingerprint
}
grouped_subkeys
[
primary_subkey_id
]
=
raw_key
.
subkeys
[
1
..-
1
].
map
do
|
s
|
{
keyid:
s
.
keyid
,
fingerprint:
s
.
fingerprint
}
end
end
end
...
...
lib/gitlab/gpg/commit.rb
View file @
c50725fe
...
...
@@ -74,7 +74,7 @@ module Gitlab
commit_sha:
@commit
.
sha
,
project:
@commit
.
project
,
gpg_key:
gpg_key
,
gpg_key_primary_keyid:
gpg_key
id
(
gpg_key
)
||
verified_signature
.
fingerprint
,
gpg_key_primary_keyid:
gpg_key
&
.
keyid
||
verified_signature
.
fingerprint
,
gpg_key_user_name:
user_infos
[
:name
],
gpg_key_user_email:
user_infos
[
:email
],
verification_status:
verification_status
...
...
@@ -99,12 +99,6 @@ module Gitlab
gpg_key
&
.
verified_user_infos
&
.
first
||
gpg_key
&
.
user_infos
&
.
first
||
{}
end
def
gpg_keyid
(
gpg_key
)
return
nil
unless
gpg_key
gpg_key
.
is_a?
(
GpgKey
)
?
gpg_key
.
primary_keyid
:
gpg_key
.
keyid
end
def
find_gpg_key
(
keyid
)
GpgKey
.
find_by
(
primary_keyid:
keyid
)
||
GpgKeySubkey
.
find_by
(
keyid:
keyid
)
end
...
...
lib/gitlab/gpg/invalid_gpg_signature_updater.rb
View file @
c50725fe
...
...
@@ -3,14 +3,13 @@ module Gitlab
class
InvalidGpgSignatureUpdater
def
initialize
(
gpg_key
)
@gpg_key
=
gpg_key
@gpg_keyids
=
gpg_key
.
subkeys
.
map
(
&
:keyid
).
push
(
gpg_key
.
primary_keyid
)
end
def
run
GpgSignature
.
select
(
:id
,
:commit_sha
,
:project_id
)
.
where
(
'gpg_key_id IS NULL OR verification_status <> ?'
,
GpgSignature
.
verification_statuses
[
:verified
])
.
where
(
gpg_key_primary_keyid:
@gpg_keyids
)
.
where
(
gpg_key_primary_keyid:
@gpg_key
.
key
ids
)
.
find_each
{
|
sig
|
sig
.
gpg_commit
.
update_signature!
(
sig
)
}
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