slosilo 2.2.2 → 3.0.1
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/CHANGELOG.md +9 -0
- data/Jenkinsfile +27 -7
- data/README.md +3 -0
- data/dev/Dockerfile.dev +7 -0
- data/dev/docker-compose.yml +8 -0
- data/lib/slosilo/attr_encrypted.rb +4 -1
- data/lib/slosilo/symmetric.rb +26 -17
- data/lib/slosilo/version.rb +1 -1
- data/publish-rubygem.sh +2 -2
- data/slosilo.gemspec +1 -1
- data/spec/sequel_adapter_spec.rb +2 -2
- data/spec/symmetric_spec.rb +23 -2
- data/test.sh +1 -1
- metadata +6 -5
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 239f3678eb01bdaf97f3c7c243740ff3cf8c1b8507833ea07b150380d5a79ee2
|
4
|
+
data.tar.gz: 2226342fa45964d0fb368712c6c181c3c587aa5a3e46bda6a780f19346cc4d0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ace59188f2bcdf101d45cfc94d1924f469522d3d1e4d076e444d017804fee4ebd862163d7bb9e07358c289257a9d485ade42a28b4bbab4f7cbfd6b70e3612e2
|
7
|
+
data.tar.gz: 061ade3a431b2a6073971343a2a15403ec93628a99aecd0150cfa7eb97c69382879a2c4ee45d5525053adfb2bf4b9ada5107d811eceeba4fe71280add15717a8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# v3.0.1
|
2
|
+
|
3
|
+
* The symmetric cipher class now encrypts and decrypts in a thread-safe manner.
|
4
|
+
[cyberark/slosilo#31](https://github.com/cyberark/slosilo/pull/31)
|
5
|
+
|
6
|
+
# v3.0.0
|
7
|
+
|
8
|
+
* Transition to Ruby 3. Consuming projects based on Ruby 2 shall use slosilo V2.X.X.
|
9
|
+
|
1
10
|
# v2.2.2
|
2
11
|
|
3
12
|
* Add rake task `slosilo:recalculate_fingerprints` which rehashes the fingerprints in the keystore.
|
data/Jenkinsfile
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
pipeline {
|
4
4
|
agent { label 'executor-v2' }
|
5
5
|
|
6
|
+
triggers {
|
7
|
+
cron(getDailyCronString())
|
8
|
+
}
|
9
|
+
|
6
10
|
options {
|
7
11
|
timestamps()
|
8
12
|
buildDiscarder(logRotator(daysToKeepStr: '30'))
|
@@ -10,13 +14,22 @@ pipeline {
|
|
10
14
|
|
11
15
|
stages {
|
12
16
|
stage('Test') {
|
13
|
-
|
14
|
-
|
17
|
+
parallel {
|
18
|
+
stage('Run tests on EE') {
|
19
|
+
agent { label 'executor-v2-rhel-ee' }
|
20
|
+
steps {
|
21
|
+
sh './test.sh'
|
22
|
+
}
|
23
|
+
post { always {
|
24
|
+
stash name: 'eeTestResults', includes: 'spec/reports/*.xml', allowEmpty:true
|
25
|
+
}}
|
26
|
+
}
|
15
27
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
28
|
+
stage('Run tests') {
|
29
|
+
steps {
|
30
|
+
sh './test.sh'
|
31
|
+
}
|
32
|
+
}
|
20
33
|
}
|
21
34
|
}
|
22
35
|
|
@@ -24,7 +37,6 @@ pipeline {
|
|
24
37
|
agent { label 'executor-v2' }
|
25
38
|
when {
|
26
39
|
allOf {
|
27
|
-
branch 'master'
|
28
40
|
expression {
|
29
41
|
boolean publish = false
|
30
42
|
|
@@ -52,6 +64,14 @@ pipeline {
|
|
52
64
|
|
53
65
|
post {
|
54
66
|
always {
|
67
|
+
dir('ee-results'){
|
68
|
+
unstash 'eeTestResults'
|
69
|
+
}
|
70
|
+
junit 'spec/reports/*.xml, ee-results/spec/reports/*.xml'
|
71
|
+
cobertura coberturaReportFile: 'spec/coverage/coverage.xml'
|
72
|
+
sh 'cp spec/coverage/coverage.xml cobertura.xml'
|
73
|
+
ccCoverage("cobertura", "github.com/cyberark/slosilo")
|
74
|
+
|
55
75
|
cleanupAndNotify(currentBuild.currentResult)
|
56
76
|
}
|
57
77
|
}
|
data/README.md
CHANGED
@@ -19,6 +19,9 @@ And then execute:
|
|
19
19
|
|
20
20
|
## Compatibility
|
21
21
|
|
22
|
+
Version 3.0 introduced full transition to Ruby 3.
|
23
|
+
Consumers who use slosilo in Ruby 2 projects, shall use slosilo V2.X.X.
|
24
|
+
|
22
25
|
Version 2.0 introduced new symmetric encryption scheme using AES-256-GCM
|
23
26
|
for authenticated encryption. It allows you to provide AAD on all symmetric
|
24
27
|
encryption primitives. It's also **NOT COMPATIBLE** with CBC used in version <2.
|
data/dev/Dockerfile.dev
ADDED
@@ -26,7 +26,10 @@ module Slosilo
|
|
26
26
|
aad = options[:aad]
|
27
27
|
# note nil.to_s is "", which is exactly the right thing
|
28
28
|
auth_data = aad.respond_to?(:to_proc) ? aad.to_proc : proc{ |_| aad.to_s }
|
29
|
-
|
29
|
+
|
30
|
+
# In ruby 3 .arity for #proc returns both 1 and 2, depends on internal #proc
|
31
|
+
# This method is also being called with aad which is string, in such case the arity is 1
|
32
|
+
raise ":aad proc must take two arguments" unless (auth_data.arity.abs == 2 || auth_data.arity.abs == 1)
|
30
33
|
|
31
34
|
# push a module onto the inheritance hierarchy
|
32
35
|
# this allows calling super in classes
|
data/lib/slosilo/symmetric.rb
CHANGED
@@ -5,6 +5,7 @@ module Slosilo
|
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@cipher = OpenSSL::Cipher.new 'aes-256-gcm' # NB: has to be lower case for whatever reason.
|
8
|
+
@cipher_mutex = Mutex.new
|
8
9
|
end
|
9
10
|
|
10
11
|
# This lets us do a final sanity check in migrations from older encryption versions
|
@@ -13,14 +14,18 @@ module Slosilo
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def encrypt plaintext, opts = {}
|
16
|
-
|
17
|
-
|
18
|
-
@
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
# All of these operations in OpenSSL must occur atomically, so we
|
18
|
+
# synchronize their access to make this step thread-safe.
|
19
|
+
@cipher_mutex.synchronize do
|
20
|
+
@cipher.reset
|
21
|
+
@cipher.encrypt
|
22
|
+
@cipher.key = (opts[:key] or raise("missing :key option"))
|
23
|
+
@cipher.iv = iv = random_iv
|
24
|
+
@cipher.auth_data = opts[:aad] || "" # Nothing good happens if you set this to nil, or don't set it at all
|
25
|
+
ctext = @cipher.update(plaintext) + @cipher.final
|
26
|
+
tag = @cipher.auth_tag(TAG_LENGTH)
|
27
|
+
"#{VERSION_MAGIC}#{tag}#{iv}#{ctext}"
|
28
|
+
end
|
24
29
|
end
|
25
30
|
|
26
31
|
def decrypt ciphertext, opts = {}
|
@@ -28,19 +33,23 @@ module Slosilo
|
|
28
33
|
|
29
34
|
raise "Invalid version magic: expected #{VERSION_MAGIC} but was #{version}" unless version == VERSION_MAGIC
|
30
35
|
|
31
|
-
|
32
|
-
|
33
|
-
@
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
# All of these operations in OpenSSL must occur atomically, so we
|
37
|
+
# synchronize their access to make this step thread-safe.
|
38
|
+
@cipher_mutex.synchronize do
|
39
|
+
@cipher.reset
|
40
|
+
@cipher.decrypt
|
41
|
+
@cipher.key = opts[:key]
|
42
|
+
@cipher.iv = iv
|
43
|
+
@cipher.auth_tag = tag
|
44
|
+
@cipher.auth_data = opts[:aad] || ""
|
45
|
+
@cipher.update(ctext) + @cipher.final
|
46
|
+
end
|
38
47
|
end
|
39
|
-
|
48
|
+
|
40
49
|
def random_iv
|
41
50
|
@cipher.random_iv
|
42
51
|
end
|
43
|
-
|
52
|
+
|
44
53
|
def random_key
|
45
54
|
@cipher.random_key
|
46
55
|
end
|
data/lib/slosilo/version.rb
CHANGED
data/publish-rubygem.sh
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
docker pull registry.tld/conjurinc/publish-rubygem
|
4
4
|
|
5
|
-
|
5
|
+
git clean -fxd
|
6
6
|
|
7
7
|
summon --yaml "RUBYGEMS_API_KEY: !var rubygems/api-key" \
|
8
8
|
docker run --rm --env-file @SUMMONENVFILE -v "$(pwd)":/opt/src \
|
9
9
|
registry.tld/conjurinc/publish-rubygem slosilo
|
10
10
|
|
11
|
-
|
11
|
+
git clean -fxd
|
data/slosilo.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.name = "slosilo"
|
23
23
|
gem.require_paths = ["lib"]
|
24
24
|
gem.version = Slosilo::VERSION
|
25
|
-
gem.required_ruby_version = '>=
|
25
|
+
gem.required_ruby_version = '>= 3.0.0'
|
26
26
|
|
27
27
|
gem.add_development_dependency 'rake'
|
28
28
|
gem.add_development_dependency 'rspec', '~> 3.0'
|
data/spec/sequel_adapter_spec.rb
CHANGED
@@ -30,13 +30,13 @@ describe Slosilo::Adapters::SequelAdapter do
|
|
30
30
|
describe "#put_key" do
|
31
31
|
let(:id) { "id" }
|
32
32
|
it "creates the key" do
|
33
|
-
expect(model).to receive(:create).with
|
33
|
+
expect(model).to receive(:create).with(hash_including(:id => id, :key => key.to_der))
|
34
34
|
allow(model).to receive_messages columns: [:id, :key]
|
35
35
|
subject.put_key id, key
|
36
36
|
end
|
37
37
|
|
38
38
|
it "adds the fingerprint if feasible" do
|
39
|
-
expect(model).to receive(:create).with
|
39
|
+
expect(model).to receive(:create).with(hash_including(:id => id, :key => key.to_der, :fingerprint => key.fingerprint))
|
40
40
|
allow(model).to receive_messages columns: [:id, :key, :fingerprint]
|
41
41
|
subject.put_key id, key
|
42
42
|
end
|
data/spec/symmetric_spec.rb
CHANGED
@@ -14,8 +14,29 @@ describe Slosilo::Symmetric do
|
|
14
14
|
expect(subject.encrypt(plaintext, key: key, aad: auth_data)).to eq(ciphertext)
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
describe '#decrypt' do
|
19
|
+
|
20
|
+
it "doesn't fail when called by multiple threads" do
|
21
|
+
threads = []
|
22
|
+
|
23
|
+
begin
|
24
|
+
# Verify we can successfuly decrypt using many threads without OpenSSL
|
25
|
+
# errors.
|
26
|
+
1000.times do
|
27
|
+
threads << Thread.new do
|
28
|
+
100.times do
|
29
|
+
expect(
|
30
|
+
subject.decrypt(ciphertext, key: key, aad: auth_data)
|
31
|
+
).to eq(plaintext)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
ensure
|
36
|
+
threads.each(&:join)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
19
40
|
it "decrypts with AES-256-GCM" do
|
20
41
|
expect(subject.decrypt(ciphertext, key: key, aad: auth_data)).to eq(plaintext)
|
21
42
|
end
|
@@ -56,7 +77,7 @@ describe Slosilo::Symmetric do
|
|
56
77
|
end
|
57
78
|
end
|
58
79
|
end
|
59
|
-
|
80
|
+
|
60
81
|
describe '#random_iv' do
|
61
82
|
it "generates a random iv" do
|
62
83
|
expect_any_instance_of(OpenSSL::Cipher).to receive(:random_iv).and_return :iv
|
data/test.sh
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slosilo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafał Rzepecki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -146,7 +146,6 @@ extra_rdoc_files: []
|
|
146
146
|
files:
|
147
147
|
- ".dockerignore"
|
148
148
|
- ".github/CODEOWNERS"
|
149
|
-
- ".github/PULL_REQUEST_TEMPLATE.md"
|
150
149
|
- ".gitignore"
|
151
150
|
- ".gitleaks.toml"
|
152
151
|
- ".kateproject"
|
@@ -158,6 +157,8 @@ files:
|
|
158
157
|
- README.md
|
159
158
|
- Rakefile
|
160
159
|
- SECURITY.md
|
160
|
+
- dev/Dockerfile.dev
|
161
|
+
- dev/docker-compose.yml
|
161
162
|
- lib/slosilo.rb
|
162
163
|
- lib/slosilo/adapters/abstract_adapter.rb
|
163
164
|
- lib/slosilo/adapters/file_adapter.rb
|
@@ -199,14 +200,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
200
|
requirements:
|
200
201
|
- - ">="
|
201
202
|
- !ruby/object:Gem::Version
|
202
|
-
version:
|
203
|
+
version: 3.0.0
|
203
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
205
|
requirements:
|
205
206
|
- - ">="
|
206
207
|
- !ruby/object:Gem::Version
|
207
208
|
version: '0'
|
208
209
|
requirements: []
|
209
|
-
rubygems_version: 3.1.
|
210
|
+
rubygems_version: 3.1.6
|
210
211
|
signing_key:
|
211
212
|
specification_version: 4
|
212
213
|
summary: Store SSL keys in a database
|
@@ -1,21 +0,0 @@
|
|
1
|
-
### What does this PR do?
|
2
|
-
- _What's changed? Why were these changes made?_
|
3
|
-
- _How should the reviewer approach this PR, especially if manual tests are required?_
|
4
|
-
- _Are there relevant screenshots you can add to the PR description?_
|
5
|
-
|
6
|
-
### What ticket does this PR close?
|
7
|
-
Connected to #[relevant GitHub issues, eg 76]
|
8
|
-
|
9
|
-
### Checklists
|
10
|
-
|
11
|
-
#### Change log
|
12
|
-
- [ ] The CHANGELOG has been updated, or
|
13
|
-
- [ ] This PR does not include user-facing changes and doesn't require a CHANGELOG update
|
14
|
-
|
15
|
-
#### Test coverage
|
16
|
-
- [ ] This PR includes new unit and integration tests to go with the code changes, or
|
17
|
-
- [ ] The changes in this PR do not require tests
|
18
|
-
|
19
|
-
#### Documentation
|
20
|
-
- [ ] Docs (e.g. `README`s) were updated in this PR, and/or there is a follow-on issue to update docs, or
|
21
|
-
- [ ] This PR does not require updating any documentation
|