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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 548099e0a0802b5a728c9ec359f077fb934e5b9ac72ebedf812aefb971700802
4
- data.tar.gz: 412be27d183db81ddd9b9a991d6e10362b3528dcf5754db725fd31d5291f3b1d
3
+ metadata.gz: 6c099a6a66b5d0f86edfaf4c05b9a3fe53234dae2e592ca6951e9b55a15727ab
4
+ data.tar.gz: 2a5c95bcc046532ca280ad2f5ac9ac5043462dc5ec877f3042a359c6a0ac9167
5
5
  SHA512:
6
- metadata.gz: 654b181dd76469ac24ad54b5cad09b78bf5aad400e2e6d6009107b5c3da841d030482aa9d9911f709417dd5aa2be2a9b0631f06d307afaa249a57e3fd44141f2
7
- data.tar.gz: ed52444b563ada73381b8cf3e8ddd33f701e534d3c3fe3da602a6d4490d30bb863be6f4c234074cca79dc10a2b2ac03d30c097174a7bd7695e5a26830f0992ba
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.5
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
- Enabled: false
14
+ Max: 25
15
+ Exclude:
16
+ - 'spec/**/*'
17
+ - '*.gemspec'
18
+ - 'Rakefile'
14
19
 
15
20
  Metrics/MethodLength:
16
- Enabled: false
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
- Enabled: false
54
+ MinSize: 3
55
+ EnforcedStyle: brackets
20
56
 
21
57
  Style/SymbolArray:
22
- Enabled: false
58
+ MinSize: 3
59
+ EnforcedStyle: brackets
23
60
 
24
61
  Style/MultilineBlockChain:
25
- Enabled: false
62
+ Enabled: true
63
+ Exclude:
64
+ - 'spec/**/*'
26
65
 
27
66
  Style/BlockDelimiters:
28
- Enabled: false
29
-
30
- Metrics/AbcSize:
31
- Enabled: false
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
- Enabled: false
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', '~> 7.1.0'
9
- gem 'dotenv', '~> 2.7.6'
8
+ gem 'cucumber', '~> 9.2.1'
9
+ gem 'dotenv', '~> 2.8.1'
10
10
  gem 'rake', '~> 13.0'
11
- gem 'rspec', '~> 3.10.0'
11
+ gem 'rspec', '~> 3.13.1'
12
12
  gem 'rubocop', '~> 1.7'
13
- gem 'simplecov', '~> 0.21.2'
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
@@ -18,7 +18,7 @@ task :download do
18
18
  end
19
19
  end
20
20
 
21
- task default: %i[spec rubocop]
21
+ task default: [:spec, :rubocop]
22
22
  task spec: :download
23
23
 
24
24
  desc 'Print current version'
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.5.0'
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'
@@ -1,5 +1,5 @@
1
- version: v0.4.35
2
- libasherah-arm64.so: fad23a38e68e126374075adf197f0f431720aea9852deebe5f62d9240c935a66
3
- libasherah-x64.so: 8c52fc000df2c02fb2d1430afc3cd68e997f47f04b60d61481f8c4b201958ef8
4
- libasherah-arm64.dylib: 315bc41c85177a2b0c97f32e0af8e2694f393928678cbe648fdd8c16b8fe062a
5
- libasherah-x64.dylib: 848d3635713373e0482223087f454ff8464e36e7695e0ed19f830737288adaa9
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
@@ -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
- if kms == 'aws'
109
- raise Error::ConfigError, 'config.region_map not set' if region_map.nil?
110
- raise Error::ConfigError, 'config.region_map must be a Hash' unless region_map.is_a?(Hash)
111
- raise Error::ConfigError, 'config.preferred_region not set' if preferred_region.nil?
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Asherah
4
- VERSION = '0.6.0'
4
+ VERSION = '0.8.0'
5
5
  end
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].map(&:free)
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].map(&:free)
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.6.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: 2025-03-19 00:00:00.000000000 Z
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.5.0
73
+ version: 2.7.0
73
74
  required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  requirements:
75
76
  - - ">="