travis-encrypt 0.0.1 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cc5b08f7b744a0d65048a30fbc106574ca09020
4
- data.tar.gz: d305be5fa49e303584418c5f848f6a3a333808a7
3
+ metadata.gz: 4b4c5b90d121b7f46e33422a7627814a3cfb2625
4
+ data.tar.gz: 5a34a737000fb84382fa53b83bb010e5f2d464c4
5
5
  SHA512:
6
- metadata.gz: cd83823e74a711d52dd0e2631f32a0124a38bd6758eb39b76943b4a0f23db04ae8422637b2615f38fa606b4855679f89b1e8a59dd1f0cd24209e1983f772eda3
7
- data.tar.gz: 7daf90258525aaadabb554da5ed37702117b02e756a98065a7f6125c69ee442be9b8d08971f57195c1236f6658f75f15fc714ee9bba2f37e5c40e9cda02c09f7
6
+ metadata.gz: 72b1a0b20ec4384530d5322dffd601f14e5b658bab3a9901db98733a284b29b1b7ffe27cb73a03fad2d18d1ada711da3b7f0330d901b5f0580977d4834bb07e2
7
+ data.tar.gz: b11628cc49b98f62f90d58aa06e2e31a1a0bcaa8880a5a4546b439f0402710e557ad0cea23d839b91ef29215f19f37bda00157ea6c66ead5dc85f8ebce9b9e75
data/Gemfile CHANGED
@@ -1,6 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- ruby '2.2.2'
3
+ # ruby '2.2.2'
4
+
5
+ platform :jruby do
6
+ gem 'jruby-openssl', '~> 0.9.8', require: false
7
+ end
4
8
 
5
9
  group :test do
6
10
  gem 'rspec'
@@ -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
+ ```
@@ -1,5 +1,6 @@
1
- require 'securerandom'
2
1
  require 'base64'
2
+ require 'securerandom'
3
+ require 'openssl'
3
4
  require 'travis/encrypt/decryptor'
4
5
  require 'travis/encrypt/encryptor'
5
6
  require 'travis/encrypt/helpers'
@@ -1,7 +1,17 @@
1
1
  module Travis
2
2
  module Encrypt
3
- module Common
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/common'
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/common'
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
@@ -1,5 +1,5 @@
1
1
  module Travis
2
2
  module Encrypt
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.5'
4
4
  end
5
5
  end
@@ -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: 'abcd' * 8 } }
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.1
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: 2015-08-26 00:00:00.000000000 Z
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
- - Gemfile
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
- - travis-encrypt.gemspec
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.4.5
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:
@@ -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
@@ -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