asherah 0.3.0-x86_64-darwin → 0.4.3-x86_64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +18 -0
- data/README.md +16 -13
- data/Rakefile +11 -103
- data/asherah.gemspec +2 -1
- data/ext/asherah/checksums.yml +5 -0
- data/ext/asherah/extconf.rb +7 -0
- data/ext/asherah/native_file.rb +64 -0
- data/lib/asherah/native/libasherah-x64.dylib +0 -0
- data/lib/asherah/version.rb +1 -1
- data/lib/asherah.rb +17 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a868c2f22d3460e16cab1dc32bfbb530020b0bb934253eaa4840e4383ad5eb6
|
4
|
+
data.tar.gz: 1638d09509e0966172646bb547134e147b6270c3271fcb823b2ab7850efe6c4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8a03518b84decaa19c5e94d51859995feedaa782368851bcea8b3ee037bc9effe3f37386af0592147d120c21bd265f21597b86624353c2c8eeb9394e7be635c
|
7
|
+
data.tar.gz: da8273a14fb347d932b215e19befc2b0b27e70d4be265166294a2f8f74453787216df68546420ea58b8ee8f3640cda597dfe5ca28150c2dcacd4722eb814b46e
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.4.3] - 2022-08-31
|
4
|
+
|
5
|
+
- Upgrade to use asherah-cobhan v0.4.16
|
6
|
+
|
7
|
+
## [0.4.2] - 2022-07-25
|
8
|
+
|
9
|
+
- Upgrade to use asherah-cobhan v0.4.15
|
10
|
+
- Add `set_env` method to set environment variables for Asherah
|
11
|
+
|
12
|
+
## [0.4.1] - 2022-03-25
|
13
|
+
|
14
|
+
- Build and release platform gems
|
15
|
+
|
16
|
+
## [0.4.0] - 2022-03-25
|
17
|
+
|
18
|
+
- Download native file during gem install and verify checksum
|
19
|
+
- Upgrade to use asherah-cobhan v0.4.11
|
20
|
+
|
3
21
|
## [0.3.0] - 2022-03-22
|
4
22
|
|
5
23
|
- 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
|
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
|
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 = '
|
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 `
|
68
|
+
To install this gem onto your local machine, run `rake install`.
|
65
69
|
|
66
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
78
|
-
|
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.16
|
2
|
+
libasherah-arm64.so: 14c4734de6bbae936e3504ad9daa31f1081755de017188a46079f0b1d3a14ea1
|
3
|
+
libasherah-x64.so: 60d68c030cdc1c792ee002f77f3b4f3f28994b94ed080b2c618d7ee636248a12
|
4
|
+
libasherah-arm64.dylib: 5d7b358e1dfd6a1946a6538442856f44a1c122d5ec467b41f6f994eac45c8a2f
|
5
|
+
libasherah-x64.dylib: 0b01f69740628869052dabdcc33c69f4a1349e4136c68ce7d859b4eb7800d0a9
|
@@ -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
|
Binary file
|
data/lib/asherah/version.rb
CHANGED
data/lib/asherah.rb
CHANGED
@@ -11,6 +11,7 @@ module Asherah
|
|
11
11
|
|
12
12
|
LIB_ROOT_PATH = File.expand_path('asherah/native', __dir__)
|
13
13
|
load_library(LIB_ROOT_PATH, 'libasherah', [
|
14
|
+
[:SetEnv, [:pointer], :int32],
|
14
15
|
[:SetupJson, [:pointer], :int32],
|
15
16
|
[:EncryptToJson, [:pointer, :pointer, :pointer], :int32],
|
16
17
|
[:DecryptFromJson, [:pointer, :pointer, :pointer], :int32],
|
@@ -22,6 +23,22 @@ module Asherah
|
|
22
23
|
BASE64_OVERHEAD = 1.34
|
23
24
|
|
24
25
|
class << self
|
26
|
+
# Set environment variables needed by Asherah dependencies for when
|
27
|
+
# Go os.Getenv() doesn't see variables set by C.setenv().
|
28
|
+
# References:
|
29
|
+
# https://github.com/golang/go/wiki/cgo#environmental-variables
|
30
|
+
# https://github.com/golang/go/issues/44108
|
31
|
+
#
|
32
|
+
# @yield [Config]
|
33
|
+
# @param env [Hash], Key-value pairs to set Asherah ENV
|
34
|
+
# @return [void]
|
35
|
+
def set_env(env = {})
|
36
|
+
env_buffer = string_to_cbuffer(env.to_json)
|
37
|
+
|
38
|
+
result = SetEnv(env_buffer)
|
39
|
+
Error.check_result!(result, 'SetEnv failed')
|
40
|
+
end
|
41
|
+
|
25
42
|
# Configures Asherah
|
26
43
|
#
|
27
44
|
# @yield [Config]
|
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
|
4
|
+
version: 0.4.3
|
5
5
|
platform: x86_64-darwin
|
6
6
|
authors:
|
7
7
|
- GoDaddy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-31 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
|