asherah 0.6.0 → 0.8.0
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/.env.secrets.example +9 -0
- data/.rubocop.yml +86 -11
- data/CHANGELOG.md +14 -0
- data/Gemfile +4 -4
- data/README.md +18 -0
- data/Rakefile +1 -1
- data/asherah.gemspec +1 -1
- data/ext/asherah/checksums.yml +5 -5
- data/lib/asherah/config.rb +6 -5
- data/lib/asherah/version.rb +1 -1
- data/lib/asherah.rb +10 -2
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6c099a6a66b5d0f86edfaf4c05b9a3fe53234dae2e592ca6951e9b55a15727ab
|
|
4
|
+
data.tar.gz: 2a5c95bcc046532ca280ad2f5ac9ac5043462dc5ec877f3042a359c6a0ac9167
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 990780fe56c076bb75f9827364e0ed9d47062e38528101dc22770000670111421d8c55f4d4748f31aec55b83cb896372b32398a1c0cbeff715237f0d3c9191f0
|
|
7
|
+
data.tar.gz: c254644b64bfd6d702113e1fa650daa066122969ebb7a33a2f868dbdb99b13d1c589a50545cc1195d57c36b6e39163417cdd54b5e8bf30fc7503f096b339501c
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Example secrets file for KMS integration tests
|
|
2
|
+
# Copy this file to .env.secrets and fill in actual values
|
|
3
|
+
#
|
|
4
|
+
# IMPORTANT: Never commit .env.secrets to version control
|
|
5
|
+
# The .env.secrets file is already in .gitignore
|
|
6
|
+
|
|
7
|
+
# AWS KMS Key ARN for integration tests (optional)
|
|
8
|
+
# Only needed if running spec/kms_spec.rb
|
|
9
|
+
# KMS_KEY_ARN=arn:aws:kms:us-west-2:123456789012:key/12345678-1234-1234-1234-123456789012
|
data/.rubocop.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
AllCops:
|
|
2
|
-
TargetRubyVersion: 2.
|
|
2
|
+
TargetRubyVersion: 2.7
|
|
3
3
|
NewCops: enable
|
|
4
4
|
SuggestExtensions: false
|
|
5
5
|
Exclude:
|
|
@@ -9,29 +9,104 @@ AllCops:
|
|
|
9
9
|
Layout/LineLength:
|
|
10
10
|
Max: 120
|
|
11
11
|
|
|
12
|
+
# Metrics cops with reasonable limits
|
|
12
13
|
Metrics/BlockLength:
|
|
13
|
-
|
|
14
|
+
Max: 25
|
|
15
|
+
Exclude:
|
|
16
|
+
- 'spec/**/*'
|
|
17
|
+
- '*.gemspec'
|
|
18
|
+
- 'Rakefile'
|
|
14
19
|
|
|
15
20
|
Metrics/MethodLength:
|
|
16
|
-
|
|
21
|
+
Max: 15
|
|
22
|
+
Exclude:
|
|
23
|
+
- 'spec/**/*'
|
|
24
|
+
- 'tasks/**/*'
|
|
25
|
+
|
|
26
|
+
Metrics/AbcSize:
|
|
27
|
+
Max: 20
|
|
28
|
+
Exclude:
|
|
29
|
+
- 'spec/**/*'
|
|
30
|
+
- 'tasks/**/*'
|
|
31
|
+
|
|
32
|
+
Metrics/CyclomaticComplexity:
|
|
33
|
+
Max: 10
|
|
34
|
+
Exclude:
|
|
35
|
+
- 'spec/**/*'
|
|
17
36
|
|
|
37
|
+
Metrics/PerceivedComplexity:
|
|
38
|
+
Max: 10
|
|
39
|
+
Exclude:
|
|
40
|
+
- 'spec/**/*'
|
|
41
|
+
|
|
42
|
+
Metrics/ClassLength:
|
|
43
|
+
Max: 150
|
|
44
|
+
Exclude:
|
|
45
|
+
- 'spec/**/*'
|
|
46
|
+
|
|
47
|
+
Metrics/ModuleLength:
|
|
48
|
+
Max: 150
|
|
49
|
+
Exclude:
|
|
50
|
+
- 'spec/**/*'
|
|
51
|
+
|
|
52
|
+
# Style cops that were disabled but should be enabled
|
|
18
53
|
Style/WordArray:
|
|
19
|
-
|
|
54
|
+
MinSize: 3
|
|
55
|
+
EnforcedStyle: brackets
|
|
20
56
|
|
|
21
57
|
Style/SymbolArray:
|
|
22
|
-
|
|
58
|
+
MinSize: 3
|
|
59
|
+
EnforcedStyle: brackets
|
|
23
60
|
|
|
24
61
|
Style/MultilineBlockChain:
|
|
25
|
-
Enabled:
|
|
62
|
+
Enabled: true
|
|
63
|
+
Exclude:
|
|
64
|
+
- 'spec/**/*'
|
|
26
65
|
|
|
27
66
|
Style/BlockDelimiters:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
67
|
+
EnforcedStyle: semantic
|
|
68
|
+
FunctionalMethods:
|
|
69
|
+
- let
|
|
70
|
+
- let!
|
|
71
|
+
- subject
|
|
72
|
+
- before
|
|
73
|
+
- after
|
|
74
|
+
Exclude:
|
|
75
|
+
- 'asherah.gemspec'
|
|
76
|
+
- 'ext/asherah/native_file.rb'
|
|
32
77
|
|
|
33
78
|
Style/GuardClause:
|
|
34
|
-
|
|
79
|
+
MinBodyLength: 3
|
|
80
|
+
Exclude:
|
|
81
|
+
- 'ext/asherah/native_file.rb'
|
|
35
82
|
|
|
83
|
+
# Naming cop adjustment
|
|
36
84
|
Naming/AccessorMethodName:
|
|
85
|
+
Exclude:
|
|
86
|
+
- 'lib/asherah.rb' # set_env is intentionally named
|
|
87
|
+
|
|
88
|
+
# Documentation cops
|
|
89
|
+
Style/Documentation:
|
|
90
|
+
Enabled: true
|
|
91
|
+
Exclude:
|
|
92
|
+
- 'spec/**/*'
|
|
93
|
+
- 'features/**/*'
|
|
94
|
+
|
|
95
|
+
Style/DocumentationMethod:
|
|
96
|
+
Enabled: false # YARD comments are optional
|
|
97
|
+
|
|
98
|
+
Style/EmptyClassDefinition:
|
|
37
99
|
Enabled: false
|
|
100
|
+
|
|
101
|
+
# Additional cops for code quality
|
|
102
|
+
Lint/UnusedMethodArgument:
|
|
103
|
+
Enabled: true
|
|
104
|
+
|
|
105
|
+
Lint/UnusedBlockArgument:
|
|
106
|
+
Enabled: true
|
|
107
|
+
|
|
108
|
+
Security/Eval:
|
|
109
|
+
Enabled: true
|
|
110
|
+
|
|
111
|
+
Security/JSONLoad:
|
|
112
|
+
Enabled: true
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.8.0] - 2026-03-04
|
|
4
|
+
|
|
5
|
+
- Upgrade to use asherah-cobhan v0.5.0
|
|
6
|
+
- Expose disable_zero_copy config option to disable zero-copy FFI input buffers
|
|
7
|
+
|
|
8
|
+
## [0.7.0] - 2025-08-15
|
|
9
|
+
|
|
10
|
+
- Fix memory leak risks in buffer management
|
|
11
|
+
- Fix inconsistent NotInitialized error handling across all methods
|
|
12
|
+
- Fix overly permissive RuboCop configuration
|
|
13
|
+
- Add Dependabot configuration for automated dependency updates
|
|
14
|
+
- Update dependencies and Github actions
|
|
15
|
+
- Update Go version to 1.24 for cross-language tests
|
|
16
|
+
|
|
3
17
|
## [0.6.0] - 2025-03-19
|
|
4
18
|
|
|
5
19
|
- Upgrade to use asherah-cobhan v0.4.35
|
data/Gemfile
CHANGED
|
@@ -5,10 +5,10 @@ source 'https://rubygems.org'
|
|
|
5
5
|
# Specify your gem's dependencies in asherah.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
-
gem 'cucumber', '~>
|
|
9
|
-
gem 'dotenv', '~> 2.
|
|
8
|
+
gem 'cucumber', '~> 9.2.1'
|
|
9
|
+
gem 'dotenv', '~> 2.8.1'
|
|
10
10
|
gem 'rake', '~> 13.0'
|
|
11
|
-
gem 'rspec', '~> 3.
|
|
11
|
+
gem 'rspec', '~> 3.13.1'
|
|
12
12
|
gem 'rubocop', '~> 1.7'
|
|
13
|
-
gem 'simplecov', '~> 0.
|
|
13
|
+
gem 'simplecov', '~> 0.22.0'
|
|
14
14
|
gem 'simplecov-console', '~> 0.9.1'
|
data/README.md
CHANGED
|
@@ -67,6 +67,24 @@ puts decrypted_data
|
|
|
67
67
|
|
|
68
68
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
69
69
|
|
|
70
|
+
For tests requiring secrets (AWS KMS, database credentials), copy `.env.secrets.example` to `.env.secrets` and fill in the required values. The `.env.secrets` file is already in `.gitignore` to prevent accidental commits.
|
|
71
|
+
|
|
72
|
+
### Cross-Language Tests
|
|
73
|
+
|
|
74
|
+
Cross-language tests verify that data encrypted with the Go implementation can be decrypted with the Ruby implementation and vice versa.
|
|
75
|
+
|
|
76
|
+
**Prerequisites:**
|
|
77
|
+
- MySQL running locally
|
|
78
|
+
- Go 1.24+ installed
|
|
79
|
+
|
|
80
|
+
**Running the tests:**
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
TEST_DB_PASSWORD=pass bin/cross-language-test.sh
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
See `bin/cross-language-test.sh` for available environment variables and their defaults.
|
|
87
|
+
|
|
70
88
|
To install this gem onto your local machine, run `rake install`.
|
|
71
89
|
|
|
72
90
|
To release a new version, update the version number in `version.rb`, create and push a version tag:
|
data/Rakefile
CHANGED
data/asherah.gemspec
CHANGED
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
|
16
16
|
|
|
17
17
|
spec.homepage = 'https://github.com/godaddy/asherah-ruby'
|
|
18
18
|
spec.license = 'MIT'
|
|
19
|
-
spec.required_ruby_version = '>= 2.
|
|
19
|
+
spec.required_ruby_version = '>= 2.7.0'
|
|
20
20
|
|
|
21
21
|
spec.metadata['homepage_uri'] = spec.homepage
|
|
22
22
|
spec.metadata['source_code_uri'] = 'https://github.com/godaddy/asherah-ruby'
|
data/ext/asherah/checksums.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
version: v0.
|
|
2
|
-
libasherah-arm64.so:
|
|
3
|
-
libasherah-x64.so:
|
|
4
|
-
libasherah-arm64.dylib:
|
|
5
|
-
libasherah-x64.dylib:
|
|
1
|
+
version: v0.5.0
|
|
2
|
+
libasherah-arm64.so: 8271298c357808d7e6daa4ca81ded8f39c1947a55043abe3b32359e0f5840a6c
|
|
3
|
+
libasherah-x64.so: 645c0da7d1330db511c6724f08154cfae3959610bd709d60eded1c1420d2fce8
|
|
4
|
+
libasherah-arm64.dylib: 909097bf62207e6927a0184e41859ccf42a62afd711cdadf69b8c5672939468b
|
|
5
|
+
libasherah-x64.dylib: e53ee66b7dd16ce587d5062e9eed8835f272653b6a91b4b5c5c1efd2ca97483e
|
data/lib/asherah/config.rb
CHANGED
|
@@ -21,6 +21,7 @@ module Asherah
|
|
|
21
21
|
# @attr [Integer] expire_after, The amount of time in seconds a key is considered valid
|
|
22
22
|
# @attr [Integer] check_interval, The amount of time in seconds before cached keys are considered stale
|
|
23
23
|
# @attr [Boolean] enable_session_caching, Enable shared session caching
|
|
24
|
+
# @attr [Boolean] disable_zero_copy, Disable zero-copy FFI input buffers to prevent use-after-free from caller runtime
|
|
24
25
|
# @attr [Boolean] verbose, Enable verbose logging output
|
|
25
26
|
class Config
|
|
26
27
|
MAPPING = {
|
|
@@ -40,6 +41,7 @@ module Asherah
|
|
|
40
41
|
session_cache_max_size: :SessionCacheMaxSize,
|
|
41
42
|
session_cache_duration: :SessionCacheDuration,
|
|
42
43
|
enable_session_caching: :EnableSessionCaching,
|
|
44
|
+
disable_zero_copy: :DisableZeroCopy,
|
|
43
45
|
expire_after: :ExpireAfter,
|
|
44
46
|
check_interval: :CheckInterval,
|
|
45
47
|
verbose: :Verbose
|
|
@@ -105,11 +107,10 @@ module Asherah
|
|
|
105
107
|
end
|
|
106
108
|
|
|
107
109
|
def validate_kms_attributes
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
end
|
|
110
|
+
return unless kms == 'aws'
|
|
111
|
+
raise Error::ConfigError, 'config.region_map not set' if region_map.nil?
|
|
112
|
+
raise Error::ConfigError, 'config.region_map must be a Hash' unless region_map.is_a?(Hash)
|
|
113
|
+
raise Error::ConfigError, 'config.preferred_region not set' if preferred_region.nil?
|
|
113
114
|
end
|
|
114
115
|
end
|
|
115
116
|
end
|
data/lib/asherah/version.rb
CHANGED
data/lib/asherah.rb
CHANGED
|
@@ -37,6 +37,8 @@ module Asherah
|
|
|
37
37
|
|
|
38
38
|
result = SetEnv(env_buffer)
|
|
39
39
|
Error.check_result!(result, 'SetEnv failed')
|
|
40
|
+
ensure
|
|
41
|
+
env_buffer&.free
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
# Configures Asherah
|
|
@@ -56,6 +58,8 @@ module Asherah
|
|
|
56
58
|
result = SetupJson(config_buffer)
|
|
57
59
|
Error.check_result!(result, 'SetupJson failed')
|
|
58
60
|
@initialized = true
|
|
61
|
+
ensure
|
|
62
|
+
config_buffer&.free
|
|
59
63
|
end
|
|
60
64
|
|
|
61
65
|
# Encrypts data for a given partition_id and returns DataRowRecord in JSON format.
|
|
@@ -74,6 +78,8 @@ module Asherah
|
|
|
74
78
|
# @param data [String]
|
|
75
79
|
# @return [String], DataRowRecord in JSON format
|
|
76
80
|
def encrypt(partition_id, data)
|
|
81
|
+
raise Asherah::Error::NotInitialized unless @initialized
|
|
82
|
+
|
|
77
83
|
partition_id_buffer = string_to_cbuffer(partition_id)
|
|
78
84
|
data_buffer = string_to_cbuffer(data)
|
|
79
85
|
estimated_buffer_bytesize = estimate_buffer(data.bytesize, partition_id.bytesize)
|
|
@@ -84,7 +90,7 @@ module Asherah
|
|
|
84
90
|
|
|
85
91
|
cbuffer_to_string(output_buffer)
|
|
86
92
|
ensure
|
|
87
|
-
[partition_id_buffer, data_buffer, output_buffer].
|
|
93
|
+
[partition_id_buffer, data_buffer, output_buffer].compact.each(&:free)
|
|
88
94
|
end
|
|
89
95
|
|
|
90
96
|
# Decrypts a DataRowRecord in JSON format for a partition_id and returns decrypted data.
|
|
@@ -93,6 +99,8 @@ module Asherah
|
|
|
93
99
|
# @param json [String], DataRowRecord in JSON format
|
|
94
100
|
# @return [String], Decrypted data
|
|
95
101
|
def decrypt(partition_id, json)
|
|
102
|
+
raise Asherah::Error::NotInitialized unless @initialized
|
|
103
|
+
|
|
96
104
|
partition_id_buffer = string_to_cbuffer(partition_id)
|
|
97
105
|
data_buffer = string_to_cbuffer(json)
|
|
98
106
|
output_buffer = allocate_cbuffer(json.bytesize)
|
|
@@ -102,7 +110,7 @@ module Asherah
|
|
|
102
110
|
|
|
103
111
|
cbuffer_to_string(output_buffer)
|
|
104
112
|
ensure
|
|
105
|
-
[partition_id_buffer, data_buffer, output_buffer].
|
|
113
|
+
[partition_id_buffer, data_buffer, output_buffer].compact.each(&:free)
|
|
106
114
|
end
|
|
107
115
|
|
|
108
116
|
# Stop the Asherah instance
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: asherah
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GoDaddy
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-03-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cobhan
|
|
@@ -34,6 +34,7 @@ extensions:
|
|
|
34
34
|
- ext/asherah/extconf.rb
|
|
35
35
|
extra_rdoc_files: []
|
|
36
36
|
files:
|
|
37
|
+
- ".env.secrets.example"
|
|
37
38
|
- ".rspec"
|
|
38
39
|
- ".rubocop.yml"
|
|
39
40
|
- ".ruby-version"
|
|
@@ -69,7 +70,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
69
70
|
requirements:
|
|
70
71
|
- - ">="
|
|
71
72
|
- !ruby/object:Gem::Version
|
|
72
|
-
version: 2.
|
|
73
|
+
version: 2.7.0
|
|
73
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
75
|
requirements:
|
|
75
76
|
- - ">="
|