Skip to content

Commit

Permalink
Merge pull request #29 from cyberark/adjust-to-ruby-3
Browse files Browse the repository at this point in the history
ONYX-14080: Bump to V3.0.0 with Ruby 3
  • Loading branch information
semyon-estrin authored Feb 1, 2022
2 parents 134989d + 42f328d commit 693d787
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v3.0.0

* Transition to Ruby 3. Consuming projects based on Ruby 2 shall use slosilo V2.X.X.

# v2.2.2

* Add rake task `slosilo:recalculate_fingerprints` which rehashes the fingerprints in the keystore.
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ And then execute:

## Compatibility

Version 3.0 introduced full transition to Ruby 3.
Consumers who use slosilo in Ruby 2 projects, shall use slosilo V2.X.X.

Version 2.0 introduced new symmetric encryption scheme using AES-256-GCM
for authenticated encryption. It allows you to provide AAD on all symmetric
encryption primitives. It's also **NOT COMPATIBLE** with CBC used in version <2.
Expand Down
5 changes: 4 additions & 1 deletion lib/slosilo/attr_encrypted.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ def attr_encrypted *a
aad = options[:aad]
# note nil.to_s is "", which is exactly the right thing
auth_data = aad.respond_to?(:to_proc) ? aad.to_proc : proc{ |_| aad.to_s }
raise ":aad proc must take one argument" unless auth_data.arity.abs == 1 # take abs to allow *args arity, -1

# In ruby 3 .arity for #proc returns both 1 and 2, depends on internal #proc
# This method is also being called with aad which is string, in such case the arity is 1
raise ":aad proc must take two arguments" unless (auth_data.arity.abs == 2 || auth_data.arity.abs == 1)

# push a module onto the inheritance hierarchy
# this allows calling super in classes
Expand Down
2 changes: 1 addition & 1 deletion lib/slosilo/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Slosilo
VERSION = "2.2.2"
VERSION = "3.0.0"
end
2 changes: 1 addition & 1 deletion slosilo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
gem.name = "slosilo"
gem.require_paths = ["lib"]
gem.version = Slosilo::VERSION
gem.required_ruby_version = '>= 1.9.3'
gem.required_ruby_version = '>= 3.0.0'

gem.add_development_dependency 'rake'
gem.add_development_dependency 'rspec', '~> 3.0'
Expand Down
4 changes: 2 additions & 2 deletions spec/sequel_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
describe "#put_key" do
let(:id) { "id" }
it "creates the key" do
expect(model).to receive(:create).with id: id, key: key.to_der
expect(model).to receive(:create).with(hash_including(:id => id, :key => key.to_der))
allow(model).to receive_messages columns: [:id, :key]
subject.put_key id, key
end

it "adds the fingerprint if feasible" do
expect(model).to receive(:create).with id: id, key: key.to_der, fingerprint: key.fingerprint
expect(model).to receive(:create).with(hash_including(:id => id, :key => key.to_der, :fingerprint => key.fingerprint))
allow(model).to receive_messages columns: [:id, :key, :fingerprint]
subject.put_key id, key
end
Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
iid=slosilo-test-$(date +%s)

docker build -t $iid -f - . << EOF
FROM ruby
FROM ruby:3.0
WORKDIR /app
COPY Gemfile slosilo.gemspec ./
RUN bundle
Expand Down

0 comments on commit 693d787

Please sign in to comment.