legion-crypt 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd2d51f77fcc6ca9912e92fbc1a7aa633182d17c503d8ae9b0c130de46e9c3d6
4
- data.tar.gz: f2973995be01490a44a894e52809391c40e0dcfce69b3f6517a2c662f3b30f99
3
+ metadata.gz: 94f0199322913d4badab5e1cd29ad29613d8590d1112a9ceffcfbffdfcf2604d
4
+ data.tar.gz: 0a901ac3efe8c894440a5888097311172c517a2f5519f08f8772976ce4b22dd5
5
5
  SHA512:
6
- metadata.gz: 52d19767ddc8bf1d5919c63176118cb6160179dea6670c7ac513cc6895d0c3fab7d2d7a0588475176fc392e9d7d952668b80449b101768c72b3130a5e5f74e5e
7
- data.tar.gz: '088e8074518db4634c575e5f409eac8a890c40b84ba6445ab6eb7ff4c0505b5f4abad62a7dd4f2a274426e7df98aec9bae3d0b9d5a66b93535aea311670f3e47'
6
+ metadata.gz: 4356dcc6172a9615b9f5eef18b7f92eb4f6ba8faf51e03fbe043a90b4dbf8286037343a45c4e7738ce6d84e6cd3ade84c704743ded75389873c06247200bac6d
7
+ data.tar.gz: 81b04201cf2885f9558f3b349c5457b08fdb971041b7999cd5b139f456bbc24338f71561457d4267f92682c1b6ba31141ab09ffcd6ae755acd12a5f5117e8837
@@ -1,11 +1,12 @@
1
1
  version: 2.1
2
2
  orbs:
3
3
  ruby: circleci/ruby@0.2.1
4
+ sonarcloud: sonarsource/sonarcloud@1.0.2
4
5
 
5
6
  jobs:
6
7
  "rubocop":
7
8
  docker:
8
- - image: circleci/ruby:2.5-node
9
+ - image: circleci/ruby:2.7-node
9
10
  steps:
10
11
  - checkout
11
12
  - ruby/load-cache
@@ -18,9 +19,13 @@ jobs:
18
19
  docker:
19
20
  - image: circleci/ruby:2.5
20
21
  - image: memcached:1.5-alpine
22
+ - image: rabbitmq:3.7
21
23
  steps:
22
24
  - checkout
23
25
  - ruby/load-cache
26
+ - run:
27
+ name: update bundler
28
+ command: gem update bundler
24
29
  - ruby/install-deps
25
30
  - ruby/run-tests
26
31
  - ruby/save-cache
@@ -28,9 +33,13 @@ jobs:
28
33
  docker:
29
34
  - image: circleci/ruby:2.6
30
35
  - image: memcached:1.5-alpine
36
+ - image: rabbitmq:3.7
31
37
  steps:
32
38
  - checkout
33
39
  - ruby/load-cache
40
+ - run:
41
+ name: update bundler
42
+ command: gem update bundler
34
43
  - ruby/install-deps
35
44
  - ruby/run-tests
36
45
  - ruby/save-cache
@@ -38,9 +47,13 @@ jobs:
38
47
  docker:
39
48
  - image: circleci/ruby:2.7
40
49
  - image: memcached:1.5-alpine
50
+ - image: rabbitmq:3.7
41
51
  steps:
42
52
  - checkout
43
53
  - ruby/load-cache
54
+ - run:
55
+ name: update bundler
56
+ command: gem update bundler
44
57
  - ruby/install-deps
45
58
  - ruby/run-tests
46
59
  - ruby/save-cache
data/Gemfile CHANGED
@@ -3,4 +3,3 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
- gem 'legionio', path: '../legion'
@@ -0,0 +1,142 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ legion-crypt (0.2.1)
5
+ vault
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ amq-protocol (2.3.2)
11
+ ast (2.4.1)
12
+ aws-eventstream (1.1.0)
13
+ aws-sigv4 (1.2.2)
14
+ aws-eventstream (~> 1, >= 1.0.2)
15
+ bunny (2.16.1)
16
+ amq-protocol (~> 2.3, >= 2.3.1)
17
+ concurrent-ruby (1.1.7)
18
+ concurrent-ruby-ext (1.1.7)
19
+ concurrent-ruby (= 1.1.7)
20
+ connection_pool (2.2.3)
21
+ daemons (1.3.1)
22
+ dalli (2.7.10)
23
+ diff-lcs (1.4.4)
24
+ docile (1.3.2)
25
+ faraday (1.0.1)
26
+ multipart-post (>= 1.2, < 3)
27
+ faraday_middleware (1.0.0)
28
+ faraday (~> 1.0)
29
+ hashdiff (1.0.1)
30
+ json (2.3.1)
31
+ json (2.3.1-java)
32
+ json_pure (2.3.1)
33
+ legion-cache (1.0.0)
34
+ connection_pool
35
+ dalli
36
+ redis
37
+ legion-data (1.1.2)
38
+ legion-logging
39
+ legion-settings
40
+ mysql2
41
+ sequel
42
+ legion-exceptions (1.1.0)
43
+ legion-json (1.1.2)
44
+ json_pure
45
+ multi_json
46
+ legion-logging (1.1.1)
47
+ rainbow (~> 3)
48
+ legion-settings (1.1.1)
49
+ legion-json
50
+ legion-logging
51
+ legion-transport (1.1.3)
52
+ bunny
53
+ concurrent-ruby
54
+ legion-json
55
+ legionio (0.2.0)
56
+ concurrent-ruby
57
+ concurrent-ruby-ext
58
+ daemons
59
+ hashdiff
60
+ legion-cache
61
+ legion-crypt
62
+ legion-data
63
+ legion-exceptions
64
+ legion-json
65
+ legion-logging
66
+ legion-settings
67
+ legion-transport
68
+ sleepiq
69
+ vault
70
+ multi_json (1.15.0)
71
+ multipart-post (2.1.1)
72
+ mysql2 (0.5.3)
73
+ parallel (1.19.2)
74
+ parser (2.7.1.4)
75
+ ast (~> 2.4.1)
76
+ rainbow (3.0.0)
77
+ rake (13.0.1)
78
+ redis (4.2.1)
79
+ regexp_parser (1.7.1)
80
+ rexml (3.2.4)
81
+ rspec (3.9.0)
82
+ rspec-core (~> 3.9.0)
83
+ rspec-expectations (~> 3.9.0)
84
+ rspec-mocks (~> 3.9.0)
85
+ rspec-core (3.9.2)
86
+ rspec-support (~> 3.9.3)
87
+ rspec-expectations (3.9.2)
88
+ diff-lcs (>= 1.2.0, < 2.0)
89
+ rspec-support (~> 3.9.0)
90
+ rspec-mocks (3.9.1)
91
+ diff-lcs (>= 1.2.0, < 2.0)
92
+ rspec-support (~> 3.9.0)
93
+ rspec-support (3.9.3)
94
+ rspec_junit_formatter (0.4.1)
95
+ rspec-core (>= 2, < 4, != 2.12.0)
96
+ rubocop (0.89.1)
97
+ parallel (~> 1.10)
98
+ parser (>= 2.7.1.1)
99
+ rainbow (>= 2.2.2, < 4.0)
100
+ regexp_parser (>= 1.7)
101
+ rexml
102
+ rubocop-ast (>= 0.3.0, < 1.0)
103
+ ruby-progressbar (~> 1.7)
104
+ unicode-display_width (>= 1.4.0, < 2.0)
105
+ rubocop-ast (0.3.0)
106
+ parser (>= 2.7.1.4)
107
+ ruby-progressbar (1.10.1)
108
+ sequel (5.35.0)
109
+ simplecov (0.17.1)
110
+ docile (~> 1.1)
111
+ json (>= 1.8, < 3)
112
+ simplecov-html (~> 0.10.0)
113
+ simplecov-html (0.10.2)
114
+ sleepiq (0.2.2)
115
+ dalli
116
+ faraday
117
+ faraday_middleware
118
+ thor
119
+ thor (1.0.1)
120
+ unicode-display_width (1.7.0)
121
+ vault (0.15.0)
122
+ aws-sigv4
123
+
124
+ PLATFORMS
125
+ java
126
+ ruby
127
+
128
+ DEPENDENCIES
129
+ bundler
130
+ legion-crypt!
131
+ legion-logging
132
+ legion-settings
133
+ legion-transport
134
+ legionio
135
+ rake
136
+ rspec
137
+ rspec_junit_formatter
138
+ rubocop
139
+ simplecov (< 0.18.0)
140
+
141
+ BUNDLED WITH
142
+ 2.1.4
@@ -21,19 +21,19 @@ Gem::Specification.new do |spec|
21
21
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
22
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
23
  end
24
- spec.bindir = 'exe'
25
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
25
  spec.require_paths = ['lib']
27
26
 
28
- spec.add_dependency 'rbnacl'
29
27
  spec.add_dependency 'vault'
30
28
 
29
+ spec.add_development_dependency 'bundler'
30
+ spec.add_development_dependency 'legionio'
31
31
  spec.add_development_dependency 'legion-logging'
32
32
  spec.add_development_dependency 'legion-settings'
33
33
  spec.add_development_dependency 'legion-transport'
34
- # spec.add_development_dependency 'legionio'
35
34
  spec.add_development_dependency 'rake'
36
35
  spec.add_development_dependency 'rspec'
36
+ spec.add_development_dependency 'rspec_junit_formatter'
37
37
  spec.add_development_dependency 'rubocop'
38
- # spec.add_development_dependency 'simplecov', '< 0.18.0'
38
+ spec.add_development_dependency 'simplecov', '< 0.18.0'
39
39
  end
@@ -1,14 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'openssl'
4
+ require 'base64'
4
5
  require 'legion/crypt/version'
5
6
  require 'legion/crypt/settings'
6
- require 'rbnacl'
7
- require 'base64'
8
7
 
9
- require 'legion/crypt/box'
10
8
  require 'legion/crypt/cipher'
11
- require 'legion/crypt/vault'
12
9
 
13
10
  module Legion
14
11
  module Crypt
@@ -16,7 +13,11 @@ module Legion
16
13
  attr_reader :sessions
17
14
 
18
15
  include Legion::Crypt::Cipher
19
- include Legion::Crypt::Vault if Legion::Settings[:crypt][:vault][:enabled]
16
+
17
+ if Legion::Settings[:crypt][:vault][:enabled]
18
+ require 'legion/crypt/vault'
19
+ include Legion::Crypt::Vault
20
+ end
20
21
 
21
22
  def start
22
23
  Legion::Logging.debug 'Legion::Crypt is running start'
@@ -83,7 +83,7 @@ module Legion
83
83
  end
84
84
 
85
85
  def generate_secure_random
86
- SecureRandom.alphanumeric(32)
86
+ SecureRandom.uuid
87
87
  end
88
88
  end
89
89
  end
@@ -5,7 +5,8 @@ module Legion
5
5
  {
6
6
  vault: vault,
7
7
  cs_encrypt_ready: false,
8
- dynamic_keys: true
8
+ dynamic_keys: true,
9
+ cluster_secret: nil
9
10
  }
10
11
  end
11
12
 
@@ -27,4 +28,9 @@ module Legion
27
28
  end
28
29
  end
29
30
 
30
- Legion::Settings.merge_settings('crypt', Legion::Crypt::Settings.default) if Legion.const_defined?('Settings')
31
+ begin
32
+ Legion::Settings.merge_settings('crypt', Legion::Crypt::Settings.default) if Legion.const_defined?('Settings')
33
+ rescue StandardError => e
34
+ Legion::Logging.fatal(e.message) if Legion::Logging.method_defined?(:fatal)
35
+ Legion::Logging.fatal(e.backtrace) if Legion::Logging.method_defined?(:fatal)
36
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module Crypt
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
@@ -0,0 +1,5 @@
1
+ {
2
+ "transport": {
3
+ "vhost": "/"
4
+ }
5
+ }
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-crypt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-20 00:00:00.000000000 Z
11
+ date: 2020-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rbnacl
14
+ name: vault
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,13 +25,27 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: vault
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
- type: :runtime
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: legionio
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
@@ -108,6 +122,20 @@ dependencies:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec_junit_formatter
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
111
139
  - !ruby/object:Gem::Dependency
112
140
  name: rubocop
113
141
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +150,20 @@ dependencies:
122
150
  - - ">="
123
151
  - !ruby/object:Gem::Version
124
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "<"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.18.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "<"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.18.0
125
167
  description: Integrates with Hashicorps vault and other encryption type things
126
168
  email:
127
169
  - matthewdiverson@gmail.com
@@ -131,15 +173,10 @@ extra_rdoc_files: []
131
173
  files:
132
174
  - ".circleci/config.yml"
133
175
  - ".gitignore"
134
- - ".idea/.rakeTasks"
135
- - ".idea/legion-crypt.iml"
136
- - ".idea/misc.xml"
137
- - ".idea/modules.xml"
138
- - ".idea/vagrant.xml"
139
- - ".idea/workspace.xml"
140
176
  - ".rspec"
141
177
  - ".rubocop.yml"
142
178
  - Gemfile
179
+ - Gemfile.lock
143
180
  - LICENSE.txt
144
181
  - README.md
145
182
  - Rakefile
@@ -147,12 +184,12 @@ files:
147
184
  - bin/setup
148
185
  - legion-crypt.gemspec
149
186
  - lib/legion/crypt.rb
150
- - lib/legion/crypt/box.rb
151
187
  - lib/legion/crypt/cipher.rb
152
188
  - lib/legion/crypt/settings.rb
153
189
  - lib/legion/crypt/vault.rb
154
190
  - lib/legion/crypt/vault_renewer.rb
155
191
  - lib/legion/crypt/version.rb
192
+ - settings/transport.json
156
193
  homepage: https://bitbucket.org/legion-io/legion-vault/
157
194
  licenses:
158
195
  - MIT
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Settings><!--This file was automatically generated by Ruby plugin.
3
- You are allowed to:
4
- 1. Remove rake task
5
- 2. Add existing rake tasks
6
- To add existing rake tasks automatically delete this file and reload the project.
7
- --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build legion-crypt-0.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install legion-crypt-0.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install legion-crypt-0.1.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.0 and build and push legion-crypt-0.1.0.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
@@ -1,54 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="RUBY_MODULE" version="4">
3
- <component name="ModuleRunConfigurationManager">
4
- <shared />
5
- </component>
6
- <component name="NewModuleRootManager">
7
- <content url="file://$MODULE_DIR$" />
8
- <orderEntry type="jdk" jdkName="RVM: ruby-2.7.0" jdkType="RUBY_SDK" />
9
- <orderEntry type="sourceFolder" forTests="false" />
10
- <orderEntry type="library" scope="PROVIDED" name="amq-protocol (v2.3.2, RVM: ruby-2.7.0) [gem]" level="application" />
11
- <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.1, RVM: ruby-2.7.0) [gem]" level="application" />
12
- <orderEntry type="library" scope="PROVIDED" name="aws-eventstream (v1.1.0, RVM: ruby-2.7.0) [gem]" level="application" />
13
- <orderEntry type="library" scope="PROVIDED" name="aws-sigv4 (v1.2.2, RVM: ruby-2.7.0) [gem]" level="application" />
14
- <orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, RVM: ruby-2.7.0) [gem]" level="application" />
15
- <orderEntry type="library" scope="PROVIDED" name="bunny (v2.16.1, RVM: ruby-2.7.0) [gem]" level="application" />
16
- <orderEntry type="library" scope="PROVIDED" name="chef (v16.1.0, RVM: ruby-2.7.0) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.7, RVM: ruby-2.7.0) [gem]" level="application" />
18
- <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby-ext (v1.1.7, RVM: ruby-2.7.0) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="connection_pool (v2.2.3, RVM: ruby-2.7.0) [gem]" level="application" />
20
- <orderEntry type="library" scope="PROVIDED" name="daemons (v1.3.1, RVM: ruby-2.7.0) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="dalli (v2.7.10, RVM: ruby-2.7.0) [gem]" level="application" />
22
- <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.4.4, RVM: ruby-2.7.0) [gem]" level="application" />
23
- <orderEntry type="library" scope="PROVIDED" name="ffi (v1.13.1, RVM: ruby-2.7.0) [gem]" level="application" />
24
- <orderEntry type="library" scope="PROVIDED" name="hashdiff (v1.0.1, RVM: ruby-2.7.0) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="legion-cache (v1.0.0, RVM: ruby-2.7.0) [gem]" level="application" />
26
- <orderEntry type="library" scope="PROVIDED" name="legion-data (v0.2.0, RVM: ruby-2.7.0) [gem]" level="application" />
27
- <orderEntry type="library" scope="PROVIDED" name="legion-exceptions (v1.1.0, RVM: ruby-2.7.0) [gem]" level="application" />
28
- <orderEntry type="library" scope="PROVIDED" name="legion-json (v1.1.0, RVM: ruby-2.7.0) [gem]" level="application" />
29
- <orderEntry type="library" scope="PROVIDED" name="legion-logging (v1.1.0, RVM: ruby-2.7.0) [gem]" level="application" />
30
- <orderEntry type="library" scope="PROVIDED" name="legion-settings (v1.1.1, RVM: ruby-2.7.0) [gem]" level="application" />
31
- <orderEntry type="library" scope="PROVIDED" name="legion-transport (v1.1.0, RVM: ruby-2.7.0) [gem]" level="application" />
32
- <orderEntry type="library" scope="PROVIDED" name="multi_json (v1.15.0, RVM: ruby-2.7.0) [gem]" level="application" />
33
- <orderEntry type="library" scope="PROVIDED" name="mysql2 (v0.5.3, RVM: ruby-2.7.0) [gem]" level="application" />
34
- <orderEntry type="library" scope="PROVIDED" name="parallel (v1.19.2, RVM: ruby-2.7.0) [gem]" level="application" />
35
- <orderEntry type="library" scope="PROVIDED" name="parser (v2.7.1.4, RVM: ruby-2.7.0) [gem]" level="application" />
36
- <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, RVM: ruby-2.7.0) [gem]" level="application" />
37
- <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.1, RVM: ruby-2.7.0) [gem]" level="application" />
38
- <orderEntry type="library" scope="PROVIDED" name="rbnacl (v7.1.1, RVM: ruby-2.7.0) [gem]" level="application" />
39
- <orderEntry type="library" scope="PROVIDED" name="redis (v4.2.1, RVM: ruby-2.7.0) [gem]" level="application" />
40
- <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v1.7.1, RVM: ruby-2.7.0) [gem]" level="application" />
41
- <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.4, RVM: ruby-2.7.0) [gem]" level="application" />
42
- <orderEntry type="library" scope="PROVIDED" name="rspec (v3.9.0, RVM: ruby-2.7.0) [gem]" level="application" />
43
- <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.9.2, RVM: ruby-2.7.0) [gem]" level="application" />
44
- <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.9.2, RVM: ruby-2.7.0) [gem]" level="application" />
45
- <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.9.1, RVM: ruby-2.7.0) [gem]" level="application" />
46
- <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.9.3, RVM: ruby-2.7.0) [gem]" level="application" />
47
- <orderEntry type="library" scope="PROVIDED" name="rubocop (v0.89.1, RVM: ruby-2.7.0) [gem]" level="application" />
48
- <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v0.3.0, RVM: ruby-2.7.0) [gem]" level="application" />
49
- <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.10.1, RVM: ruby-2.7.0) [gem]" level="application" />
50
- <orderEntry type="library" scope="PROVIDED" name="sequel (v5.35.0, RVM: ruby-2.7.0) [gem]" level="application" />
51
- <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v1.7.0, RVM: ruby-2.7.0) [gem]" level="application" />
52
- <orderEntry type="library" scope="PROVIDED" name="vault (v0.15.0, RVM: ruby-2.7.0) [gem]" level="application" />
53
- </component>
54
- </module>
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptSettings">
4
- <option name="languageLevel" value="ES6" />
5
- </component>
6
- <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.6.3" project-jdk-type="RUBY_SDK" />
7
- </project>
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/legion-crypt.iml" filepath="$PROJECT_DIR$/.idea/legion-crypt.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VagrantProjectSettings">
4
- <option name="instanceFolder" value="" />
5
- <option name="provider" value="" />
6
- </component>
7
- </project>
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="CoverageOptionsProvider">
4
- <option name="myAddOrReplace" value="0" />
5
- </component>
6
- <component name="Git.Settings">
7
- <option name="PUSH_AUTO_UPDATE" value="true" />
8
- <option name="ROOT_SYNC" value="DONT_SYNC" />
9
- </component>
10
- <component name="ProjectId" id="1Yk09ZatgP1aKTE1VrPrnkK2STE" />
11
- <component name="PropertiesComponent">
12
- <property name="settings.editor.selected.configurable" value="reference.settingsdialog.project.vagrant" />
13
- </component>
14
- </project>
@@ -1,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Legion
4
- module Crypt
5
- module Box
6
- def create_keys
7
- Legion::Logging.debug 'Legion::Crypt::Box.create_keys has been called'
8
- @private_key = RbNaCl::PrivateKey.generate
9
- @public_key = @private_key.public_key
10
- return unless Dir.exist? './settings'
11
-
12
- File.open('./settings/private.key', 'w').write(@private_key.to_s)
13
- File.open('./settings/public.key', 'w').write(@public_key.to_s)
14
- end
15
-
16
- def delete_keys
17
- File.delete('./settings/private.key') if File.exist? './settings/private.key'
18
- File.delete('./settings/public.key') if File.exist? './settings/public.key'
19
- end
20
-
21
- def load_keys
22
- return unless Dir.exist? './settings'
23
-
24
- @private_key = RbNaCl::PrivateKey.new(File.read('./settings/private.key').force_encoding('BINARY'))
25
- @public_key = RbNaCl::PrivateKey.new(File.read('./settings/public.key').force_encoding('BINARY'))
26
- end
27
-
28
- def encrypt_from_keypair(public_key:, message:, **_opts)
29
- Legion::Logging.debug('encrypt_from_keypair')
30
- Base64.encode64(RbNaCl::SimpleBox.from_keypair(Base64.decode64(public_key), @private_key).encrypt(message))
31
- end
32
-
33
- def decrypt_from_keypair(public_key, enciphered_message)
34
- Legion::Logging.debug 'decrypt_from_keypair'
35
- RbNaCl::SimpleBox
36
- .from_keypair(Base64.decode64(public_key), @private_key)
37
- .decrypt(Base64.decode64(enciphered_message))
38
- end
39
-
40
- def encrypt(message)
41
- Legion::Logging.debug 'encrypting message'
42
- Base64.encode64(@box.encrypt(message))
43
- end
44
-
45
- def decrypt(message)
46
- Legion::Logging.debug 'decrypting message'
47
- @box.decrypt(Base64.decode64(message))
48
- end
49
-
50
- def setup_safe # rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity
51
- Legion::Logging.debug 'Setting up Legion::Crypt safe'
52
- if Legion::Settings[:crypt][:cluster_secret].nil?
53
- if Legion::Settings[:crypt][:vault][:connected] && Legion::Crypt.exist?('crypt')
54
- Legion::Settings[:crypt][:cluster_secret] = Base64.decode64(Legion::Crypt.get('crypt')[:cluster_secret])
55
- elsif Legion::Transport::Queue.new('node.crypt', passive: true).consumer_count.zero?
56
- Legion::Logging.info 'Legion::Crypt Generating new cluster_secret since this is the first node'
57
- Legion::Settings[:crypt][:bootstrapped] = true
58
- Legion::Settings[:crypt][:cluster_secret] = RbNaCl::Random.random_bytes(RbNaCl::SecretBox.key_bytes)
59
- if Legion::Settings[:crypt][:vault][:connected]
60
- Legion::Crypt.write('crypt', :cluster_secret, Base64.encode64(Legion::Settings[:crypt][:cluster_secret]))
61
- end
62
- else
63
- require 'legion/transport/messages/request_cluster_secret'
64
- Legion::Logging.info 'Requesting cluster secret via public key'
65
- start = Time.now
66
- Legion::Transport::Messages::RequestClusterSecret.new.publish
67
- sleep_time = 0.001
68
- until !Legion::Settings[:crypt][:cluster_secret].nil? || (Time.now - start) > Legion::Settings[:crypt][:cluster_secret_timeout]
69
- sleep(sleep_time)
70
- sleep_time *= 2
71
- end
72
- unless Legion::Settings[:crypt][:cluster_secret].nil?
73
- Legion::Logging.info "Received cluster secret in #{((Time.new - start) * 1000.0).round}ms"
74
- end
75
- Legion::Logging.warn 'Cluster secret is still nil' if Legion::Settings[:crypt][:cluster_secret].nil?
76
- end
77
- end
78
-
79
- @key = Legion::Settings[:crypt][:cluster_secret].to_s
80
- @box = RbNaCl::SimpleBox.from_secret_key(@key) unless @key.empty?
81
- if !Legion::Settings[:crypt].key?(:encrypted_string) || !Legion::Settings[:crypt].key?(:validation_string)
82
- unless Legion::Settings[:crypt][:bootstrapped]
83
- Legion::Logging.warn 'Legion::Crypt has been set up but wasn\'t testing with a validation string!'
84
- end
85
- Legion::Settings[:crypt][:cs_encrypt_ready] = true
86
- elsif Legion::Crypt.decrypt(Legion::Settings[:crypt][:encrypted_string]) == Legion::Settings[:crypt][:validation_string]
87
- Legion::Logging.info 'Legion::Crypt was set up correctly after string match'
88
- Legion::Settings[:crypt][:cs_encrypt_ready] = true
89
- else
90
- Legion::Logging.fatal 'idk wtf happened'
91
- end
92
- end
93
- end
94
- end
95
- end