Commit 4768afbd authored by Keith Pope's avatar Keith Pope

Add simple identifier to public SSH keys

parent e299504b
...@@ -18,6 +18,7 @@ v 8.11.0 (unreleased) ...@@ -18,6 +18,7 @@ v 8.11.0 (unreleased)
- Fix renaming repository when name contains invalid chararacters under project settings - Fix renaming repository when name contains invalid chararacters under project settings
- Optimize checking if a user has read access to a list of issues !5370 - Optimize checking if a user has read access to a list of issues !5370
- Nokogiri's various parsing methods are now instrumented - Nokogiri's various parsing methods are now instrumented
- Add simple identifier to public SSH keys (muteor)
- Add a way to send an email and create an issue based on private personal token. Find the email address from issues page. !3363 - Add a way to send an email and create an issue based on private personal token. Find the email address from issues page. !3363
- Add build event color in HipChat messages (David Eisner) - Add build event color in HipChat messages (David Eisner)
- Make fork counter always clickable. !5463 (winniehell) - Make fork counter always clickable. !5463 (winniehell)
......
...@@ -26,8 +26,9 @@ class Key < ActiveRecord::Base ...@@ -26,8 +26,9 @@ class Key < ActiveRecord::Base
end end
def publishable_key def publishable_key
# Removes anything beyond the keytype and key itself # Strip out the keys comment so we don't leak email addresses
self.key.split[0..1].join(' ') # Replace with simple ident of user_name (hostname)
self.key.split[0..1].push("#{self.user_name} (#{Gitlab.config.gitlab.host})").join(' ')
end end
# projects that has this key # projects that has this key
......
...@@ -16,12 +16,13 @@ describe Key, models: true do ...@@ -16,12 +16,13 @@ describe Key, models: true do
end end
describe "Methods" do describe "Methods" do
let(:user) { create(:user) }
it { is_expected.to respond_to :projects } it { is_expected.to respond_to :projects }
it { is_expected.to respond_to :publishable_key } it { is_expected.to respond_to :publishable_key }
describe "#publishable_keys" do describe "#publishable_keys" do
it 'strips all personal information' do it 'replaces SSH key comment with simple identifier of username + hostname' do
expect(build(:key).publishable_key).not_to match(/dummy@gitlab/) expect(build(:key, user: user).publishable_key).to match(/#{Regexp.escape(user.name)} \(localhost\)/)
end end
end end
end end
......
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