familia 2.0.0.pre4 → 2.0.0.pre5
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/.gitignore +3 -0
- data/.rubocop_todo.yml +17 -17
- data/CLAUDE.md +3 -3
- data/Gemfile +5 -1
- data/Gemfile.lock +18 -3
- data/README.md +36 -157
- data/TEST_COVERAGE.md +40 -0
- data/docs/overview.md +359 -0
- data/docs/wiki/API-Reference.md +270 -0
- data/docs/wiki/Encrypted-Fields-Overview.md +64 -0
- data/docs/wiki/Home.md +49 -0
- data/docs/wiki/Implementation-Guide.md +183 -0
- data/docs/wiki/Security-Model.md +143 -0
- data/lib/familia/base.rb +18 -27
- data/lib/familia/connection.rb +6 -5
- data/lib/familia/{datatype → data_type}/commands.rb +2 -5
- data/lib/familia/{datatype → data_type}/serialization.rb +8 -10
- data/lib/familia/{datatype → data_type}/types/hashkey.rb +2 -2
- data/lib/familia/{datatype → data_type}/types/list.rb +17 -18
- data/lib/familia/{datatype → data_type}/types/sorted_set.rb +17 -17
- data/lib/familia/{datatype → data_type}/types/string.rb +2 -1
- data/lib/familia/{datatype → data_type}/types/unsorted_set.rb +17 -18
- data/lib/familia/{datatype.rb → data_type.rb} +10 -12
- data/lib/familia/encryption/manager.rb +102 -0
- data/lib/familia/encryption/provider.rb +49 -0
- data/lib/familia/encryption/providers/aes_gcm_provider.rb +103 -0
- data/lib/familia/encryption/providers/secure_xchacha20_poly1305_provider.rb +184 -0
- data/lib/familia/encryption/providers/xchacha20_poly1305_provider.rb +118 -0
- data/lib/familia/encryption/registry.rb +50 -0
- data/lib/familia/encryption.rb +178 -0
- data/lib/familia/encryption_request_cache.rb +68 -0
- data/lib/familia/features/encrypted_fields/encrypted_field_type.rb +153 -0
- data/lib/familia/features/encrypted_fields.rb +28 -0
- data/lib/familia/features/expiration.rb +107 -77
- data/lib/familia/features/quantization.rb +5 -9
- data/lib/familia/features/relatable_objects.rb +2 -4
- data/lib/familia/features/safe_dump.rb +14 -17
- data/lib/familia/features/transient_fields/redacted_string.rb +159 -0
- data/lib/familia/features/transient_fields/single_use_redacted_string.rb +62 -0
- data/lib/familia/features/transient_fields/transient_field_type.rb +139 -0
- data/lib/familia/features/transient_fields.rb +47 -0
- data/lib/familia/features.rb +40 -24
- data/lib/familia/field_type.rb +270 -0
- data/lib/familia/horreum/connection.rb +8 -11
- data/lib/familia/horreum/{commands.rb → database_commands.rb} +7 -19
- data/lib/familia/horreum/definition_methods.rb +453 -0
- data/lib/familia/horreum/{class_methods.rb → management_methods.rb} +19 -243
- data/lib/familia/horreum/serialization.rb +46 -18
- data/lib/familia/horreum/settings.rb +10 -2
- data/lib/familia/horreum/utils.rb +9 -10
- data/lib/familia/horreum.rb +18 -10
- data/lib/familia/logging.rb +14 -14
- data/lib/familia/settings.rb +39 -3
- data/lib/familia/utils.rb +45 -0
- data/lib/familia/version.rb +1 -1
- data/lib/familia.rb +2 -1
- data/try/core/base_enhancements_try.rb +115 -0
- data/try/core/connection_try.rb +0 -1
- data/try/core/errors_try.rb +0 -1
- data/try/core/familia_extended_try.rb +3 -4
- data/try/core/familia_try.rb +0 -1
- data/try/core/pools_try.rb +2 -2
- data/try/core/secure_identifier_try.rb +0 -1
- data/try/core/settings_try.rb +0 -1
- data/try/core/utils_try.rb +0 -1
- data/try/{datatypes → data_types}/boolean_try.rb +1 -2
- data/try/{datatypes → data_types}/datatype_base_try.rb +2 -3
- data/try/{datatypes → data_types}/hash_try.rb +1 -2
- data/try/{datatypes → data_types}/list_try.rb +1 -2
- data/try/{datatypes → data_types}/set_try.rb +1 -2
- data/try/{datatypes → data_types}/sorted_set_try.rb +1 -2
- data/try/{datatypes → data_types}/string_try.rb +1 -2
- data/try/debugging/README.md +32 -0
- data/try/debugging/cache_behavior_tracer.rb +91 -0
- data/try/debugging/encryption_method_tracer.rb +138 -0
- data/try/debugging/provider_diagnostics.rb +110 -0
- data/try/edge_cases/hash_symbolization_try.rb +0 -1
- data/try/edge_cases/json_serialization_try.rb +0 -1
- data/try/edge_cases/reserved_keywords_try.rb +42 -11
- data/try/encryption/config_persistence_try.rb +192 -0
- data/try/encryption/encryption_core_try.rb +328 -0
- data/try/encryption/instance_variable_scope_try.rb +31 -0
- data/try/encryption/module_loading_try.rb +28 -0
- data/try/encryption/providers/aes_gcm_provider_try.rb +178 -0
- data/try/encryption/providers/xchacha20_poly1305_provider_try.rb +169 -0
- data/try/encryption/roundtrip_validation_try.rb +28 -0
- data/try/encryption/secure_memory_handling_try.rb +125 -0
- data/try/features/encrypted_fields_core_try.rb +117 -0
- data/try/features/encrypted_fields_integration_try.rb +220 -0
- data/try/features/encrypted_fields_no_cache_security_try.rb +205 -0
- data/try/features/encrypted_fields_security_try.rb +370 -0
- data/try/features/encryption_fields/aad_protection_try.rb +53 -0
- data/try/features/encryption_fields/context_isolation_try.rb +120 -0
- data/try/features/encryption_fields/error_conditions_try.rb +116 -0
- data/try/features/encryption_fields/fresh_key_derivation_try.rb +122 -0
- data/try/features/encryption_fields/fresh_key_try.rb +163 -0
- data/try/features/encryption_fields/key_rotation_try.rb +117 -0
- data/try/features/encryption_fields/memory_security_try.rb +37 -0
- data/try/features/encryption_fields/missing_current_key_version_try.rb +23 -0
- data/try/features/encryption_fields/nonce_uniqueness_try.rb +54 -0
- data/try/features/encryption_fields/thread_safety_try.rb +199 -0
- data/try/features/expiration_try.rb +0 -1
- data/try/features/feature_dependencies_try.rb +159 -0
- data/try/features/quantization_try.rb +0 -1
- data/try/features/real_feature_integration_try.rb +148 -0
- data/try/features/relatable_objects_try.rb +0 -1
- data/try/features/safe_dump_advanced_try.rb +0 -1
- data/try/features/safe_dump_try.rb +0 -1
- data/try/features/transient_fields/redacted_string_try.rb +248 -0
- data/try/features/transient_fields/refresh_reset_try.rb +164 -0
- data/try/features/transient_fields/simple_refresh_test.rb +50 -0
- data/try/features/transient_fields/single_use_redacted_string_try.rb +310 -0
- data/try/features/transient_fields_core_try.rb +181 -0
- data/try/features/transient_fields_integration_try.rb +260 -0
- data/try/helpers/test_helpers.rb +42 -0
- data/try/horreum/base_try.rb +157 -3
- data/try/horreum/enhanced_conflict_handling_try.rb +176 -0
- data/try/horreum/field_categories_try.rb +118 -0
- data/try/horreum/field_definition_try.rb +96 -0
- data/try/horreum/initialization_try.rb +0 -1
- data/try/horreum/relations_try.rb +0 -1
- data/try/horreum/serialization_persistent_fields_try.rb +165 -0
- data/try/horreum/serialization_try.rb +2 -3
- data/try/memory/memory_basic_test.rb +73 -0
- data/try/memory/memory_detailed_test.rb +121 -0
- data/try/memory/memory_docker_ruby_dump.sh +80 -0
- data/try/memory/memory_search_for_string.rb +83 -0
- data/try/memory/test_actual_redactedstring_protection.rb +38 -0
- data/try/models/customer_safe_dump_try.rb +0 -1
- data/try/models/customer_try.rb +0 -1
- data/try/models/datatype_base_try.rb +1 -2
- data/try/models/familia_object_try.rb +0 -1
- metadata +85 -18
@@ -0,0 +1,83 @@
|
|
1
|
+
# try/edge_cases/search_memory_for_string_try.rb
|
2
|
+
|
3
|
+
require 'objspace'
|
4
|
+
|
5
|
+
require_relative '../helpers/test_helpers'
|
6
|
+
|
7
|
+
# Enable object space tracking
|
8
|
+
ObjectSpace.trace_object_allocations_start
|
9
|
+
|
10
|
+
def search_memory_for_string(target)
|
11
|
+
found_locations = []
|
12
|
+
|
13
|
+
ObjectSpace.each_object(String) do |str|
|
14
|
+
begin
|
15
|
+
if str.include?(target)
|
16
|
+
found_locations << {
|
17
|
+
value: str[0..100], # First 100 chars
|
18
|
+
object_id: str.object_id,
|
19
|
+
source: ObjectSpace.allocation_sourcefile(str),
|
20
|
+
line: ObjectSpace.allocation_sourceline(str),
|
21
|
+
frozen: str.frozen?
|
22
|
+
}
|
23
|
+
end
|
24
|
+
rescue => e
|
25
|
+
# Some strings might not be accessible
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
found_locations
|
30
|
+
end
|
31
|
+
|
32
|
+
# Test scenario
|
33
|
+
secret = "SUPER_SECRET_API_KEY_12345"
|
34
|
+
puts "Testing with secret: #{secret}"
|
35
|
+
|
36
|
+
# Create RedactedString
|
37
|
+
redacted = RedactedString.new(secret)
|
38
|
+
puts "Created RedactedString"
|
39
|
+
|
40
|
+
# Force GC to see if copies persist
|
41
|
+
GC.start(full_mark: true, immediate_sweep: true)
|
42
|
+
|
43
|
+
# Search memory
|
44
|
+
puts "\n=== Memory search BEFORE expose ==="
|
45
|
+
found = search_memory_for_string("SUPER_SECRET_API_KEY")
|
46
|
+
found.each do |location|
|
47
|
+
puts "Found at object_id: #{location[:object_id]}"
|
48
|
+
puts " Value: #{location[:value]}"
|
49
|
+
puts " Source: #{location[:source]}:#{location[:line]}"
|
50
|
+
puts " Frozen: #{location[:frozen]}"
|
51
|
+
end
|
52
|
+
|
53
|
+
# Use expose
|
54
|
+
redacted.expose do |plain|
|
55
|
+
puts "\nInside expose block, plain = [REDACTED for display]"
|
56
|
+
|
57
|
+
# Search during expose
|
58
|
+
puts "\n=== Memory search DURING expose ==="
|
59
|
+
found = search_memory_for_string("SUPER_SECRET_API_KEY")
|
60
|
+
puts "Found #{found.size} instances"
|
61
|
+
end
|
62
|
+
|
63
|
+
# After expose
|
64
|
+
GC.start(full_mark: true, immediate_sweep: true)
|
65
|
+
puts "\n=== Memory search AFTER expose ==="
|
66
|
+
found = search_memory_for_string("SUPER_SECRET_API_KEY")
|
67
|
+
found.each do |location|
|
68
|
+
puts "Found at object_id: #{location[:object_id]}"
|
69
|
+
puts " Value: #{location[:value]}"
|
70
|
+
end
|
71
|
+
|
72
|
+
# Also check with marshal dump
|
73
|
+
puts "\n=== Checking Marshal dump ==="
|
74
|
+
begin
|
75
|
+
marshaled = Marshal.dump(ObjectSpace.each_object.to_a)
|
76
|
+
if marshaled.include?("SUPER_SECRET_API_KEY")
|
77
|
+
puts "❌ Secret found in Marshal dump!"
|
78
|
+
else
|
79
|
+
puts "✅ Secret not found in Marshal dump"
|
80
|
+
end
|
81
|
+
rescue => e
|
82
|
+
puts "Marshal failed: #{e}"
|
83
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# try/memory/test_actual_redactedstring_protection.rb
|
2
|
+
|
3
|
+
require_relative '../helpers/test_helpers'
|
4
|
+
|
5
|
+
# Test 1: Does it prevent logging leaks?
|
6
|
+
secret = "API_KEY_12345"
|
7
|
+
redacted = RedactedString.new(secret)
|
8
|
+
|
9
|
+
puts "Logging test:"
|
10
|
+
puts "Normal string logs as: #{secret}" # Shows: API_KEY_12345
|
11
|
+
puts "Redacted string logs as: #{redacted}" # Shows: [REDACTED]
|
12
|
+
puts "✅ Logging protection works!\n\n"
|
13
|
+
|
14
|
+
# Test 2: Does it prevent exception leaks?
|
15
|
+
begin
|
16
|
+
raise StandardError, "Error with secret: #{redacted}"
|
17
|
+
rescue => e
|
18
|
+
puts "Exception message: #{e.message}"
|
19
|
+
puts "✅ Exception protection works!\n\n" if e.message.include?("[REDACTED]")
|
20
|
+
end
|
21
|
+
|
22
|
+
# Test 3: Does it prevent debug leaks?
|
23
|
+
require 'pp'
|
24
|
+
data = {
|
25
|
+
user: "john",
|
26
|
+
token: redacted
|
27
|
+
}
|
28
|
+
puts "Debug output:"
|
29
|
+
pp data # Will show token: [REDACTED]
|
30
|
+
puts "✅ Debug protection works!\n\n"
|
31
|
+
|
32
|
+
# Test 4: Real-world usage pattern
|
33
|
+
redacted.expose do |token|
|
34
|
+
# Simulate API call
|
35
|
+
puts "Making API call with token (simulated)"
|
36
|
+
# HTTParty.get("https://api.example.com", headers: { "Authorization" => token })
|
37
|
+
end
|
38
|
+
puts "After API call, trying to access: #{redacted}" # Still shows [REDACTED]
|
data/try/models/customer_try.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: familia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.pre5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Delano Mandelbaum
|
@@ -132,31 +132,54 @@ files:
|
|
132
132
|
- Gemfile.lock
|
133
133
|
- LICENSE.txt
|
134
134
|
- README.md
|
135
|
+
- TEST_COVERAGE.md
|
135
136
|
- bin/irb
|
136
137
|
- docs/connection_pooling.md
|
138
|
+
- docs/overview.md
|
139
|
+
- docs/wiki/API-Reference.md
|
140
|
+
- docs/wiki/Encrypted-Fields-Overview.md
|
141
|
+
- docs/wiki/Home.md
|
142
|
+
- docs/wiki/Implementation-Guide.md
|
143
|
+
- docs/wiki/Security-Model.md
|
137
144
|
- familia.gemspec
|
138
145
|
- lib/familia.rb
|
139
146
|
- lib/familia/base.rb
|
140
147
|
- lib/familia/connection.rb
|
141
148
|
- lib/familia/core_ext.rb
|
142
|
-
- lib/familia/
|
143
|
-
- lib/familia/
|
144
|
-
- lib/familia/
|
145
|
-
- lib/familia/
|
146
|
-
- lib/familia/
|
147
|
-
- lib/familia/
|
148
|
-
- lib/familia/
|
149
|
-
- lib/familia/
|
149
|
+
- lib/familia/data_type.rb
|
150
|
+
- lib/familia/data_type/commands.rb
|
151
|
+
- lib/familia/data_type/serialization.rb
|
152
|
+
- lib/familia/data_type/types/hashkey.rb
|
153
|
+
- lib/familia/data_type/types/list.rb
|
154
|
+
- lib/familia/data_type/types/sorted_set.rb
|
155
|
+
- lib/familia/data_type/types/string.rb
|
156
|
+
- lib/familia/data_type/types/unsorted_set.rb
|
157
|
+
- lib/familia/encryption.rb
|
158
|
+
- lib/familia/encryption/manager.rb
|
159
|
+
- lib/familia/encryption/provider.rb
|
160
|
+
- lib/familia/encryption/providers/aes_gcm_provider.rb
|
161
|
+
- lib/familia/encryption/providers/secure_xchacha20_poly1305_provider.rb
|
162
|
+
- lib/familia/encryption/providers/xchacha20_poly1305_provider.rb
|
163
|
+
- lib/familia/encryption/registry.rb
|
164
|
+
- lib/familia/encryption_request_cache.rb
|
150
165
|
- lib/familia/errors.rb
|
151
166
|
- lib/familia/features.rb
|
167
|
+
- lib/familia/features/encrypted_fields.rb
|
168
|
+
- lib/familia/features/encrypted_fields/encrypted_field_type.rb
|
152
169
|
- lib/familia/features/expiration.rb
|
153
170
|
- lib/familia/features/quantization.rb
|
154
171
|
- lib/familia/features/relatable_objects.rb
|
155
172
|
- lib/familia/features/safe_dump.rb
|
173
|
+
- lib/familia/features/transient_fields.rb
|
174
|
+
- lib/familia/features/transient_fields/redacted_string.rb
|
175
|
+
- lib/familia/features/transient_fields/single_use_redacted_string.rb
|
176
|
+
- lib/familia/features/transient_fields/transient_field_type.rb
|
177
|
+
- lib/familia/field_type.rb
|
156
178
|
- lib/familia/horreum.rb
|
157
|
-
- lib/familia/horreum/class_methods.rb
|
158
|
-
- lib/familia/horreum/commands.rb
|
159
179
|
- lib/familia/horreum/connection.rb
|
180
|
+
- lib/familia/horreum/database_commands.rb
|
181
|
+
- lib/familia/horreum/definition_methods.rb
|
182
|
+
- lib/familia/horreum/management_methods.rb
|
160
183
|
- lib/familia/horreum/related_fields_management.rb
|
161
184
|
- lib/familia/horreum/serialization.rb
|
162
185
|
- lib/familia/horreum/settings.rb
|
@@ -170,6 +193,7 @@ files:
|
|
170
193
|
- lib/familia/version.rb
|
171
194
|
- lib/middleware/database_middleware.rb
|
172
195
|
- try/configuration/scenarios_try.rb
|
196
|
+
- try/core/base_enhancements_try.rb
|
173
197
|
- try/core/connection_try.rb
|
174
198
|
- try/core/errors_try.rb
|
175
199
|
- try/core/extensions_try.rb
|
@@ -181,13 +205,17 @@ files:
|
|
181
205
|
- try/core/settings_try.rb
|
182
206
|
- try/core/tools_try.rb
|
183
207
|
- try/core/utils_try.rb
|
184
|
-
- try/
|
185
|
-
- try/
|
186
|
-
- try/
|
187
|
-
- try/
|
188
|
-
- try/
|
189
|
-
- try/
|
190
|
-
- try/
|
208
|
+
- try/data_types/boolean_try.rb
|
209
|
+
- try/data_types/datatype_base_try.rb
|
210
|
+
- try/data_types/hash_try.rb
|
211
|
+
- try/data_types/list_try.rb
|
212
|
+
- try/data_types/set_try.rb
|
213
|
+
- try/data_types/sorted_set_try.rb
|
214
|
+
- try/data_types/string_try.rb
|
215
|
+
- try/debugging/README.md
|
216
|
+
- try/debugging/cache_behavior_tracer.rb
|
217
|
+
- try/debugging/encryption_method_tracer.rb
|
218
|
+
- try/debugging/provider_diagnostics.rb
|
191
219
|
- try/edge_cases/empty_identifiers_try.rb
|
192
220
|
- try/edge_cases/hash_symbolization_try.rb
|
193
221
|
- try/edge_cases/json_serialization_try.rb
|
@@ -195,20 +223,59 @@ files:
|
|
195
223
|
- try/edge_cases/reserved_keywords_try.rb
|
196
224
|
- try/edge_cases/string_coercion_try.rb
|
197
225
|
- try/edge_cases/ttl_side_effects_try.rb
|
226
|
+
- try/encryption/config_persistence_try.rb
|
227
|
+
- try/encryption/encryption_core_try.rb
|
228
|
+
- try/encryption/instance_variable_scope_try.rb
|
229
|
+
- try/encryption/module_loading_try.rb
|
230
|
+
- try/encryption/providers/aes_gcm_provider_try.rb
|
231
|
+
- try/encryption/providers/xchacha20_poly1305_provider_try.rb
|
232
|
+
- try/encryption/roundtrip_validation_try.rb
|
233
|
+
- try/encryption/secure_memory_handling_try.rb
|
234
|
+
- try/features/encrypted_fields_core_try.rb
|
235
|
+
- try/features/encrypted_fields_integration_try.rb
|
236
|
+
- try/features/encrypted_fields_no_cache_security_try.rb
|
237
|
+
- try/features/encrypted_fields_security_try.rb
|
238
|
+
- try/features/encryption_fields/aad_protection_try.rb
|
239
|
+
- try/features/encryption_fields/context_isolation_try.rb
|
240
|
+
- try/features/encryption_fields/error_conditions_try.rb
|
241
|
+
- try/features/encryption_fields/fresh_key_derivation_try.rb
|
242
|
+
- try/features/encryption_fields/fresh_key_try.rb
|
243
|
+
- try/features/encryption_fields/key_rotation_try.rb
|
244
|
+
- try/features/encryption_fields/memory_security_try.rb
|
245
|
+
- try/features/encryption_fields/missing_current_key_version_try.rb
|
246
|
+
- try/features/encryption_fields/nonce_uniqueness_try.rb
|
247
|
+
- try/features/encryption_fields/thread_safety_try.rb
|
198
248
|
- try/features/expiration_try.rb
|
249
|
+
- try/features/feature_dependencies_try.rb
|
199
250
|
- try/features/quantization_try.rb
|
251
|
+
- try/features/real_feature_integration_try.rb
|
200
252
|
- try/features/relatable_objects_try.rb
|
201
253
|
- try/features/safe_dump_advanced_try.rb
|
202
254
|
- try/features/safe_dump_try.rb
|
255
|
+
- try/features/transient_fields/redacted_string_try.rb
|
256
|
+
- try/features/transient_fields/refresh_reset_try.rb
|
257
|
+
- try/features/transient_fields/simple_refresh_test.rb
|
258
|
+
- try/features/transient_fields/single_use_redacted_string_try.rb
|
259
|
+
- try/features/transient_fields_core_try.rb
|
260
|
+
- try/features/transient_fields_integration_try.rb
|
203
261
|
- try/helpers/test_helpers.rb
|
204
262
|
- try/horreum/base_try.rb
|
205
263
|
- try/horreum/class_methods_try.rb
|
206
264
|
- try/horreum/commands_try.rb
|
265
|
+
- try/horreum/enhanced_conflict_handling_try.rb
|
266
|
+
- try/horreum/field_categories_try.rb
|
267
|
+
- try/horreum/field_definition_try.rb
|
207
268
|
- try/horreum/initialization_try.rb
|
208
269
|
- try/horreum/relations_try.rb
|
270
|
+
- try/horreum/serialization_persistent_fields_try.rb
|
209
271
|
- try/horreum/serialization_try.rb
|
210
272
|
- try/horreum/settings_try.rb
|
211
273
|
- try/integration/cross_component_try.rb
|
274
|
+
- try/memory/memory_basic_test.rb
|
275
|
+
- try/memory/memory_detailed_test.rb
|
276
|
+
- try/memory/memory_docker_ruby_dump.sh
|
277
|
+
- try/memory/memory_search_for_string.rb
|
278
|
+
- try/memory/test_actual_redactedstring_protection.rb
|
212
279
|
- try/models/customer_safe_dump_try.rb
|
213
280
|
- try/models/customer_try.rb
|
214
281
|
- try/models/datatype_base_try.rb
|