rubygems-openpgp 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.asc +8 -8
- data.tar.gz.asc +8 -8
- data/README.md +1 -1
- data/lib/rubygems/commands/verify_command.rb +10 -0
- data/lib/rubygems/openpgp/gpg_helpers.rb +21 -3
- data/lib/rubygems/openpgp/owner_check.rb +77 -0
- data/lib/rubygems/openpgp/verification.rb +20 -5
- data/lib/rubygems/openpgp/verify_plugins.rb +7 -1
- data/test/test_rubygems-openpgp.rb +1 -1
- metadata +18 -3
- metadata.gz.asc +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f953d2ca99d4e3729240d2875767733e1e0d61e5
|
4
|
+
data.tar.gz: c1d76f6c5ceba471e2efefae1dea8b83d6789090
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d7bc9fa5c42f35d23407754e21f02bf0e740ee9a7368e551f4122a1d2d4251dca69b9dc8dd367192af073400e31d82f3a9d57aca50bc3ae7e0ae7866a241e51
|
7
|
+
data.tar.gz: 3160f28a0fc53e54c6eb472b929401472570cee59210dfc43711e69959ba539933f87e5cee47826305a1305c2dae46656732cce770ce53c1a2bd5dc81d47d788
|
checksums.yaml.gz.asc
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
-----BEGIN PGP SIGNATURE-----
|
2
|
-
Version: GnuPG
|
2
|
+
Version: GnuPG v2.0.17 (GNU/Linux)
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
=
|
4
|
+
iQEcBAABAgAGBQJRRfxRAAoJEP5F5V2hilTWhIUIAJa7y+ItzX0u80MVLlR/fTlL
|
5
|
+
ojiwoo3HoTQpTyUzpbcx2qV55paf9aPy/oWGGKKcsOTJV53rYcXBLz11Klx4ieJB
|
6
|
+
TRAglWQD+XdmH4yGXsU5bjtpDGw3cwanBVTn+9xV29qKMipogrFcLrPHOPNx8wsy
|
7
|
+
RWiaZD7vyQSptHsZVIOguoNkMpv4SUC13BqICurtm+MX9SSCwnxV5DYTPMugwWf7
|
8
|
+
wIHIPX3HEvFSgLBnxaXsjB9BnzIO7D+xt7V946h+jlFMx0awPLvTfbhTUIedOE/j
|
9
|
+
SMUasTxcILBJDUceSsI1TMEhmWpY6DDw81Zaj7B/CF0vBolaEuPlX7v60ZRK1vo=
|
10
|
+
=d2zb
|
11
11
|
-----END PGP SIGNATURE-----
|
data.tar.gz.asc
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
-----BEGIN PGP SIGNATURE-----
|
2
|
-
Version: GnuPG
|
2
|
+
Version: GnuPG v2.0.17 (GNU/Linux)
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
iQEcBAABAgAGBQJRRfxOAAoJEP5F5V2hilTWzQYH/1cMPlLm1UdI2elmZpoYdemn
|
5
|
+
RQFLiPLrgjED8xYOaoLE2YEjMU3eMmCnPA9gZxErAEqcbArZJzV31q8DoOC25I9n
|
6
|
+
lJa1JWIAVJP+gvXCdqTam9P4m5wxl/pO9dQlDPUR2/sbyPZ82jLJH8HV3MAyXjHo
|
7
|
+
Vmul6cPZ94BskTD+Nj8/wkmHe7YHVl5b7lNrUgeG8RNo3v9c6PswrT5VG1kRi2sx
|
8
|
+
8F/vw85pfThjtga/p4F5dZRqQ6YOBoHrM8qgp2Xq2wqEhEizGlMda+Xp1Qr8IQYG
|
9
|
+
U/jEPJAGbwNTZlmtyfLMXz5MiAwS0Ejf2XR8P8nB3nZyUVNvtLziU/Lr7m9aXnA=
|
10
|
+
=u5Oy
|
11
11
|
-----END PGP SIGNATURE-----
|
data/README.md
CHANGED
@@ -59,7 +59,7 @@ rubygems-openpgp](http://www.rubygems-openpgp-ca.org/blog/the-complete-guide-to-
|
|
59
59
|
A test gem **openpgp_signed_hola** is on rubygems.org. To try out
|
60
60
|
this extension:
|
61
61
|
|
62
|
-
gem install openpgp_signed_hola-0.0.0.gem --
|
62
|
+
gem install openpgp_signed_hola-0.0.0.gem --trust --get-key
|
63
63
|
|
64
64
|
|
65
65
|
### But That Just Failed!
|
@@ -24,6 +24,16 @@ class Gem::Commands::VerifyCommand < Gem::Command
|
|
24
24
|
options[:get_key] = true
|
25
25
|
end
|
26
26
|
|
27
|
+
add_option("--trust",
|
28
|
+
'Enforce gnupg trust settings. Only install if trusted.') do |value, options|
|
29
|
+
Gem::OpenPGP.options[:trust] = true
|
30
|
+
end
|
31
|
+
|
32
|
+
add_option("--no-trust",
|
33
|
+
"Ignoure gnupg trust settings, even if --trust has previously been specified") do |value, options|
|
34
|
+
Gem::OpenPGP.options[:no_trust] = true
|
35
|
+
end
|
36
|
+
|
27
37
|
end
|
28
38
|
|
29
39
|
def arguments # :nodoc:
|
@@ -14,11 +14,29 @@ private
|
|
14
14
|
|
15
15
|
# Tests to see if gpg is installed and available.
|
16
16
|
def self.is_gpg_available
|
17
|
-
|
17
|
+
|
18
18
|
`gpg --version`
|
19
|
-
|
19
|
+
abort_if_shell_error
|
20
20
|
rescue Errno::ENOENT => ex
|
21
|
-
|
21
|
+
abort_if_shell_error
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.abort_if_shell_error
|
25
|
+
install_msg = <<FOO
|
26
|
+
Couldn't find gpg. Don't have it? It'll only take a few minutes to install.
|
27
|
+
|
28
|
+
Windows installer available at http://gpg4win.org/
|
29
|
+
|
30
|
+
OSX installer available at https://www.gpgtools.org/
|
31
|
+
|
32
|
+
FOO
|
33
|
+
err_msg = "Unable to find a working gnupg installation. Make sure gnupg is installed and you can call 'gpg --version' from a command prompt."
|
34
|
+
|
35
|
+
if $? != 0
|
36
|
+
puts install_msg
|
37
|
+
raise Gem::OpenPGPException, err_msg
|
38
|
+
end
|
22
39
|
end
|
40
|
+
|
23
41
|
|
24
42
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'rubygems/user_interaction'
|
2
|
+
require 'gems'
|
3
|
+
|
4
|
+
module Gem::OpenPGP
|
5
|
+
def self.check_rubygems_org_owner gem_name, fingerprint
|
6
|
+
uids_and_trust = get_good_uids(fingerprint)
|
7
|
+
owners = Gems.owners(gem_name).map { |o| o["email"] }
|
8
|
+
|
9
|
+
good_owner_status = find_good_owner(uids_and_trust, owners)
|
10
|
+
if !good_owner_status
|
11
|
+
valid_uids = uids_and_trust.map { |x| x[:uid] }
|
12
|
+
say add_color("Couldn't match good UID against rubygems.org owners!", :red)
|
13
|
+
say add_color("\tGood User Ids: #{pretty_email_list(valid_uids)}", :red)
|
14
|
+
say add_color("\trubygems.org Owners: #{pretty_email_list(owners)}", :red)
|
15
|
+
end
|
16
|
+
|
17
|
+
good_owner_status
|
18
|
+
rescue Errno::ECONNREFUSED, SocketError => ex
|
19
|
+
say add_color("Can't verify ownership. Couldn't connect with rubygems.org.", :yellow)
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def self.pretty_email_list list
|
26
|
+
list.select { |x| !(x.nil? || x.empty?)}.join(", ")
|
27
|
+
end
|
28
|
+
|
29
|
+
# Extract good trusted UIDs from a given fingerprint
|
30
|
+
def self.get_good_uids fingerprint
|
31
|
+
good_uids = []
|
32
|
+
|
33
|
+
key_info = `gpg --with-colons --list-keys #{fingerprint}`
|
34
|
+
key_info.split("\n").each do |line|
|
35
|
+
line = line.strip
|
36
|
+
fields = line.split(":")
|
37
|
+
|
38
|
+
next if !['pub','uid'].include?(fields.first)
|
39
|
+
|
40
|
+
trust = fields[1]
|
41
|
+
next if ['r','i','d','e','n'].include? trust # clearly invalid
|
42
|
+
|
43
|
+
# If we're in --trust mode, we skip unknown uids.
|
44
|
+
if options[:trust]
|
45
|
+
next if !['f','m','u'].include?(trust)
|
46
|
+
end
|
47
|
+
|
48
|
+
uid = fields[9]
|
49
|
+
good_uids << {:uid => uid, :trust => trust}
|
50
|
+
end
|
51
|
+
|
52
|
+
good_uids
|
53
|
+
end
|
54
|
+
|
55
|
+
# match up valid trusted uid with good owner if possible
|
56
|
+
def self.find_good_owner uids_and_trust, owners
|
57
|
+
good_owner = false
|
58
|
+
|
59
|
+
uids_and_trust.each do |u|
|
60
|
+
uid = u[:uid]
|
61
|
+
email = if uid.include? "<"
|
62
|
+
/<([^>]+)>/.match(uid)[1]
|
63
|
+
else
|
64
|
+
uid
|
65
|
+
end
|
66
|
+
|
67
|
+
if owners.include? email
|
68
|
+
say add_color("Owner check indicates #{email} is owner per rubygems.org...", :green)
|
69
|
+
good_owner = true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
good_owner
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
end
|
@@ -11,6 +11,7 @@ require 'rubygems/openpgp/keymaster'
|
|
11
11
|
require 'rubygems/openpgp/options'
|
12
12
|
require 'rubygems/openpgp/gpg_helpers'
|
13
13
|
require 'rubygems/openpgp/openpgpexception'
|
14
|
+
require 'rubygems/openpgp/owner_check'
|
14
15
|
|
15
16
|
module Gem::OpenPGP
|
16
17
|
extend Gem::UserInteraction
|
@@ -35,7 +36,7 @@ module Gem::OpenPGP
|
|
35
36
|
homedir_flags = ""
|
36
37
|
homedir_flags = "--homedir #{homedir}" if homedir
|
37
38
|
|
38
|
-
gpg_args = "#{get_key_params} #{homedir_flags} --verify #{sig_file.path} #{data_file.path}"
|
39
|
+
gpg_args = "#{get_key_params} #{homedir_flags} --with-colons --verify #{sig_file.path} #{data_file.path}"
|
39
40
|
|
40
41
|
status_info = {:file_name => file_name}
|
41
42
|
gpg_results = GPGStatusParser.run_gpg(gpg_args) { |message| verify_extract_status_info(message, status_info) }
|
@@ -86,7 +87,7 @@ module Gem::OpenPGP
|
|
86
87
|
raise Gem::OpenPGPException, "Can't verify without sig, aborting!!!"
|
87
88
|
end
|
88
89
|
|
89
|
-
|
90
|
+
begin
|
90
91
|
fingerprints << Gem::OpenPGP.verify(file_name, tar_files[file_name], tar_files[sig_file_name], get_key, homedir)
|
91
92
|
rescue Gem::OpenPGPException => ex
|
92
93
|
color_code = "31"
|
@@ -95,9 +96,12 @@ module Gem::OpenPGP
|
|
95
96
|
end
|
96
97
|
end
|
97
98
|
|
98
|
-
|
99
|
-
|
99
|
+
fingerprints.uniq!
|
100
|
+
|
101
|
+
# Verify fingerprint and owner
|
102
|
+
fingerprints.each do |fp|
|
100
103
|
verify_gem_check_fingerprint gem_name, fp
|
104
|
+
owner_checks gem_name, fp
|
101
105
|
end
|
102
106
|
|
103
107
|
ensure
|
@@ -106,6 +110,17 @@ module Gem::OpenPGP
|
|
106
110
|
|
107
111
|
private
|
108
112
|
|
113
|
+
def self.owner_checks gem_name, fp
|
114
|
+
if !check_rubygems_org_owner(gem_name, fp)
|
115
|
+
if options[:ignore_owner_check]
|
116
|
+
say add_color("Ignoring bad owner status because you told me to!",:yellow)
|
117
|
+
else
|
118
|
+
say add_color("Use --ignore-owner-check to install anyway.", :yellow)
|
119
|
+
raise Gem::OpenPGPException, "BADOWNER"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
109
124
|
# Extract the info we care about, throw away the rest
|
110
125
|
def self.verify_extract_status_info message, status_info
|
111
126
|
case message.status
|
@@ -116,7 +131,7 @@ module Gem::OpenPGP
|
|
116
131
|
when :SIG_ID
|
117
132
|
when :VALIDSIG, :EXPSIG, :BADSIG
|
118
133
|
status_info[:sig_status] = message.status
|
119
|
-
status_info[:primary_key] = "0x#{message.args[:primary_key_fpr][-
|
134
|
+
status_info[:primary_key] = "0x#{message.args[:primary_key_fpr][-8..-1]}"
|
120
135
|
status_info[:primary_key_fingerprint] = message.args[:primary_key_fpr]
|
121
136
|
when :TRUST_UNDEFINED, :TRUST_NEVER, :TRUST_MARGINAL, :TRUST_FULLY, :TRUST_ULTIMATE
|
122
137
|
status_info[:trust_status] = message.status
|
@@ -27,6 +27,11 @@ i.add_option("--no-trust",
|
|
27
27
|
Gem::OpenPGP.options[:no_trust] = true
|
28
28
|
end
|
29
29
|
|
30
|
+
i.add_option("--ignore-owner-check",
|
31
|
+
"Ignore a failed ownership check against rubygems.org") do |value, options|
|
32
|
+
Gem::OpenPGP.options[:ignore_owner_check] = true
|
33
|
+
end
|
34
|
+
|
30
35
|
i.add_option('--get-key', "If the key is not available, download it from a keyserver") do |key, options|
|
31
36
|
Gem::OpenPGP.options[:get_key] = true
|
32
37
|
end
|
@@ -34,7 +39,8 @@ end
|
|
34
39
|
Gem.pre_install do |installer|
|
35
40
|
begin
|
36
41
|
# --no-verify overrides --verify
|
37
|
-
if Gem::OpenPGP.options[:verify] && !Gem::OpenPGP.options[:no_verify]
|
42
|
+
if (Gem::OpenPGP.options[:verify] && !Gem::OpenPGP.options[:no_verify]) ||
|
43
|
+
(Gem::OpenPGP.options[:trust] && !Gem::OpenPGP.options[:no_trust])
|
38
44
|
Gem::OpenPGP.verify_gem(installer.gem,
|
39
45
|
Gem::OpenPGP.options[:get_key])
|
40
46
|
end
|
@@ -21,7 +21,7 @@ class RubygemsPluginTest < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_gem_sign_and_verify
|
24
|
-
Gem::OpenPGP.stubs(:verify_gem_check_fingerprint => true)
|
24
|
+
Gem::OpenPGP.stubs(:verify_gem_check_fingerprint => true, :check_rubygems_org_owner => true)
|
25
25
|
|
26
26
|
in_tmp_gpg_homedir do |gpg_home|
|
27
27
|
assert_raise Gem::OpenPGPException do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubygems-openpgp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grant Olson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gpg_status_parser
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.4.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gems
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.7.1
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: mocha
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,6 +72,7 @@ files:
|
|
58
72
|
- lib/rubygems/openpgp/keymaster.rb
|
59
73
|
- lib/rubygems/openpgp/verify_plugins.rb
|
60
74
|
- lib/rubygems/openpgp/sign_plugins.rb
|
75
|
+
- lib/rubygems/openpgp/owner_check.rb
|
61
76
|
- lib/rubygems/openpgp/openpgpexception.rb
|
62
77
|
- README.md
|
63
78
|
- test/test_keymaster.rb
|
@@ -65,7 +80,7 @@ files:
|
|
65
80
|
- test/pablo_escobar_seckey.asc
|
66
81
|
- test/pablo_escobar_pubkey.asc
|
67
82
|
- test/unsigned_hola-0.0.0.gem
|
68
|
-
homepage:
|
83
|
+
homepage: https://www.rubygems-openpgp-ca.org
|
69
84
|
licenses:
|
70
85
|
- BSD 3 Clause
|
71
86
|
metadata: {}
|
metadata.gz.asc
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
-----BEGIN PGP SIGNATURE-----
|
2
|
-
Version: GnuPG
|
2
|
+
Version: GnuPG v2.0.17 (GNU/Linux)
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
=
|
4
|
+
iQEcBAABAgAGBQJRRfxJAAoJEP5F5V2hilTW6cIIAI02JVhjEr5UQYfNq7OF7D+T
|
5
|
+
Icey5OmnmAOBlkZNiukGcQTT9LsbysXZoKelk3r6NFToO+vsWJK2wpRHfxkYIgkI
|
6
|
+
O75DnYZ7Pcgd5foEtAWi0K0BHbKK9huGSX4vjMcXzN28EXiasDI9j1Eh6rOTsBdX
|
7
|
+
eiJDeMMyvBZmAEcQH0hWoNtBhOYk3+BBTnGbt+ORTRBOON/hCtZPnVkG3HObruka
|
8
|
+
KPafC3r9wQcvdvi1WvFiypaPvqo61lFCt8a0DBES2r8BKOjK08V+/vIRc+wTKikG
|
9
|
+
uYnWDPYmbMSl00h6Nrc7u6+DPN5JlHAuz0L9HItQjBDJMCb+f45FgwNPa70C8qE=
|
10
|
+
=uJVJ
|
11
11
|
-----END PGP SIGNATURE-----
|