travis-encrypt 0.0.1 → 0.0.5
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/Gemfile +5 -1
- data/README.md +49 -0
- data/lib/travis/encrypt.rb +2 -1
- data/lib/travis/encrypt/{common.rb → base.rb} +18 -1
- data/lib/travis/encrypt/decryptor.rb +2 -12
- data/lib/travis/encrypt/encryptor.rb +2 -12
- data/lib/travis/encrypt/version.rb +1 -1
- data/spec/encrypt_spec.rb +6 -1
- metadata +10 -12
- data/Gemfile.lock +0 -23
- data/travis-encrypt.gemspec +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b4c5b90d121b7f46e33422a7627814a3cfb2625
|
4
|
+
data.tar.gz: 5a34a737000fb84382fa53b83bb010e5f2d464c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72b1a0b20ec4384530d5322dffd601f14e5b658bab3a9901db98733a284b29b1b7ffe27cb73a03fad2d18d1ada711da3b7f0330d901b5f0580977d4834bb07e2
|
7
|
+
data.tar.gz: b11628cc49b98f62f90d58aa06e2e31a1a0bcaa8880a5a4546b439f0402710e557ad0cea23d839b91ef29215f19f37bda00157ea6c66ead5dc85f8ebce9b9e75
|
data/Gemfile
CHANGED
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# travis-encrypt
|
2
|
+
|
3
|
+
Encryption support for models and helpers in travis-ci services.
|
4
|
+
|
5
|
+
Usage:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
require 'travis/encrypt'
|
9
|
+
|
10
|
+
Encrypt.setup(key: 'secret')
|
11
|
+
|
12
|
+
class Foo < ActiveRecord::Base
|
13
|
+
include Travis::Encrypt::Helpers::ActiveRecord
|
14
|
+
|
15
|
+
attr_encrypted :foo
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
or:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'travis/encrypt'
|
23
|
+
|
24
|
+
class Foo < ActiveRecord::Base
|
25
|
+
include Travis::Encrypt::Helpers::ActiveRecord
|
26
|
+
|
27
|
+
attr_encrypted :foo, key: 'secret'
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
For Sequel models use `Travis::Encrypt::Helpers::Sequel`, which also decrypts
|
32
|
+
values in `values`.
|
33
|
+
|
34
|
+
Note this currently goes through normal attribute accessors, so not all methods
|
35
|
+
might return decrypted values (e.g. ActiveRecord's `pluck`, and Sequel's
|
36
|
+
`select_map`).
|
37
|
+
|
38
|
+
### Doing releases
|
39
|
+
|
40
|
+
Bump the version in
|
41
|
+
[travis/encrypt/version.rb](https://github.com/travis-ci/travis-encrypt/blob/master/lib/travis/encrypt/version.rb),
|
42
|
+
create a git tag, and push to https://rubygems.org
|
43
|
+
|
44
|
+
Or:
|
45
|
+
|
46
|
+
```
|
47
|
+
$ gem install gem-release
|
48
|
+
$ gem bump --push --tag --release
|
49
|
+
```
|
data/lib/travis/encrypt.rb
CHANGED
@@ -1,7 +1,17 @@
|
|
1
1
|
module Travis
|
2
2
|
module Encrypt
|
3
|
-
|
3
|
+
class Base
|
4
|
+
attr_reader :string, :key, :options
|
5
|
+
|
6
|
+
def initialize(string, options)
|
7
|
+
@string = string
|
8
|
+
@key = options[:key]
|
9
|
+
@options = options
|
10
|
+
validate
|
11
|
+
end
|
12
|
+
|
4
13
|
def create_aes(mode = :encrypt, key, iv)
|
14
|
+
key = key[0, 32] # https://github.com/ruby/ruby/commit/ce635262f53b760284d56bb1027baebaaec175d1
|
5
15
|
aes = OpenSSL::Cipher::AES.new(256, :CBC)
|
6
16
|
aes.send(mode)
|
7
17
|
aes.key = key
|
@@ -28,6 +38,13 @@ module Travis
|
|
28
38
|
def decode(str)
|
29
39
|
Base64.strict_decode64(str)
|
30
40
|
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def validate
|
45
|
+
key || fail('No key given')
|
46
|
+
key.is_a?(String) || fail("Invalid key given: #{key.inspect}")
|
47
|
+
end
|
31
48
|
end
|
32
49
|
end
|
33
50
|
end
|
@@ -1,18 +1,8 @@
|
|
1
|
-
require 'travis/encrypt/
|
1
|
+
require 'travis/encrypt/base'
|
2
2
|
|
3
3
|
module Travis
|
4
4
|
module Encrypt
|
5
|
-
class Decryptor
|
6
|
-
include Common
|
7
|
-
|
8
|
-
attr_reader :string, :key, :options
|
9
|
-
|
10
|
-
def initialize(string, options)
|
11
|
-
@string = string
|
12
|
-
@key = options[:key] || fail("Need to pass a key")
|
13
|
-
@options = options || {}
|
14
|
-
end
|
15
|
-
|
5
|
+
class Decryptor < Base
|
16
6
|
def apply?
|
17
7
|
string && (!use_prefix? || prefix_used?)
|
18
8
|
end
|
@@ -1,18 +1,8 @@
|
|
1
|
-
require 'travis/encrypt/
|
1
|
+
require 'travis/encrypt/base'
|
2
2
|
|
3
3
|
module Travis
|
4
4
|
module Encrypt
|
5
|
-
class Encryptor
|
6
|
-
include Common
|
7
|
-
|
8
|
-
attr_reader :string, :key, :options
|
9
|
-
|
10
|
-
def initialize(string, options)
|
11
|
-
@string = string
|
12
|
-
@key = options[:key] || fail("Need to pass a key")
|
13
|
-
@options = options || {}
|
14
|
-
end
|
15
|
-
|
5
|
+
class Encryptor < Base
|
16
6
|
def apply?
|
17
7
|
!!string && !string.empty? && !options[:disable] # TODO ask piotr
|
18
8
|
end
|
data/spec/encrypt_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe Travis::Encrypt do
|
|
4
4
|
let(:string) { 'travis' }
|
5
5
|
let(:encrypted) { encrypt(string, options) }
|
6
6
|
let(:decrypted) { decrypt(encrypted, options) }
|
7
|
-
let(:options) { { key: '
|
7
|
+
let(:options) { { key: 'secret' * 10 } }
|
8
8
|
|
9
9
|
it 'can decrypt an encrypted string' do
|
10
10
|
expect(decrypted).to eql(string)
|
@@ -18,4 +18,9 @@ describe Travis::Encrypt do
|
|
18
18
|
options[:use_prefix] = false
|
19
19
|
expect(encrypted[0..7]).to_not eql(described_class::PREFIX)
|
20
20
|
end
|
21
|
+
|
22
|
+
describe 'travis-core legacy compat' do
|
23
|
+
let(:encrypted) { '--ENCR--q/BkAx83j9FaMqw0RR2mqzBmMjI1ZGFjMGI3YTY3ZDc=' }
|
24
|
+
it { expect(decrypted).to eq('foo') }
|
25
|
+
end
|
21
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travis-encrypt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis CI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Travis CI encryption support.
|
14
14
|
email: contact@travis-ci.org
|
@@ -16,21 +16,20 @@ executables: []
|
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
-
-
|
20
|
-
- Gemfile.lock
|
21
|
-
- lib/travis/encrypt.rb
|
22
|
-
- lib/travis/encrypt/common.rb
|
19
|
+
- lib/travis/encrypt/base.rb
|
23
20
|
- lib/travis/encrypt/decryptor.rb
|
24
21
|
- lib/travis/encrypt/encryptor.rb
|
25
|
-
- lib/travis/encrypt/helpers.rb
|
26
22
|
- lib/travis/encrypt/helpers/active_record.rb
|
27
23
|
- lib/travis/encrypt/helpers/common.rb
|
28
24
|
- lib/travis/encrypt/helpers/sequel.rb
|
25
|
+
- lib/travis/encrypt/helpers.rb
|
29
26
|
- lib/travis/encrypt/version.rb
|
27
|
+
- lib/travis/encrypt.rb
|
30
28
|
- spec/encrypt_spec.rb
|
31
29
|
- spec/helpers_spec.rb
|
32
30
|
- spec/spec_helper.rb
|
33
|
-
-
|
31
|
+
- Gemfile
|
32
|
+
- README.md
|
34
33
|
homepage: https://github.com/travis-ci/travis-encrypt
|
35
34
|
licenses:
|
36
35
|
- MIT
|
@@ -41,19 +40,18 @@ require_paths:
|
|
41
40
|
- lib
|
42
41
|
required_ruby_version: !ruby/object:Gem::Requirement
|
43
42
|
requirements:
|
44
|
-
- -
|
43
|
+
- - '>='
|
45
44
|
- !ruby/object:Gem::Version
|
46
45
|
version: '0'
|
47
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
47
|
requirements:
|
49
|
-
- -
|
48
|
+
- - '>='
|
50
49
|
- !ruby/object:Gem::Version
|
51
50
|
version: '0'
|
52
51
|
requirements: []
|
53
52
|
rubyforge_project:
|
54
|
-
rubygems_version: 2.
|
53
|
+
rubygems_version: 2.0.14.1
|
55
54
|
signing_key:
|
56
55
|
specification_version: 4
|
57
56
|
summary: Travis CI encryption support
|
58
57
|
test_files: []
|
59
|
-
has_rdoc:
|
data/Gemfile.lock
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
diff-lcs (1.2.5)
|
5
|
-
rspec (3.3.0)
|
6
|
-
rspec-core (~> 3.3.0)
|
7
|
-
rspec-expectations (~> 3.3.0)
|
8
|
-
rspec-mocks (~> 3.3.0)
|
9
|
-
rspec-core (3.3.2)
|
10
|
-
rspec-support (~> 3.3.0)
|
11
|
-
rspec-expectations (3.3.1)
|
12
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
13
|
-
rspec-support (~> 3.3.0)
|
14
|
-
rspec-mocks (3.3.2)
|
15
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
16
|
-
rspec-support (~> 3.3.0)
|
17
|
-
rspec-support (3.3.0)
|
18
|
-
|
19
|
-
PLATFORMS
|
20
|
-
ruby
|
21
|
-
|
22
|
-
DEPENDENCIES
|
23
|
-
rspec
|
data/travis-encrypt.gemspec
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
$:.unshift File.expand_path('../lib', __FILE__)
|
4
|
-
require 'travis/encrypt/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = "travis-encrypt"
|
8
|
-
s.version = Travis::Encrypt::VERSION
|
9
|
-
s.authors = ["Travis CI"]
|
10
|
-
s.email = "contact@travis-ci.org"
|
11
|
-
s.homepage = "https://github.com/travis-ci/travis-encrypt"
|
12
|
-
s.summary = "Travis CI encryption support"
|
13
|
-
s.description = "#{s.summary}."
|
14
|
-
s.license = "MIT"
|
15
|
-
|
16
|
-
s.files = Dir['{bin/**/*,lib/**/*,spec/**/*,[A-Z]*}']
|
17
|
-
s.platform = Gem::Platform::RUBY
|
18
|
-
s.require_path = 'lib'
|
19
|
-
end
|