asherah 0.3.0-arm64-darwin → 0.4.1-arm64-darwin

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: 6a43b4d34ccce682cf20e8e0154704be1e88f43fd83243143b1eb29cb184e5e1
4
- data.tar.gz: 4e1f4ba3d4f67096204bc126eea95e2dcc50666ecf1dc4d3e4f2dac2108b19e4
3
+ metadata.gz: efa2ad977b1b285cf1bcaf6b9cc4955cff8a10ada3b2fe95defef432e8226836
4
+ data.tar.gz: 7526c84667c9f42b27eeb34f2c7db449dd1a3c5b229ed6377732309529fe94b4
5
5
  SHA512:
6
- metadata.gz: 5ff13c55e0d1eee27ed301a854e353fe0edc7acdbe99f9da41a1e215ee64f7311353bc45f89f1ad652508545e74e9f1949e92e50e9dd6d41ebe8c2bea47ef1c6
7
- data.tar.gz: 63dab48dfb85fe4e794dc5a5431cf1a7e5abc2f27ff62a90d9e7cec7939e85e24e04ccdd14107274a341f9f7b1020867bcae41b93ef0ce8d4064d48bf544bc3e
6
+ metadata.gz: dd4e99affde2cf8dcf54fb80766464199cbb4c64f14d214fc216a1cf90e922677eb14d486e650fe1fd48532e0a6c5532891278b578c0d7c18542d334857f79a9
7
+ data.tar.gz: 7df0a5794af380b58272f38eadb17095a1f19de8156748b2530e56e4ce58b46e84e55984324e42b857e2c24ae74690f7ec8460ffe8515c48990bd82d201d25e4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.1] - 2022-03-25
4
+
5
+ - Build and release platform gems
6
+
7
+ ## [0.4.0] - 2022-03-25
8
+
9
+ - Download native file during gem install and verify checksum
10
+ - Upgrade to use asherah-cobhan v0.4.11
11
+
3
12
  ## [0.3.0] - 2022-03-22
4
13
 
5
14
  - Free up cobhan buffers after encrypt/decrypt to prevent growing heap memory
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Asherah
2
2
 
3
- Asherah is a Ruby wrapper around [Asherah Go](https://github.com/godaddy/asherah) application-layer encryption SDK that provides advanced encryption features and defense in depth against compromise. It uses a technique known as "envelope encryption" and supports cloud-agnostic data storage and key management.
3
+ Asherah is a Ruby FFI wrapper around Go version of [Asherah](https://github.com/godaddy/asherah) application-layer encryption SDK. Asherah provides advanced encryption features and defense in depth against compromise. It uses a technique known as "envelope encryption" and supports cloud-agnostic data storage and key management.
4
4
 
5
- Check out the following documentation to get more familiar with its concepts:
5
+ Check out the following documentation to get more familiar with the concepts and configuration options:
6
6
 
7
7
  - [Design and Architecture](https://github.com/godaddy/asherah/blob/master/docs/DesignAndArchitecture.md)
8
8
  - [Key Caching](https://github.com/godaddy/asherah/blob/master/docs/KeyCaching.md)
@@ -10,6 +10,10 @@ Check out the following documentation to get more familiar with its concepts:
10
10
  - [Metastore](https://github.com/godaddy/asherah/blob/master/docs/Metastore.md)
11
11
  - [System Requirements](https://github.com/godaddy/asherah/blob/master/docs/SystemRequirements.md)
12
12
 
13
+ ## Supported Platforms
14
+
15
+ Currently supported platforms are Linux and Darwin operating systems for x64 and arm64 CPU architectures.
16
+
13
17
  ## Installation
14
18
 
15
19
  Add this line to your application's Gemfile:
@@ -45,7 +49,7 @@ Encrypt some data for a `partition_id`
45
49
 
46
50
  ```ruby
47
51
  partition_id = 'user_1'
48
- data = 'Some PII data'
52
+ data = 'PII data'
49
53
  data_row_record_json = Asherah.encrypt(partition_id, data)
50
54
  puts data_row_record_json
51
55
  ```
@@ -61,23 +65,22 @@ puts decrypted_data
61
65
 
62
66
  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.
63
67
 
64
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
68
+ To install this gem onto your local machine, run `rake install`.
65
69
 
66
- ## Contributing
67
-
68
- Bug reports and pull requests are welcome on GitHub at https://github.com/godaddy/asherah-ruby.
69
-
70
- ## Releasing new gem version
70
+ To release a new version, update the version number in `version.rb`, create and push a version tag:
71
71
 
72
72
  ```
73
- # Create and push a version tag
74
73
  git tag -a v$(rake version) -m "Version $(rake version)"
75
74
  git push origin v$(rake version)
76
-
77
- # Create a release in Github to trigger .github/workflows/publish.yml workflow
78
- echo "Version $(rake version)"
79
75
  ```
80
76
 
77
+ And then create a release in Github with title `echo "Version $(rake version)"` that will trigger `.github/workflows/publish.yml` workflow and push the `.gem` file to [rubygems.org](https://rubygems.org):
78
+
79
+
80
+ ## Contributing
81
+
82
+ Bug reports and pull requests are welcome on GitHub at https://github.com/godaddy/asherah-ruby.
83
+
81
84
  ## License
82
85
 
83
86
  The gem is available as open source under the terms of the [MIT License](LICENSE.txt).
data/Rakefile CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
- require 'rubygems/package'
6
5
 
7
6
  RSpec::Core::RakeTask.new(:spec)
8
7
 
@@ -10,112 +9,21 @@ require 'rubocop/rake_task'
10
9
 
11
10
  RuboCop::RakeTask.new
12
11
 
13
- task default: %i[spec rubocop]
14
-
15
- ASHERAH_BIN = 'bin/download-asherah.sh'
16
- DISTRIBUTIONS = {
17
- 'x86_64-linux' => ['libasherah-x64.so'],
18
- 'x86_64-darwin' => ['libasherah-x64.dylib'],
19
- 'aarch64-linux' => ['libasherah-arm64.so'],
20
- 'arm64-darwin' => ['libasherah-arm64.dylib']
21
- }.freeze
22
-
23
- def current_filename
24
- @current_filename ||=
25
- begin
26
- require 'cobhan'
27
- Class.new.extend(Cobhan).library_file_name('libasherah')
28
- end
29
- end
30
-
31
- def current_platform
32
- @distribution ||= DISTRIBUTIONS.detect { |_k, v| v.include?(current_filename) }
33
- @distribution.first
34
- end
35
-
36
- def native_build(platform, native_files)
37
- puts "Building gem for #{platform}"
38
-
39
- pkg_dir = File.join(__dir__, 'pkg')
40
- FileUtils.mkdir_p(pkg_dir)
41
-
42
- tmp_gem_dir = File.join(__dir__, 'tmp', platform)
43
- FileUtils.rm_rf(tmp_gem_dir, verbose: true)
44
- FileUtils.mkdir_p(tmp_gem_dir, verbose: true)
45
-
46
- # Copy files to tmp gem dir
47
- gemspec = Bundler.load_gemspec('asherah.gemspec')
48
- (gemspec.files + [ASHERAH_BIN]).each do |file|
49
- dir = File.dirname(file)
50
- filename = File.basename(file)
51
- FileUtils.mkdir_p(File.join(tmp_gem_dir, dir))
52
- FileUtils.copy_file(file, File.join(tmp_gem_dir, dir, filename))
53
- end
54
-
55
- # Set platform for native gem build
56
- gemspec.platform = Gem::Platform.new(platform)
57
-
58
- native_dir = 'lib/asherah/native'
59
- FileUtils.cd(tmp_gem_dir, verbose: true) do
60
- FileUtils.mkdir_p(native_dir)
61
- native_files.each do |native_file|
62
- native_file_path = File.join(native_dir, native_file)
63
-
64
- # Download native file
65
- download_asherah_path = File.join(tmp_gem_dir, ASHERAH_BIN)
66
- system("#{download_asherah_path} #{native_file}")
67
-
68
- # Add native file in gemspec
69
- gemspec.files << native_file_path
70
- end
71
-
72
- package = Gem::Package.build(gemspec)
73
- FileUtils.mv package, File.join(pkg_dir, package)
12
+ desc 'Download the binary for the current platform'
13
+ task :download do
14
+ tmp_dir = 'tmp'
15
+ FileUtils.mkdir_p(tmp_dir)
16
+ FileUtils.cd(tmp_dir, verbose: true) do
17
+ system('ruby ../ext/asherah/extconf.rb')
74
18
  end
75
19
  end
76
20
 
77
- namespace :native do
78
- desc 'Build all native gems'
79
- task :build do
80
- DISTRIBUTIONS.each do |platform, native_files|
81
- native_build(platform, native_files)
82
- end
83
- end
84
-
85
- namespace :build do
86
- DISTRIBUTIONS.each do |platform, native_files|
87
- desc "Build native gem for #{platform}"
88
- task :"#{platform}" do
89
- native_build(platform, native_files)
90
- end
91
- end
92
- end
93
-
94
- namespace :current do
95
- desc 'Download asherah binary for current platform'
96
- task :download do
97
- download_asherah_path = File.join(__dir__, ASHERAH_BIN)
98
- system("#{download_asherah_path} #{current_filename}")
99
- end
100
-
101
- desc 'Build native gem for current platform'
102
- task :build do
103
- native_build(current_platform, DISTRIBUTIONS[current_platform])
104
- end
105
-
106
- desc 'Smoke test native gem for current platform'
107
- task smoke: :build do
108
- platform = current_platform
109
- gemspec = Bundler.load_gemspec('asherah.gemspec')
110
- gemspec.platform = Gem::Platform.new(platform)
111
-
112
- sh('gem uninstall asherah')
113
- sh("gem install pkg/#{gemspec.file_name}")
114
- sh('ruby spec/smoke_test.rb')
115
- end
116
- end
117
- end
21
+ task default: %i[spec rubocop]
22
+ task spec: :download
118
23
 
24
+ desc 'Print current version'
119
25
  task :version do
120
26
  puts Asherah::VERSION
121
27
  end
28
+
29
+ Rake.add_rakelib 'tasks'
data/asherah.gemspec CHANGED
@@ -27,12 +27,13 @@ Gem::Specification.new do |spec|
27
27
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
28
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
29
29
  `git ls-files -z`.split("\x0").reject do |f|
30
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
30
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features|tasks)/|\.(?:git|travis|circleci)|appveyor)})
31
31
  end
32
32
  end
33
33
  spec.bindir = 'exe'
34
34
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
35
35
  spec.require_paths = ['lib']
36
+ spec.extensions = ['ext/asherah/extconf.rb']
36
37
 
37
38
  spec.add_dependency 'cobhan', '~> 0.2.0'
38
39
  spec.add_development_dependency 'dotenv', '~> 2.7.6'
@@ -0,0 +1,5 @@
1
+ version: v0.4.11
2
+ libasherah-arm64.so: bc044b74453fc8fceca564fb127c9f2748aeac107791bd24c680ced1fcb7b816
3
+ libasherah-x64.so: 82f10505ef11fba2c8e027668d9b5c89584f73eb1e53a9f5ff21d5705ecffb3a
4
+ libasherah-arm64.dylib: 0b843d002212722c442c990d84e6ceac73c78e1663260be8c3f759a9a283b14a
5
+ libasherah-x64.dylib: fd0592ed4cdfbc7b3a2534b540c22301a9669c6c37dfb3d28f600ccc9ba975f8
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mkmf'
4
+ create_makefile('asherah/asherah')
5
+
6
+ require_relative 'native_file'
7
+ NativeFile.download
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open-uri'
4
+ require 'fileutils'
5
+ require 'digest'
6
+ require 'yaml'
7
+ require 'cobhan'
8
+
9
+ # Downloads native file and verifies checksum
10
+ class NativeFile
11
+ LIB_NAME = 'libasherah'
12
+ ROOT_DIR = File.expand_path('../../', __dir__)
13
+ CHECKSUMS_FILE = File.expand_path('checksums.yml', __dir__)
14
+ CHECKSUMS = YAML.load_file(CHECKSUMS_FILE)
15
+ VERSION = CHECKSUMS.fetch('version')
16
+ RETRIES = 3
17
+ RETRY_DELAY = 1
18
+
19
+ class << self
20
+ def download(
21
+ file_name: Class.new.extend(Cobhan).library_file_name(LIB_NAME),
22
+ dir: File.join(ROOT_DIR, 'lib/asherah/native')
23
+ )
24
+ file_path = File.join(dir, file_name)
25
+ if File.exist?(file_path)
26
+ puts "#{file_path} already exists ... skipping download"
27
+ return
28
+ end
29
+
30
+ checksum = CHECKSUMS.fetch(file_name) do
31
+ abort "Unsupported platform #{RUBY_PLATFORM}"
32
+ end
33
+
34
+ content = download_content(file_name)
35
+
36
+ sha256 = Digest::SHA256.hexdigest(content)
37
+ abort "Could not verify checksum of #{file_name}" if sha256 != checksum
38
+
39
+ FileUtils.mkdir_p(dir)
40
+ File.binwrite(file_path, content)
41
+ end
42
+
43
+ private
44
+
45
+ def download_content(file_name)
46
+ tries = 0
47
+
48
+ begin
49
+ tries += 1
50
+ url = "https://github.com/godaddy/asherah-cobhan/releases/download/#{VERSION}/#{file_name}"
51
+ puts "Downloading #{url}"
52
+ URI.parse(url).open.read
53
+ rescue Net::OpenTimeout, Net::ReadTimeout => e
54
+ if tries <= RETRIES
55
+ puts "Got #{e.class}... retrying in #{RETRY_DELAY} seconds"
56
+ sleep RETRY_DELAY
57
+ retry
58
+ else
59
+ raise e
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Asherah
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.1'
5
5
  end
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.3.0
4
+ version: 0.4.1
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - GoDaddy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-22 00:00:00.000000000 Z
11
+ date: 2022-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cobhan
@@ -100,7 +100,8 @@ description: |
100
100
  email:
101
101
  - oss@godaddy.com
102
102
  executables: []
103
- extensions: []
103
+ extensions:
104
+ - ext/asherah/extconf.rb
104
105
  extra_rdoc_files: []
105
106
  files:
106
107
  - ".rspec"
@@ -115,6 +116,9 @@ files:
115
116
  - Rakefile
116
117
  - SECURITY.md
117
118
  - asherah.gemspec
119
+ - ext/asherah/checksums.yml
120
+ - ext/asherah/extconf.rb
121
+ - ext/asherah/native_file.rb
118
122
  - lib/asherah.rb
119
123
  - lib/asherah/config.rb
120
124
  - lib/asherah/error.rb