dinomischus 0.1.4 → 0.1.5
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 +14 -0
- data/exe/dinomischus +14 -4
- data/lib/dinomischus.rb +19 -10
- data/lib/dinomischus/l_conf.rb +7 -4
- data/lib/dinomischus/l_def.rb +3 -3
- data/lib/dinomischus/l_key.rb +0 -2
- data/lib/dinomischus/{crypt_aes.rb → utils/crypt_aes.rb} +0 -0
- data/lib/dinomischus/utils/crypt_dino.rb +37 -0
- data/lib/dinomischus/{merge_yaml.rb → utils/merge_yaml.rb} +0 -0
- data/lib/dinomischus/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9be59068e706c1dbc49c6f9571fd3f9213caeab3b36794a48aac55ee72a9c721
|
|
4
|
+
data.tar.gz: 935a13f4059df89faed1d9d7391fb9564a083dd7f78f91133bc1d2108c66ebfa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e91250f997fae463e4a6d2ed1c340258d30645d692c509339949b5d90b43cbf398adf072e65246096d210f3b5b23923ab77f2d7fa2e0dc8df27c1b7ea266a1a2
|
|
7
|
+
data.tar.gz: 9d06db65c79a773f5d6719710e172596c4ba2769d3d7a3d3858153165fe5ece37870df77cc71ffa52d3dd2e994816e8ac4a5d6e07b015a5b745b593d765c3201
|
data/README.md
CHANGED
|
@@ -109,6 +109,20 @@ hash = Dinomischus.load_file('project_name_config_index.yml')
|
|
|
109
109
|
```
|
|
110
110
|
The setting value of ```:fruit``` changed to ```banana``` depending on the file read later.
|
|
111
111
|
|
|
112
|
+
### For Reading by the CLI
|
|
113
|
+
|
|
114
|
+
get 1 value
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
bash$ dinomischus -g -f [FileName] -k [key]
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
get key-value list
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
bash$ dinomischus -l -f [FileName]
|
|
124
|
+
```
|
|
125
|
+
|
|
112
126
|
### For Write Setting
|
|
113
127
|
|
|
114
128
|
|
data/exe/dinomischus
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require_relative '../lib/dinomischus'
|
|
4
4
|
require 'optparse'
|
|
5
5
|
Version = Dinomischus::VERSION
|
|
6
6
|
|
|
@@ -21,11 +21,11 @@ class Command
|
|
|
21
21
|
@options.include?(name)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
#
|
|
24
|
+
# 指定したオプションを全て指定しているか?
|
|
25
25
|
def has_all?(*names)
|
|
26
26
|
all_finded = true
|
|
27
27
|
names.each do |nm|
|
|
28
|
-
finded = @options.include?(
|
|
28
|
+
finded = @options.include?(nm)
|
|
29
29
|
$stderr.puts("This Command needs '#{nm}' option. ") unless finded
|
|
30
30
|
all_finded &&= finded
|
|
31
31
|
end
|
|
@@ -44,6 +44,16 @@ class Command
|
|
|
44
44
|
def self.CmdList( path )
|
|
45
45
|
Dinomischus.load_file( path )
|
|
46
46
|
end
|
|
47
|
+
|
|
48
|
+
def self.PrintHash( hash )
|
|
49
|
+
# pp "#{value}"
|
|
50
|
+
max_length = hash.keys.max_by(&:length).length
|
|
51
|
+
print "{\n"
|
|
52
|
+
hash.each do |k, v|
|
|
53
|
+
print sprintf(" %<key>-#{max_length}s : %<value>s \n", {key:k, value:v})
|
|
54
|
+
end
|
|
55
|
+
print "}\n"
|
|
56
|
+
end
|
|
47
57
|
end
|
|
48
58
|
|
|
49
59
|
# メニュー振り分け処理と引数チェック
|
|
@@ -59,7 +69,7 @@ case true
|
|
|
59
69
|
when cmd.has?(:list) then
|
|
60
70
|
return unless cmd.has_all?(:file)
|
|
61
71
|
value = Command.CmdList( cmd.get(:file) )
|
|
62
|
-
|
|
72
|
+
Command.PrintHash(value)
|
|
63
73
|
|
|
64
74
|
# CUI メニュー表示
|
|
65
75
|
when cmd.has?(:menu) then
|
data/lib/dinomischus.rb
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
require 'yaml'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
require File.expand_path("../dinomischus/l_conf.rb", __FILE__)
|
|
10
|
-
require File.expand_path("../dinomischus/menu.rb", __FILE__)
|
|
3
|
+
require_relative "./dinomischus/version"
|
|
4
|
+
require_relative "./dinomischus/utils/merge_yaml.rb"
|
|
5
|
+
require_relative "./dinomischus/l_key.rb"
|
|
6
|
+
require_relative "./dinomischus/l_def.rb"
|
|
7
|
+
require_relative "./dinomischus/l_conf.rb"
|
|
8
|
+
require_relative "./dinomischus/menu.rb"
|
|
11
9
|
|
|
12
10
|
|
|
13
11
|
module Dinomischus
|
|
@@ -40,13 +38,24 @@ module Dinomischus
|
|
|
40
38
|
def self.load_file( path, specify = false )
|
|
41
39
|
# get loading target
|
|
42
40
|
yml = YAML.load_file(path)
|
|
43
|
-
files = yml[0].has_key?(:conf_path) ? yml : [ {conf_path: path} ]
|
|
41
|
+
# files = yml[0].has_key?(:conf_path) ? yml : [ {conf_path: path} ]
|
|
42
|
+
# base_dir = yml[0].has_key?
|
|
43
|
+
files = []
|
|
44
|
+
base_dir = ""
|
|
45
|
+
if yml[0].has_key?(:conf_path) then
|
|
46
|
+
files = yml
|
|
47
|
+
base_dir = File.dirname(path)
|
|
48
|
+
else
|
|
49
|
+
files = [ {conf_path: path} ]
|
|
50
|
+
base_dir = Dir.pwd
|
|
51
|
+
end
|
|
44
52
|
|
|
45
53
|
# loading config files...
|
|
46
54
|
config_list = {}
|
|
47
55
|
files.each do |p|
|
|
48
56
|
items = {}
|
|
49
|
-
|
|
57
|
+
conf_path = File.expand_path(p[:conf_path], base_dir )
|
|
58
|
+
items = load_conf(conf_path, specify)
|
|
50
59
|
merge_yaml(config_list, items)
|
|
51
60
|
end
|
|
52
61
|
config_list
|
data/lib/dinomischus/l_conf.rb
CHANGED
|
@@ -4,7 +4,7 @@ require 'optparse'
|
|
|
4
4
|
require 'securerandom'
|
|
5
5
|
require 'base64'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
require_relative './utils/crypt_dino.rb'
|
|
8
8
|
|
|
9
9
|
module Dinomischus
|
|
10
10
|
|
|
@@ -32,7 +32,8 @@ module Dinomischus
|
|
|
32
32
|
key_path = yml[0][:key_path]
|
|
33
33
|
raise RuntimeError.new("鍵ファイルが存在しません。#{key_path}") if !File.exist?(key_path)
|
|
34
34
|
|
|
35
|
-
val_text = do_encrypt ? "?#{exec_encrypt( key_path, value)}" : value
|
|
35
|
+
#val_text = do_encrypt ? "?#{exec_encrypt( key_path, value)}" : value
|
|
36
|
+
val_text = do_encrypt ? "?#{Dinomischus::dino_encrypt( key_path, value)}" : value
|
|
36
37
|
|
|
37
38
|
yml[1][key.to_sym] = {"value": val_text, "desc": desc}
|
|
38
39
|
File.open(conf_path, 'w') do |f|
|
|
@@ -46,7 +47,8 @@ module Dinomischus
|
|
|
46
47
|
raise RuntimeError.new("設定ファイルが存在しません。#{conf_path}") if !File.exist?(conf_path)
|
|
47
48
|
|
|
48
49
|
conf_file = YAML.load_file(conf_path)
|
|
49
|
-
key_path = conf_file[0][:key_path]
|
|
50
|
+
key_path = sprintf("%s", conf_file[0][:key_path] )
|
|
51
|
+
key_path = File.expand_path(key_path, File.dirname(conf_path))
|
|
50
52
|
raw_items = conf_file[1]
|
|
51
53
|
items = {}
|
|
52
54
|
raw_items.keys.each do |key|
|
|
@@ -70,7 +72,8 @@ module Dinomischus
|
|
|
70
72
|
if value.match /^\?.*/
|
|
71
73
|
ret.gsub!("\n","")
|
|
72
74
|
ret = ret[/\?(.*)/, 1]
|
|
73
|
-
ret = exec_decrypt(key_path, ret)
|
|
75
|
+
#ret = exec_decrypt(key_path, ret)
|
|
76
|
+
ret = Dinomischus::dino_decrypt(key_path, ret)
|
|
74
77
|
else
|
|
75
78
|
ret = value
|
|
76
79
|
end
|
data/lib/dinomischus/l_def.rb
CHANGED
|
@@ -4,8 +4,7 @@ require 'optparse'
|
|
|
4
4
|
require 'securerandom'
|
|
5
5
|
require 'base64'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
require File.expand_path('../l_conf.rb', __FILE__)
|
|
7
|
+
require_relative './l_conf.rb'
|
|
9
8
|
|
|
10
9
|
module Dinomischus
|
|
11
10
|
attr_reader :items
|
|
@@ -31,7 +30,8 @@ module Dinomischus
|
|
|
31
30
|
files = load_file(def_path)
|
|
32
31
|
configs = {}
|
|
33
32
|
files.each do |f|
|
|
34
|
-
|
|
33
|
+
conf_path = File.expand_path(f[:conf_path], def_path)
|
|
34
|
+
cfg = Dinomischus::ConfFile.load_file(conf_path)
|
|
35
35
|
configs.merge!(cfg)
|
|
36
36
|
end
|
|
37
37
|
configs
|
data/lib/dinomischus/l_key.rb
CHANGED
|
File without changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'base64'
|
|
2
|
+
require 'securerandom'
|
|
3
|
+
require_relative './crypt_aes.rb'
|
|
4
|
+
|
|
5
|
+
module Dinomischus
|
|
6
|
+
def self.dino_encrypt(key_path, value)
|
|
7
|
+
raise RuntimeError.new("鍵ファイルが存在しません。#{key_path}") if !File.exist?(key_path)
|
|
8
|
+
|
|
9
|
+
keys = YAML.load_file(key_path)
|
|
10
|
+
enctype = keys[:key][:type]
|
|
11
|
+
if enctype == "sha256"
|
|
12
|
+
# sha256の処理。
|
|
13
|
+
pass = keys[:key][:value]
|
|
14
|
+
enc1 = Crypter::CryptAes.encrypt( value, pass, true )
|
|
15
|
+
enc2 = Crypter::CryptAes.encrypt( enc1.to_s, pass, false )
|
|
16
|
+
else
|
|
17
|
+
raise RuntimeError.new("未サポートの暗号です。#{enctype}")
|
|
18
|
+
end
|
|
19
|
+
enc2[0]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.dino_decrypt(key_path, value)
|
|
23
|
+
raise RuntimeError.new("鍵ファイルが存在しません。#{key_path}") if !File.exist?(key_path)
|
|
24
|
+
|
|
25
|
+
keys = YAML.load_file(key_path)
|
|
26
|
+
enctype = keys[:key][:type]
|
|
27
|
+
if enctype == "sha256"
|
|
28
|
+
pass = keys[:key][:value]
|
|
29
|
+
v2 = Crypter::CryptAes.decrypt( value, pass )
|
|
30
|
+
v1raw = YAML.load(v2)
|
|
31
|
+
v1 = Crypter::CryptAes.decrypt( v1raw[0], pass, v1raw[1])
|
|
32
|
+
else
|
|
33
|
+
raise RuntimeError.new("未サポートの暗号です。#{enctype}")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
File without changes
|
data/lib/dinomischus/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dinomischus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kuroko Sin
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-11-
|
|
11
|
+
date: 2020-11-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email:
|
|
@@ -30,12 +30,13 @@ files:
|
|
|
30
30
|
- dinomischus.gemspec
|
|
31
31
|
- exe/dinomischus
|
|
32
32
|
- lib/dinomischus.rb
|
|
33
|
-
- lib/dinomischus/crypt_aes.rb
|
|
34
33
|
- lib/dinomischus/l_conf.rb
|
|
35
34
|
- lib/dinomischus/l_def.rb
|
|
36
35
|
- lib/dinomischus/l_key.rb
|
|
37
36
|
- lib/dinomischus/menu.rb
|
|
38
|
-
- lib/dinomischus/
|
|
37
|
+
- lib/dinomischus/utils/crypt_aes.rb
|
|
38
|
+
- lib/dinomischus/utils/crypt_dino.rb
|
|
39
|
+
- lib/dinomischus/utils/merge_yaml.rb
|
|
39
40
|
- lib/dinomischus/version.rb
|
|
40
41
|
homepage: https://github.com/kurokoSin/Dinomischus
|
|
41
42
|
licenses:
|