mellon 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/bin/mellon +11 -2
- data/lib/mellon/keychain.rb +5 -1
- data/lib/mellon/store.rb +2 -6
- data/lib/mellon/version.rb +1 -1
- data/spec/mellon/keychain_spec.rb +9 -0
- data/spec/mellon/store_spec.rb +7 -0
- data/spec/mellon_spec.rb +1 -1
- data/spec/spec_helper.rb +8 -0
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8678fd19fa9cfae39812816421a3909d45eaeb2
|
4
|
+
data.tar.gz: 03e80fc20be1c93f769f25fcd081e3166fe1deb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8da897237648b63ee5b3c21d9ae0dfad9f90e6c24a9a70ab714de7d352deb997201250eeb1995e17c8eae6fce8b315b2890627182631c9d1b67b2a9e6128ec4
|
7
|
+
data.tar.gz: f1d71b5cd507568290b8aed46feafe6390eedb4481043e1391a527a86ab5af875a41b6ea8ca5812f83a2339d726e0d11ea98368ec6909e1efac9e1f78d9456ec
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
[HEAD][]
|
2
2
|
--------
|
3
3
|
|
4
|
+
[v1.1.1][]
|
5
|
+
----------
|
6
|
+
|
7
|
+
- Fix Mellon::Store for empty keychain entries (c3d1da52)
|
8
|
+
- Fix mistaking error reading keychain from missing entry (782d2d82)
|
9
|
+
- Show stderr and exit status when `mellon edit` fails (fd2eecee)
|
10
|
+
|
4
11
|
[v1.1.0][]
|
5
12
|
----------
|
6
13
|
|
@@ -14,6 +21,7 @@
|
|
14
21
|
|
15
22
|
Initial release!
|
16
23
|
|
17
|
-
[HEAD]: https://github.com/elabs/mellon/compare/v1.1.
|
24
|
+
[HEAD]: https://github.com/elabs/mellon/compare/v1.1.1...HEAD
|
25
|
+
[v1.1.1]: https://github.com/elabs/mellon/compare/v1.1.0...v1.1.1
|
18
26
|
[v1.1.0]: https://github.com/elabs/mellon/compare/v1.0.0...v1.1.0
|
19
27
|
[v1.0.0]: https://github.com/elabs/mellon/compare/24b83977d...v1.0.0
|
data/bin/mellon
CHANGED
@@ -101,11 +101,20 @@ Slop.parse(strict: true, help: true) do
|
|
101
101
|
exit false
|
102
102
|
end
|
103
103
|
|
104
|
+
require "shellwords"
|
104
105
|
require "tempfile"
|
105
106
|
Tempfile.open([name, ".txt"]) do |io|
|
106
107
|
File.write io.path, keychain[name]
|
107
|
-
|
108
|
-
|
108
|
+
stderr_r, stderr_w = IO.pipe
|
109
|
+
system("$EDITOR #{Shellwords.escape(io.path)}", :err => stderr_w)
|
110
|
+
status = $?
|
111
|
+
stderr_w.close
|
112
|
+
|
113
|
+
if status.success?
|
114
|
+
keychain[name] = File.read(io.path)
|
115
|
+
else
|
116
|
+
$stderr.puts "[#{status}] #{stderr_r.read}"
|
117
|
+
end
|
109
118
|
end
|
110
119
|
end
|
111
120
|
end
|
data/lib/mellon/keychain.rb
CHANGED
@@ -3,6 +3,8 @@ require "plist"
|
|
3
3
|
module Mellon
|
4
4
|
# Keychain provides simple methods for reading and storing keychain entries.
|
5
5
|
class Keychain
|
6
|
+
ENTRY_MISSING = /SecKeychainSearchCopyNext/.freeze
|
7
|
+
|
6
8
|
class << self
|
7
9
|
# Find the first keychain that contains the key.
|
8
10
|
#
|
@@ -11,7 +13,8 @@ module Mellon
|
|
11
13
|
def search(key)
|
12
14
|
output = ShellUtils.security("find-generic-password", "-l", key)
|
13
15
|
new(output[/keychain: "(.+)"/i, 1], ensure_exists: false)
|
14
|
-
rescue CommandError
|
16
|
+
rescue CommandError => e
|
17
|
+
raise unless e.message =~ ENTRY_MISSING
|
15
18
|
nil
|
16
19
|
end
|
17
20
|
|
@@ -140,6 +143,7 @@ module Mellon
|
|
140
143
|
[Utils.parse_info(info), Utils.parse_contents(password_info)]
|
141
144
|
end
|
142
145
|
rescue CommandError => e
|
146
|
+
raise unless e.message =~ ENTRY_MISSING
|
143
147
|
nil
|
144
148
|
end
|
145
149
|
|
data/lib/mellon/store.rb
CHANGED
data/lib/mellon/version.rb
CHANGED
@@ -86,6 +86,15 @@ describe Mellon::Keychain do
|
|
86
86
|
it "returns nil when there is no entry with the given name" do
|
87
87
|
keychain["nonexisting note"].should be_nil
|
88
88
|
end
|
89
|
+
|
90
|
+
it "raises an error when command exits for a reason other than key missing" do
|
91
|
+
error = Mellon::CommandError.new(<<-ERROR)
|
92
|
+
security find-generic-password -g -l unreadable /Users/dev/Projects/mellon/spec/temporary_keychain.keychain
|
93
|
+
security: SecKeychainItemCopyAccess: In dark wake, no UI possible
|
94
|
+
ERROR
|
95
|
+
Mellon::ShellUtils.should_receive(:sh).and_raise(error)
|
96
|
+
expect { keychain["simple"] }.to raise_error(Mellon::CommandError, /dark wake/)
|
97
|
+
end
|
89
98
|
end
|
90
99
|
|
91
100
|
describe "#[]=" do
|
data/spec/mellon/store_spec.rb
CHANGED
@@ -50,6 +50,13 @@ describe Mellon::Store do
|
|
50
50
|
store = Mellon::Store.new("missing project", keychain: keychain)
|
51
51
|
store["some value"].should be_nil
|
52
52
|
end
|
53
|
+
|
54
|
+
it "returns nil if keychain item is empty" do
|
55
|
+
store = Mellon::Store.new("empty", keychain: keychain)
|
56
|
+
store["some value"].should be_nil
|
57
|
+
store["some value"] = "New value"
|
58
|
+
store["some value"].should eq "New value"
|
59
|
+
end
|
53
60
|
end
|
54
61
|
|
55
62
|
describe "#[]=" do
|
data/spec/mellon_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -6,6 +6,14 @@ keychain_path = File.expand_path("./temporary_keychain.keychain", __dir__)
|
|
6
6
|
original_keychain_path = File.expand_path("./keychain.keychain", __dir__)
|
7
7
|
|
8
8
|
RSpec.configure do |config|
|
9
|
+
config.expect_with :rspec do |c|
|
10
|
+
c.syntax = [:expect, :should]
|
11
|
+
end
|
12
|
+
|
13
|
+
config.mock_with :rspec do |c|
|
14
|
+
c.syntax = :should
|
15
|
+
end
|
16
|
+
|
9
17
|
config.around do |example|
|
10
18
|
FileUtils.cp(original_keychain_path, keychain_path)
|
11
19
|
example.run
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mellon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kim Burgestrand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plist
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: slop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.6'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.6'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: pry
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description:
|
@@ -102,8 +102,8 @@ executables:
|
|
102
102
|
extensions: []
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
|
-
- .gitignore
|
106
|
-
- .rspec
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
107
|
- CHANGELOG.md
|
108
108
|
- Gemfile
|
109
109
|
- LICENSE
|
@@ -133,17 +133,17 @@ require_paths:
|
|
133
133
|
- lib
|
134
134
|
required_ruby_version: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
140
|
requirements:
|
141
|
-
- -
|
141
|
+
- - ">="
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: '0'
|
144
144
|
requirements: []
|
145
145
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.2.
|
146
|
+
rubygems_version: 2.2.1
|
147
147
|
signing_key:
|
148
148
|
specification_version: 4
|
149
149
|
summary: A command-line utility for managing secret application credentials via OSX
|