secure_conf 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/Rakefile +7 -3
- data/exe/secure_conf.rb +1 -1
- data/lib/secure_conf/config.rb +5 -5
- data/lib/secure_conf/openssh.rb +2 -2
- data/lib/secure_conf/storage/yaml.rb +3 -1
- data/lib/secure_conf/version.rb +1 -1
- data/secure_conf.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abe2a25e6dbe9aac46965807a20fcdcf507db1635961c19f86c9f08b1c68c2e2
|
4
|
+
data.tar.gz: fcbfd1b8c33ab8b0c3a0708a522b1c49ca4ee07009c9af2596ebefe8e58608ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9e1b112d53d48f6e2eaf445f1faea965e4df0d9b092c8022353bcd53b8b212d9df4fc2883ff496c385e5dcdc2296a9aa898b215e7a41cb982793c7d7131abe4
|
7
|
+
data.tar.gz: 90e342f51a1698cad0b71e905f1a481b597fb25c5cdd9aeb281a8d7bee28c0d1fe930abc357ecb0194afbcae5f23366ae6ab986d5a5d1b4a3945b563bf8101f6
|
data/README.md
CHANGED
@@ -32,6 +32,21 @@ Or install it yourself as:
|
|
32
32
|
p config["enc:pass"]
|
33
33
|
p config["last_access"]
|
34
34
|
|
35
|
+
## Usage cli
|
36
|
+
|
37
|
+
% secure_conf.rb read enc:pass
|
38
|
+
read
|
39
|
+
key: enc:pass
|
40
|
+
val: himitsu
|
41
|
+
|
42
|
+
% secure_conf.rb --help
|
43
|
+
Usage: secure_conf.rb [options] method [arguments]...
|
44
|
+
--pkey privatekey_path PrivateKey file path (default: ~/.ssh/id_rsa)
|
45
|
+
--storage storage_path Storage file path (default: ./secure.yml)
|
46
|
+
methods usage:
|
47
|
+
secure_conf.rb [options] read key
|
48
|
+
secure_conf.rb [options] write key value
|
49
|
+
secure_conf.rb [options] delete key
|
35
50
|
|
36
51
|
## Development
|
37
52
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require "
|
2
|
+
require "rake/testtask"
|
3
3
|
|
4
|
-
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
8
|
+
end
|
5
9
|
|
6
|
-
task :default => :
|
10
|
+
task :default => :test
|
data/exe/secure_conf.rb
CHANGED
@@ -24,7 +24,7 @@ class SecureConfCmd
|
|
24
24
|
|
25
25
|
pkey = File.open(@privatekey_path, "r") {|f| f.read}
|
26
26
|
|
27
|
-
@config = SecureConf::Config.new(@storage_path,
|
27
|
+
@config = SecureConf::Config.new(@storage_path, encrypter: SecureConf::Encrypter.new(pkey), auto_commit: true)
|
28
28
|
end
|
29
29
|
@config
|
30
30
|
end
|
data/lib/secure_conf/config.rb
CHANGED
@@ -3,14 +3,14 @@ require 'delegate'
|
|
3
3
|
module SecureConf
|
4
4
|
class Config < SimpleDelegator
|
5
5
|
attr_reader :path
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :encrypter
|
7
7
|
attr_reader :serializer
|
8
8
|
attr_reader :storage
|
9
9
|
attr_accessor :auto_commit
|
10
10
|
|
11
|
-
def initialize(path,
|
11
|
+
def initialize(path, encrypter: nil, serializer: nil, storage: nil, auto_commit: false)
|
12
12
|
@path = path
|
13
|
-
@
|
13
|
+
@encrypter = encrypter || SecureConf.default
|
14
14
|
@serializer = serializer || Serializer::Marshal
|
15
15
|
@storage = storage || Storage.fetch(path)
|
16
16
|
@auto_commit = auto_commit
|
@@ -26,7 +26,7 @@ module SecureConf
|
|
26
26
|
|
27
27
|
def secure_store(key, value)
|
28
28
|
value = @serializer.dump(value)
|
29
|
-
plain_store(key, @
|
29
|
+
plain_store(key, @encrypter.encrypt(value))
|
30
30
|
end
|
31
31
|
|
32
32
|
def store(key, value)
|
@@ -47,7 +47,7 @@ module SecureConf
|
|
47
47
|
def [](key)
|
48
48
|
value = plain_get(key)
|
49
49
|
if value && key.to_s.start_with?("enc:")
|
50
|
-
value = @
|
50
|
+
value = @encrypter.decrypt(value)
|
51
51
|
value = @serializer.load(value)
|
52
52
|
end
|
53
53
|
value
|
data/lib/secure_conf/openssh.rb
CHANGED
@@ -12,7 +12,7 @@ module SecureConf
|
|
12
12
|
# pem string
|
13
13
|
@h = parse_pem(source)
|
14
14
|
|
15
|
-
elsif IO===source
|
15
|
+
elsif IO===source || source.respond_to?(:read)
|
16
16
|
# pem io
|
17
17
|
source = source.read
|
18
18
|
@h = parse_pem(source)
|
@@ -269,7 +269,7 @@ module SecureConf
|
|
269
269
|
exponent1 = d % (p - 1)
|
270
270
|
exponent2 = d % (q - 1)
|
271
271
|
|
272
|
-
|
272
|
+
OpenSSL::ASN1::Sequence.new([
|
273
273
|
OpenSSL::ASN1::Integer.new(0),
|
274
274
|
OpenSSL::ASN1::Integer.new(h[:privatekey][:n].unpack("H*")[0].to_i(16)),
|
275
275
|
OpenSSL::ASN1::Integer.new(h[:privatekey][:e].unpack("H*")[0].to_i(16)),
|
data/lib/secure_conf/version.rb
CHANGED
data/secure_conf.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secure_conf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yoshida
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '12.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '5.0'
|
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
|
-
version: '
|
54
|
+
version: '5.0'
|
55
55
|
description: To encrypt the configuration value.
|
56
56
|
email:
|
57
57
|
- yoshida.eth0@gmail.com
|