legion-crypt 0.2.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,6 +22,10 @@ module Legion
22
22
 
23
23
  require_relative 'vault_renewer'
24
24
  @renewer = Legion::Crypt::Vault::Renewer.new
25
+ rescue StandardError => e
26
+ Legion::Logging.error e.message
27
+ Legion::Settings[:crypt][:vault][:connected] = false
28
+ false
25
29
  end
26
30
 
27
31
  def read(path, type = 'legion')
@@ -32,20 +36,18 @@ module Legion
32
36
  end
33
37
 
34
38
  def get(path)
35
- result = ::Vault.kv('legion').read(path)
39
+ result = ::Vault.kv(settings[:vault][:kv_path]).read(path)
36
40
  return nil if result.nil?
37
41
 
38
42
  result.data
39
43
  end
40
44
 
41
- def write(path, key, value)
42
- hash = {}
43
- hash[key.to_sym] = value
44
- ::Vault.kv('legion').write(path, **hash)
45
+ def write(path, **hash)
46
+ ::Vault.kv(settings[:vault][:kv_path]).write(path, **hash)
45
47
  end
46
48
 
47
49
  def exist?(path)
48
- !::Vault.kv('legion').read_metadata(path).nil?
50
+ !::Vault.kv(settings[:vault][:kv_path]).read_metadata(path).nil?
49
51
  end
50
52
 
51
53
  def add_session(path:)
@@ -53,9 +55,10 @@ module Legion
53
55
  end
54
56
 
55
57
  def close_sessions
56
- Legion::Logging.info 'Closing all Legion::Crypt vault sessions'
57
58
  return if @sessions.nil?
58
59
 
60
+ Legion::Logging.info 'Closing all Legion::Crypt vault sessions'
61
+
59
62
  @sessions.each do |session|
60
63
  close_session(session: session)
61
64
  end
@@ -65,7 +68,7 @@ module Legion
65
68
  return unless Legion::Settings[:crypt][:vault][:connected]
66
69
  return if @renewer.nil?
67
70
 
68
- Legion::Logging.debug 'Shutdown down Legion::Crypt::Vault::Renewer'
71
+ Legion::Logging.debug 'Shutting down Legion::Crypt::Vault::Renewer'
69
72
  @renewer.cancel
70
73
  end
71
74
 
@@ -82,6 +85,10 @@ module Legion
82
85
  renew_session(session: session)
83
86
  end
84
87
  end
88
+
89
+ def vault_exists?(name)
90
+ ::Vault.sys.mounts.key?(name.to_sym)
91
+ end
85
92
  end
86
93
  end
87
94
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module Crypt
5
- VERSION = '0.2.0'
5
+ VERSION = '1.2.0'
6
6
  end
7
7
  end
@@ -0,0 +1,11 @@
1
+ sonar.projectKey=legion-io_legion-crypt
2
+ sonar.organization=legion-io
3
+ sonar.sources=.
4
+ sonar.exclusions=vendor/**
5
+ sonar.coverage.exclusions=spec/**
6
+ sonar.ruby.coverage.reportPath=coverage/.resultset.json
7
+ sonar.ruby.file.suffixes=rb,ruby
8
+ sonar.ruby.coverage.framework=RSpec
9
+ sonar.ruby.rubocopConfig=.rubocop.yml
10
+ sonar.ruby.rubocop.reportPath=rubocop-result.json
11
+ sonar.ruby.rubocop.filePath=.
data/sourcehawk.yml ADDED
@@ -0,0 +1,4 @@
1
+
2
+ config-locations:
3
+ - https://raw.githubusercontent.com/optum/.github/main/sourcehawk.yml
4
+
metadata CHANGED
@@ -1,43 +1,29 @@
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: 1.2.0
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: 2021-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rbnacl
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: vault
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: '0'
19
+ version: 0.15.0
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: '0'
26
+ version: 0.15.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: legion-logging
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,100 +52,51 @@ dependencies:
66
52
  - - ">="
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: legion-transport
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- description: Integrates with Hashicorps vault and other encryption type things
55
+ description: A gem used by the LegionIO framework for encryption
126
56
  email:
127
57
  - matthewdiverson@gmail.com
58
+ - ruby@optum.com
128
59
  executables: []
129
60
  extensions: []
130
- extra_rdoc_files: []
61
+ extra_rdoc_files:
62
+ - README.md
63
+ - LICENSE
64
+ - CHANGELOG.md
131
65
  files:
132
- - ".circleci/config.yml"
66
+ - ".github/workflows/rubocop-analysis.yml"
67
+ - ".github/workflows/sourcehawk-scan.yml"
133
68
  - ".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
- - ".rspec"
141
69
  - ".rubocop.yml"
70
+ - CHANGELOG.md
71
+ - CODE_OF_CONDUCT.md
72
+ - CONTRIBUTING.md
142
73
  - Gemfile
143
- - LICENSE.txt
74
+ - INDIVIDUAL_CONTRIBUTOR_LICENSE.md
75
+ - LICENSE
76
+ - NOTICE.txt
144
77
  - README.md
145
- - Rakefile
146
- - bin/console
147
- - bin/setup
78
+ - SECURITY.md
79
+ - attribution.txt
148
80
  - legion-crypt.gemspec
149
81
  - lib/legion/crypt.rb
150
- - lib/legion/crypt/box.rb
151
82
  - lib/legion/crypt/cipher.rb
83
+ - lib/legion/crypt/cluster_secret.rb
152
84
  - lib/legion/crypt/settings.rb
153
85
  - lib/legion/crypt/vault.rb
154
86
  - lib/legion/crypt/vault_renewer.rb
155
87
  - lib/legion/crypt/version.rb
156
- homepage: https://bitbucket.org/legion-io/legion-vault/
88
+ - sonar-project.properties
89
+ - sourcehawk.yml
90
+ homepage: https://github.com/Optum/legion-crypt
157
91
  licenses:
158
- - MIT
92
+ - Apache-2.0
159
93
  metadata:
160
- homepage_uri: https://bitbucket.org/legion-io/legion-vault/
161
- source_code_uri: https://bitbucket.org/legion-io/legion/
162
- changelog_uri: https://bitbucket.org/legion-io/legion/src/master/CHANGELOG.md
94
+ bug_tracker_uri: https://github.com/Optum/legion-crypt/issues
95
+ changelog_uri: https://github.com/Optum/legion-crypt/src/main/CHANGELOG.md
96
+ documentation_uri: https://github.com/Optum/legion-crypt
97
+ homepage_uri: https://github.com/Optum/LegionIO
98
+ source_code_uri: https://github.com/Optum/legion-crypt
99
+ wiki_uri: https://github.com/Optum/legion-crypt/wiki
163
100
  post_install_message:
164
101
  rdoc_options: []
165
102
  require_paths:
@@ -168,15 +105,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
105
  requirements:
169
106
  - - ">="
170
107
  - !ruby/object:Gem::Version
171
- version: 2.5.0
108
+ version: '2.4'
172
109
  required_rubygems_version: !ruby/object:Gem::Requirement
173
110
  requirements:
174
111
  - - ">="
175
112
  - !ruby/object:Gem::Version
176
113
  version: '0'
177
114
  requirements: []
178
- rubygems_version: 3.1.2
115
+ rubygems_version: 3.1.6
179
116
  signing_key:
180
117
  specification_version: 4
181
- summary: Legion::Vault is used to keep things safe
118
+ summary: Handles requests for encrypt, decrypting, connecting to Vault, among other
119
+ things
182
120
  test_files: []
data/.circleci/config.yml DELETED
@@ -1,61 +0,0 @@
1
- version: 2.1
2
- orbs:
3
- ruby: circleci/ruby@0.2.1
4
-
5
- jobs:
6
- "rubocop":
7
- docker:
8
- - image: circleci/ruby:2.5-node
9
- steps:
10
- - checkout
11
- - ruby/load-cache
12
- - ruby/install-deps
13
- - run:
14
- name: Run Rubocop
15
- command: bundle exec rubocop
16
- - ruby/save-cache
17
- "ruby-two-five":
18
- docker:
19
- - image: circleci/ruby:2.5
20
- - image: memcached:1.5-alpine
21
- steps:
22
- - checkout
23
- - ruby/load-cache
24
- - ruby/install-deps
25
- - ruby/run-tests
26
- - ruby/save-cache
27
- "ruby-two-six":
28
- docker:
29
- - image: circleci/ruby:2.6
30
- - image: memcached:1.5-alpine
31
- steps:
32
- - checkout
33
- - ruby/load-cache
34
- - ruby/install-deps
35
- - ruby/run-tests
36
- - ruby/save-cache
37
- "ruby-two-seven":
38
- docker:
39
- - image: circleci/ruby:2.7
40
- - image: memcached:1.5-alpine
41
- steps:
42
- - checkout
43
- - ruby/load-cache
44
- - ruby/install-deps
45
- - ruby/run-tests
46
- - ruby/save-cache
47
-
48
- workflows:
49
- version: 2
50
- rubocop-rspec:
51
- jobs:
52
- - rubocop
53
- - ruby-two-five:
54
- requires:
55
- - rubocop
56
- - ruby-two-six:
57
- requires:
58
- - ruby-two-five
59
- - ruby-two-seven:
60
- requires:
61
- - ruby-two-five
data/.idea/.rakeTasks DELETED
@@ -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>
data/.idea/misc.xml DELETED
@@ -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>
data/.idea/modules.xml DELETED
@@ -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>
data/.idea/vagrant.xml DELETED
@@ -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>
data/.idea/workspace.xml DELETED
@@ -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>