legion-crypt 1.4.20 → 1.4.22
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/CHANGELOG.md +14 -0
- data/README.md +1 -1
- data/lib/legion/crypt/cluster_secret.rb +21 -4
- data/lib/legion/crypt/settings.rb +4 -3
- data/lib/legion/crypt/vault.rb +7 -1
- data/lib/legion/crypt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ec95cba72f1350ed61da82d296c14ddf6729cce61785ac908fbcf98256935e48
|
|
4
|
+
data.tar.gz: 15770beb8714e14a4ff14c42473a9f55ef0de549683e299b6b4d044da513249e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aea19ef52f31d1d7b5e8ddd8392749fd40e7305eef410958ae9012128dd8c79698df37baf557ef25c0b34ebf8ba6821ef42900346a28d73dee5241c44024039a
|
|
7
|
+
data.tar.gz: ba9ab25d478aaeed112a41362ca4b587ea0acacf1745f5518f4867a936372567dc9f7bb906b7855a5596973d020da1629f7349608d81e7ec907e1965a4777686
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Legion::Crypt
|
|
2
2
|
|
|
3
|
+
## [1.4.22] - 2026-03-27
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- Replace split `log.error(e.message); log.error(e.backtrace)` patterns with single `Legion::Logging.log_exception` calls in `vault.rb`, `cluster_secret.rb`, and `settings.rb` for structured exception events
|
|
7
|
+
- Guard all `log_exception` call sites in `vault.rb`, `settings.rb`, and `cluster_secret.rb` with `Legion::Logging` presence checks (`defined?` in `vault.rb`/`cluster_secret.rb`, `Legion.const_defined?('Logging')` in `settings.rb`) plus `Legion::Logging.respond_to?(:log_exception)`; fall back to `Legion::Logging.fatal`/`error` or `warn` to preserve structured logging in environments where `log_exception` is unavailable
|
|
8
|
+
- `from_transport` and `cs` rescue blocks in `cluster_secret.rb` now use the same 4-branch guard (log_exception / Logging.error / Logging.warn / Kernel.warn) and explicitly return `nil` to preserve expected return types
|
|
9
|
+
- Fallback `.error`/`.warn`/`Kernel.warn` branches in `from_transport` and `cs` include the first 10 backtrace lines for debuggability parity with the prior `e.backtrace[0..10]` logging; `Vault#connect_vault` warn fallback omits backtrace to keep health-check failure messages concise
|
|
10
|
+
- `cs` rescue adds final `Kernel.warn` fallback so exceptions are never silently swallowed when `Legion::Logging` is absent
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Specs for `connect_vault` rescue logging: asserts `false` return and covers log_exception / Logging.error / warn fallback branches when `Vault.sys.health_status` raises
|
|
14
|
+
- Specs for `from_transport` and `cs` rescue paths: asserts `nil` return and covers all logging fallback branches (including `Kernel.warn`) plus `Legion::Logging` absent case
|
|
15
|
+
- Duplicate invocation eliminated in rescue-path specs: single call stored in `result`, both no-raise and return value asserted on that one call
|
|
16
|
+
|
|
3
17
|
## [1.4.20] - 2026-03-27
|
|
4
18
|
|
|
5
19
|
### Fixed
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Encryption, secrets management, JWT token management, and HashiCorp Vault integration for the [LegionIO](https://github.com/LegionIO/LegionIO) framework. Provides AES-256-CBC message encryption, RSA key pair generation, cluster secret management, JWT issue/verify operations, Vault token lifecycle management, and multi-cluster Vault connectivity.
|
|
4
4
|
|
|
5
|
-
**Version**: 1.4.
|
|
5
|
+
**Version**: 1.4.22
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -64,8 +64,14 @@ module Legion
|
|
|
64
64
|
Legion::Logging.error 'Cluster secret is still unknown!'
|
|
65
65
|
nil
|
|
66
66
|
rescue StandardError => e
|
|
67
|
-
Legion::Logging
|
|
68
|
-
|
|
67
|
+
if defined?(Legion::Logging) && Legion::Logging.respond_to?(:log_exception)
|
|
68
|
+
Legion::Logging.log_exception(e, lex: 'crypt', component_type: :helper)
|
|
69
|
+
elsif defined?(Legion::Logging) && Legion::Logging.respond_to?(:error)
|
|
70
|
+
Legion::Logging.error "from_transport failed: #{e.class}=#{e.message}\n#{Array(e.backtrace).first(10).join("\n")}"
|
|
71
|
+
else
|
|
72
|
+
warn "from_transport failed: #{e.class}=#{e.message}\n#{Array(e.backtrace).first(10).join("\n")}"
|
|
73
|
+
end
|
|
74
|
+
nil
|
|
69
75
|
end
|
|
70
76
|
|
|
71
77
|
def force_cluster_secret
|
|
@@ -114,8 +120,19 @@ module Legion
|
|
|
114
120
|
def cs
|
|
115
121
|
@cs ||= Digest::SHA256.digest(find_cluster_secret)
|
|
116
122
|
rescue StandardError => e
|
|
117
|
-
Legion::Logging
|
|
118
|
-
|
|
123
|
+
if defined?(Legion::Logging) && Legion::Logging.respond_to?(:log_exception)
|
|
124
|
+
Legion::Logging.log_exception(e, lex: 'crypt', component_type: :helper)
|
|
125
|
+
elsif defined?(Legion::Logging) && Legion::Logging.respond_to?(:error)
|
|
126
|
+
backtrace = Array(e.backtrace).first(10).join("\n")
|
|
127
|
+
Legion::Logging.error "Legion::Crypt::ClusterSecret#cs failed: #{e.class}: #{e.message}\n#{backtrace}"
|
|
128
|
+
elsif defined?(Legion::Logging) && Legion::Logging.respond_to?(:warn)
|
|
129
|
+
backtrace = Array(e.backtrace).first(10).join("\n")
|
|
130
|
+
Legion::Logging.warn "Legion::Crypt::ClusterSecret#cs failed: #{e.class}: #{e.message}\n#{backtrace}"
|
|
131
|
+
else
|
|
132
|
+
backtrace = Array(e.backtrace).first(10).join("\n")
|
|
133
|
+
::Kernel.warn "Legion::Crypt::ClusterSecret#cs failed: #{e.class}: #{e.message}\n#{backtrace}"
|
|
134
|
+
end
|
|
135
|
+
nil
|
|
119
136
|
end
|
|
120
137
|
|
|
121
138
|
def validate_hex(value, length = secret_length)
|
|
@@ -67,9 +67,10 @@ end
|
|
|
67
67
|
begin
|
|
68
68
|
Legion::Settings.merge_settings('crypt', Legion::Crypt::Settings.default) if Legion.const_defined?('Settings')
|
|
69
69
|
rescue StandardError => e
|
|
70
|
-
if Legion.const_defined?('Logging') && Legion::Logging.
|
|
71
|
-
Legion::Logging.
|
|
72
|
-
|
|
70
|
+
if Legion.const_defined?('Logging') && Legion::Logging.respond_to?(:log_exception)
|
|
71
|
+
Legion::Logging.log_exception(e, lex: 'crypt', component_type: :helper, level: :fatal)
|
|
72
|
+
elsif Legion.const_defined?('Logging') && Legion::Logging.respond_to?(:fatal)
|
|
73
|
+
Legion::Logging.fatal("crypt settings merge error: #{e.class}: #{e.message}\n#{Array(e.backtrace).join("\n")}")
|
|
73
74
|
else
|
|
74
75
|
puts e.message
|
|
75
76
|
puts e.backtrace
|
data/lib/legion/crypt/vault.rb
CHANGED
|
@@ -37,7 +37,13 @@ module Legion
|
|
|
37
37
|
Legion::Logging.info "Vault connected at #{::Vault.address}" if defined?(Legion::Logging)
|
|
38
38
|
end
|
|
39
39
|
rescue StandardError => e
|
|
40
|
-
Legion::Logging
|
|
40
|
+
if defined?(Legion::Logging) && Legion::Logging.respond_to?(:log_exception)
|
|
41
|
+
Legion::Logging.log_exception(e, lex: 'crypt', component_type: :helper)
|
|
42
|
+
elsif defined?(Legion::Logging) && Legion::Logging.respond_to?(:error)
|
|
43
|
+
Legion::Logging.error "Vault connection failed: #{e.class}=#{e.message}\n#{Array(e.backtrace).first(10).join("\n")}"
|
|
44
|
+
else
|
|
45
|
+
warn "Vault connection failed: #{e.class}=#{e.message}"
|
|
46
|
+
end
|
|
41
47
|
Legion::Settings[:crypt][:vault][:connected] = false
|
|
42
48
|
false
|
|
43
49
|
end
|
data/lib/legion/crypt/version.rb
CHANGED