active_record-pgcrypto 0.2.0 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -11
- data/lib/active_record/pgcrypto.rb +4 -2
- data/lib/active_record/pgcrypto/log_subscriber.rb +2 -0
- data/lib/active_record/pgcrypto/patches.rb +23 -0
- data/lib/active_record/pgcrypto/symmetric_coder.rb +27 -12
- data/lib/active_record/pgcrypto/version.rb +1 -1
- data/spec/active_record/pgcrypto/log_subscriber_spec.rb +24 -0
- data/spec/active_record/pgcrypto/symmetric_coder_spec.rb +36 -0
- data/spec/dummy.rb +27 -0
- data/spec/integration/model_spec.rb +32 -0
- data/spec/spec_helper.rb +22 -0
- metadata +11 -15
- data/.github/main.workflow +0 -18
- data/.gitignore +0 -11
- data/.rubocop.yml +0 -47
- data/.yardstick.yml +0 -29
- data/CODE_OF_CONDUCT.md +0 -74
- data/Dockerfile +0 -17
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -92
- data/Rakefile +0 -23
- data/active_record-pgcrypto.gemspec +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 720cc8894659947200a913bee9a2757ddb9b31f993dd5a710d0a4dba781c3f95
|
4
|
+
data.tar.gz: e4309d8fe0032d489a205158bd37768cc867aaa8adf8e0999ffbf20ee32082bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 146fbaa31f74481b715ae9dec906bf5f556ad23881a5c0a7d8510cd5869500104ad4d211b0c273499f60aa9d6c9e5a12c24a7e1da1c4a6dd7c7294494b585d9d
|
7
|
+
data.tar.gz: 7e534fd989099428241b88f64822c55b75f8e6a2e7a923c03f002c4353dd76b0dfbc34be8d108f29f883911c2598af9074122d87b9002937c717003c3043f231
|
data/README.md
CHANGED
@@ -71,15 +71,16 @@ class MyModel < ActiveRecord::Base
|
|
71
71
|
end
|
72
72
|
```
|
73
73
|
|
74
|
-
The coder provides a simple API to help you provide search support by
|
75
|
-
Arel API:
|
74
|
+
The coder provides a simple API to help you provide search support by
|
75
|
+
leveraging the Arel API:
|
76
76
|
|
77
77
|
```ruby
|
78
78
|
class MyModel < ActiveRecord::Base
|
79
79
|
serialize(:email, ActiveRecord::PGCrypto::SymmetricCoder)
|
80
80
|
|
81
81
|
def self.decrypted_email
|
82
|
-
ActiveRecord::PGCrypto::SymmetricCoder
|
82
|
+
ActiveRecord::PGCrypto::SymmetricCoder
|
83
|
+
.decrypted_arel_text(arel_table[:email])
|
83
84
|
end
|
84
85
|
end
|
85
86
|
```
|
@@ -87,21 +88,23 @@ end
|
|
87
88
|
Now you can use add it to your `ActiveRecord::Base#where` queries:
|
88
89
|
|
89
90
|
```ruby
|
90
|
-
MyModel.where(MyModel.decrypted_email.
|
91
|
+
MyModel.where(MyModel.decrypted_email.matches('keyword%'))
|
91
92
|
```
|
92
93
|
|
93
94
|
## Development
|
94
95
|
|
95
|
-
|
96
|
+
Build the Docker image first:
|
96
97
|
|
97
|
-
|
98
|
+
```
|
99
|
+
docker build -f Dockerfile -t active_record-pgcrypto/ci ./`
|
100
|
+
```
|
101
|
+
|
102
|
+
Now you can run the tests:
|
98
103
|
|
99
|
-
|
104
|
+
```
|
105
|
+
docker run -v `pwd`:/gem -it active_record-pgcrypto/ci
|
106
|
+
```
|
100
107
|
|
101
|
-
To release a new version, update the version number in `version.rb`, and then
|
102
|
-
run `bundle exec rake release`, which will create a git tag for the version,
|
103
|
-
push git commits and tags, and push the `.gem` file to
|
104
|
-
[rubygems.org](https://rubygems.org).
|
105
108
|
|
106
109
|
## Contributing
|
107
110
|
|
@@ -1,5 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'active_support'
|
2
2
|
require 'active_record/log_subscriber'
|
3
|
+
require 'active_record/pgcrypto/version'
|
4
|
+
require 'active_record/pgcrypto/patches'
|
3
5
|
require 'active_record/pgcrypto/symmetric_coder'
|
4
6
|
require 'active_record/pgcrypto/log_subscriber'
|
5
7
|
|
@@ -10,7 +12,7 @@ module ActiveRecord
|
|
10
12
|
#
|
11
13
|
# @return [NilClass]
|
12
14
|
def self.enable_log_subscriber!
|
13
|
-
ActiveRecord::LogSubscriber.prepend(
|
15
|
+
::ActiveRecord::LogSubscriber.prepend(LogSubscriber)
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
@@ -2,8 +2,10 @@ module ActiveRecord
|
|
2
2
|
module PGCrypto
|
3
3
|
# Subscribes to the logger and obfuscates the sensitive queries.
|
4
4
|
module LogSubscriber
|
5
|
+
# rubocop:disable Lint/MixedRegexpCaptureTypes
|
5
6
|
REGEXP = \
|
6
7
|
/(\(*)(?<operation>pgp_sym_(decrypt|encrypt)_bytea)(\(+.*\)+)/im.freeze
|
8
|
+
# rubocop:enable Lint/MixedRegexpCaptureTypes
|
7
9
|
PLACEHOLDER = '[FILTERED]'.freeze
|
8
10
|
|
9
11
|
# Scrubs the log event from any sensitive SQL
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'active_record/type/serialized'
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
# ...
|
5
|
+
module PGCrypto
|
6
|
+
# Patched `serialize` wrapper class to play well with [ActiveModel::Dirty]
|
7
|
+
module PatchedSerialized
|
8
|
+
# Determines whether the mutable value has been modified since it was read
|
9
|
+
#
|
10
|
+
# Since encrypted binary data, from our coder,
|
11
|
+
# can return same decrypted values, we don't check it.
|
12
|
+
#
|
13
|
+
# @return [FalseClass] on our coder values.
|
14
|
+
def changed_in_place?(*args, **kwargs)
|
15
|
+
return false if coder == ActiveRecord::PGCrypto::SymmetricCoder
|
16
|
+
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
ActiveRecord::Type::Serialized.prepend(PatchedSerialized)
|
22
|
+
end
|
23
|
+
end
|
@@ -2,17 +2,15 @@ module ActiveRecord
|
|
2
2
|
module PGCrypto
|
3
3
|
# PGCrypto symmetric encryption/decryption coder for attribute serialization
|
4
4
|
module SymmetricCoder
|
5
|
-
mattr_accessor :pgcrypto_key
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
default: Encoding.find(ENV['PGCRYPTO_ENCODING'] || 'utf-8')
|
15
|
-
)
|
5
|
+
mattr_accessor :pgcrypto_key do
|
6
|
+
ENV['PGCRYPTO_SYM_KEY']
|
7
|
+
end
|
8
|
+
mattr_accessor :pgcrypto_options do
|
9
|
+
ENV['PGCRYPTO_SYM_OPTIONS'] || 'cipher-algo=aes256, unicode-mode=1'
|
10
|
+
end
|
11
|
+
mattr_accessor :pgcrypto_encoding do
|
12
|
+
Encoding.find(ENV['PGCRYPTO_ENCODING'] || 'utf-8')
|
13
|
+
end
|
16
14
|
|
17
15
|
# Decrypts the requested value
|
18
16
|
#
|
@@ -57,6 +55,18 @@ module ActiveRecord
|
|
57
55
|
)
|
58
56
|
end
|
59
57
|
|
58
|
+
# Wraps a node for decryption and text encoded calls
|
59
|
+
#
|
60
|
+
# @return [Arel::Node]
|
61
|
+
def self.decrypted_arel_text(node)
|
62
|
+
Arel::Nodes::NamedFunction.new(
|
63
|
+
'ENCODE', [
|
64
|
+
decrypted_arel(node),
|
65
|
+
Arel::Nodes::Quoted.new('escape')
|
66
|
+
]
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
60
70
|
# Wraps the value into an [Arel::Node] with SQL calls for decryption
|
61
71
|
#
|
62
72
|
# @return [Arel::Node]
|
@@ -73,8 +83,13 @@ module ActiveRecord
|
|
73
83
|
#
|
74
84
|
# @return [String] the first returned value
|
75
85
|
def self.arel_query(arel_nodes)
|
76
|
-
|
86
|
+
sel_manager = Arel::SelectManager.new(nil)
|
87
|
+
|
88
|
+
if ::ActiveRecord::VERSION::MAJOR == 4
|
89
|
+
sel_manager = Arel::SelectManager.new(::ActiveRecord::Base)
|
90
|
+
end
|
77
91
|
|
92
|
+
query = sel_manager.project(arel_nodes).to_sql
|
78
93
|
::ActiveRecord::Base.connection.select_value(query)
|
79
94
|
end
|
80
95
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'active_record/pgcrypto/log_subscriber'
|
3
|
+
|
4
|
+
RSpec.describe ActiveRecord::PGCrypto::LogSubscriber do
|
5
|
+
let(:pgcrypto_key) { FFaker::Internet.password }
|
6
|
+
let(:subscriber) { ActiveRecord::LogSubscriber.new }
|
7
|
+
let(:event_payload) do
|
8
|
+
{ sql: "SELECT PGP_SYM_ENCRYPT_BYTEA('data', '#{pgcrypto_key}')" }
|
9
|
+
end
|
10
|
+
let(:event) do
|
11
|
+
ActiveSupport::Notifications::Event.new(:test, 0, 0, :id, event_payload)
|
12
|
+
end
|
13
|
+
|
14
|
+
before do
|
15
|
+
ActiveRecord::PGCrypto.enable_log_subscriber!
|
16
|
+
end
|
17
|
+
|
18
|
+
it do
|
19
|
+
subscriber.sql(event)
|
20
|
+
|
21
|
+
expect(event.payload[:sql]).not_to include(pgcrypto_key)
|
22
|
+
expect(event.payload[:sql]).to include(described_class::PLACEHOLDER)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'active_record/pgcrypto/symmetric_coder'
|
3
|
+
|
4
|
+
RSpec.describe ActiveRecord::PGCrypto::SymmetricCoder do
|
5
|
+
let(:pgcrypto_key) { FFaker::Internet.password }
|
6
|
+
let(:text) { '€n©őđ3Đ' }
|
7
|
+
let(:numeric) { rand(1.0..5.0) }
|
8
|
+
|
9
|
+
before do
|
10
|
+
described_class.pgcrypto_key = pgcrypto_key
|
11
|
+
end
|
12
|
+
|
13
|
+
it { expect(described_class.pgcrypto_key).to eq(pgcrypto_key) }
|
14
|
+
|
15
|
+
context 'with encrypted text' do
|
16
|
+
it { expect(described_class.dump(text)).not_to eq(text) }
|
17
|
+
|
18
|
+
it { expect(described_class.dump(text)).not_to be_blank }
|
19
|
+
|
20
|
+
it do
|
21
|
+
expect(described_class.load(described_class.dump(text))).to eq(text)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with encrypted numeric' do
|
26
|
+
it { expect(described_class.dump(numeric)).not_to eq(numeric.to_s) }
|
27
|
+
|
28
|
+
it { expect(described_class.dump(numeric)).not_to be_blank }
|
29
|
+
|
30
|
+
it do
|
31
|
+
expect(
|
32
|
+
described_class.load(described_class.dump(numeric))
|
33
|
+
).to eq(numeric.to_s)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/dummy.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
ActiveRecord::Base.logger = Logger.new($stdout)
|
5
|
+
ActiveRecord::Base.logger.level = ENV['LOG_LEVEL'] || Logger::WARN
|
6
|
+
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
|
7
|
+
|
8
|
+
ActiveRecord::Schema.define do
|
9
|
+
enable_extension 'pgcrypto'
|
10
|
+
|
11
|
+
create_table :users, force: true do |t|
|
12
|
+
t.binary :email
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# Enable PGCrypto Symmetric encryption support.
|
17
|
+
ENV['PGCRYPTO_SYM_KEY'] = SecureRandom.hex(10)
|
18
|
+
require 'active_record/pgcrypto'
|
19
|
+
|
20
|
+
class User < ActiveRecord::Base
|
21
|
+
serialize(:email, ActiveRecord::PGCrypto::SymmetricCoder)
|
22
|
+
|
23
|
+
def self.decrypted_email
|
24
|
+
ActiveRecord::PGCrypto::SymmetricCoder
|
25
|
+
.decrypted_arel_text(arel_table[:email])
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
RSpec.describe User do
|
5
|
+
let(:good_user) { User.create!(email: FFaker::Internet.email) }
|
6
|
+
let(:bad_user) { User.create!(email: FFaker::Internet.email) }
|
7
|
+
|
8
|
+
it 'finds the searched user' do
|
9
|
+
expect(good_user.email).not_to eq(bad_user.email)
|
10
|
+
|
11
|
+
filtered = User.where(
|
12
|
+
User.decrypted_email.matches("#{good_user.email.first(4)}%")
|
13
|
+
)
|
14
|
+
|
15
|
+
expect(filtered.count).to eq(1)
|
16
|
+
expect(filtered.first).to eq(good_user)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'stays unchanged' do
|
20
|
+
good_user.reload
|
21
|
+
expect(good_user).not_to be_changed
|
22
|
+
|
23
|
+
good_user.email = good_user.reload.email
|
24
|
+
expect(good_user).not_to be_changed
|
25
|
+
|
26
|
+
good_user.email = FFaker::Internet.email
|
27
|
+
expect(good_user).to be_changed
|
28
|
+
|
29
|
+
good_user.reload
|
30
|
+
expect(good_user).not_to be_changed
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'simplecov'
|
3
|
+
|
4
|
+
SimpleCov.start do
|
5
|
+
add_group 'Lib', 'lib'
|
6
|
+
add_group 'Tests', 'spec'
|
7
|
+
end
|
8
|
+
SimpleCov.minimum_coverage 90
|
9
|
+
|
10
|
+
require 'dummy'
|
11
|
+
require 'ffaker'
|
12
|
+
require 'rspec'
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.mock_with :rspec
|
16
|
+
config.filter_run_when_matching :focus
|
17
|
+
config.disable_monkey_patching!
|
18
|
+
|
19
|
+
config.expect_with :rspec do |c|
|
20
|
+
c.syntax = :expect
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record-pgcrypto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stas SUȘCOV
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,22 +157,18 @@ executables: []
|
|
157
157
|
extensions: []
|
158
158
|
extra_rdoc_files: []
|
159
159
|
files:
|
160
|
-
- ".github/main.workflow"
|
161
|
-
- ".gitignore"
|
162
|
-
- ".rubocop.yml"
|
163
|
-
- ".yardstick.yml"
|
164
|
-
- CODE_OF_CONDUCT.md
|
165
|
-
- Dockerfile
|
166
|
-
- Gemfile
|
167
|
-
- Gemfile.lock
|
168
160
|
- LICENSE.txt
|
169
161
|
- README.md
|
170
|
-
- Rakefile
|
171
|
-
- active_record-pgcrypto.gemspec
|
172
162
|
- lib/active_record/pgcrypto.rb
|
173
163
|
- lib/active_record/pgcrypto/log_subscriber.rb
|
164
|
+
- lib/active_record/pgcrypto/patches.rb
|
174
165
|
- lib/active_record/pgcrypto/symmetric_coder.rb
|
175
166
|
- lib/active_record/pgcrypto/version.rb
|
167
|
+
- spec/active_record/pgcrypto/log_subscriber_spec.rb
|
168
|
+
- spec/active_record/pgcrypto/symmetric_coder_spec.rb
|
169
|
+
- spec/dummy.rb
|
170
|
+
- spec/integration/model_spec.rb
|
171
|
+
- spec/spec_helper.rb
|
176
172
|
homepage: https://github.com/stas/active_record-pgcrypto
|
177
173
|
licenses:
|
178
174
|
- MIT
|
@@ -192,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
188
|
- !ruby/object:Gem::Version
|
193
189
|
version: '0'
|
194
190
|
requirements: []
|
195
|
-
rubygems_version: 3.
|
191
|
+
rubygems_version: 3.2.3
|
196
192
|
signing_key:
|
197
193
|
specification_version: 4
|
198
194
|
summary: PGCrypto for ActiveRecord
|
data/.github/main.workflow
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
workflow "Docs/Tests" {
|
2
|
-
on = "push"
|
3
|
-
resolves = [
|
4
|
-
"Builds the Docker image",
|
5
|
-
"Runs the linters and tests"
|
6
|
-
]
|
7
|
-
}
|
8
|
-
|
9
|
-
action "Builds the Docker image" {
|
10
|
-
uses = "actions/docker/cli@master"
|
11
|
-
args = "build -f Dockerfile -t active_record-pgcrypto/ci:$GITHUB_SHA ."
|
12
|
-
}
|
13
|
-
|
14
|
-
action "Runs the linters and tests" {
|
15
|
-
uses = "actions/docker/cli@master"
|
16
|
-
needs = ["Builds the Docker image"]
|
17
|
-
args = "run active_record-pgcrypto/ci:$GITHUB_SHA"
|
18
|
-
}
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require:
|
2
|
-
- rubocop-performance
|
3
|
-
- rubocop-rspec
|
4
|
-
|
5
|
-
RSpec:
|
6
|
-
Enabled: true
|
7
|
-
|
8
|
-
RSpec/MultipleExpectations:
|
9
|
-
Enabled: false
|
10
|
-
|
11
|
-
Performance:
|
12
|
-
Enabled: true
|
13
|
-
|
14
|
-
Bundler:
|
15
|
-
Enabled: true
|
16
|
-
|
17
|
-
Gemspec:
|
18
|
-
Enabled: true
|
19
|
-
|
20
|
-
Style/StringLiterals:
|
21
|
-
Enabled: true
|
22
|
-
EnforcedStyle: single_quotes
|
23
|
-
|
24
|
-
Style/FrozenStringLiteralComment:
|
25
|
-
Enabled: false
|
26
|
-
|
27
|
-
Metrics/LineLength:
|
28
|
-
Max: 80
|
29
|
-
|
30
|
-
Metrics/BlockLength:
|
31
|
-
Exclude:
|
32
|
-
- 'spec/**/*_spec.rb'
|
33
|
-
- '**/*.gemspec'
|
34
|
-
|
35
|
-
Layout/IndentationConsistency:
|
36
|
-
EnforcedStyle: normal
|
37
|
-
|
38
|
-
Style/BlockDelimiters:
|
39
|
-
Enabled: true
|
40
|
-
|
41
|
-
RSpec/FilePath:
|
42
|
-
Exclude:
|
43
|
-
- 'spec/**/*_spec.rb'
|
44
|
-
|
45
|
-
RSpec/DescribedClass:
|
46
|
-
Exclude:
|
47
|
-
- 'spec/integration/*_spec.rb'
|
data/.yardstick.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
---
|
2
|
-
path: ['lib/**/*.rb']
|
3
|
-
threshold: 100
|
4
|
-
rules:
|
5
|
-
ApiTag::Presence:
|
6
|
-
enabled: false
|
7
|
-
ApiTag::Inclusion:
|
8
|
-
enabled: false
|
9
|
-
ApiTag::ProtectedMethod:
|
10
|
-
enabled: false
|
11
|
-
ApiTag::PrivateMethod:
|
12
|
-
enabled: false
|
13
|
-
ExampleTag:
|
14
|
-
enabled: false
|
15
|
-
ReturnTag:
|
16
|
-
enabled: true
|
17
|
-
exclude: []
|
18
|
-
Summary::Presence:
|
19
|
-
enabled: true
|
20
|
-
exclude: []
|
21
|
-
Summary::Length:
|
22
|
-
enabled: true
|
23
|
-
exclude: []
|
24
|
-
Summary::Delimiter:
|
25
|
-
enabled: true
|
26
|
-
exclude: []
|
27
|
-
Summary::SingleLine:
|
28
|
-
enabled: true
|
29
|
-
exclude: []
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at stas@nerd.ro. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: http://contributor-covenant.org
|
74
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
data/Dockerfile
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
FROM postgres:10.5-alpine
|
2
|
-
|
3
|
-
RUN apk add --no-cache git build-base ruby ruby-full ruby-dev
|
4
|
-
|
5
|
-
RUN gem install -q --no-ri --no-rdoc -v '~> 1' bundler
|
6
|
-
|
7
|
-
RUN mkdir /gem
|
8
|
-
WORKDIR /gem
|
9
|
-
|
10
|
-
COPY ./ ./
|
11
|
-
RUN bundle install --no-cache
|
12
|
-
|
13
|
-
ENV DATABASE_URL=postgresql://postgres@localhost/postgres?pool=5
|
14
|
-
|
15
|
-
ENTRYPOINT []
|
16
|
-
|
17
|
-
CMD ["sh", "-c", "(nohup /docker-entrypoint.sh postgres > /dev/null &) && sleep 3 && bundle exec rake"]
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
active_record-pgcrypto (0.1.1)
|
5
|
-
activerecord
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
activemodel (5.2.3)
|
11
|
-
activesupport (= 5.2.3)
|
12
|
-
activerecord (5.2.3)
|
13
|
-
activemodel (= 5.2.3)
|
14
|
-
activesupport (= 5.2.3)
|
15
|
-
arel (>= 9.0)
|
16
|
-
activesupport (5.2.3)
|
17
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
-
i18n (>= 0.7, < 2)
|
19
|
-
minitest (~> 5.1)
|
20
|
-
tzinfo (~> 1.1)
|
21
|
-
arel (9.0.0)
|
22
|
-
ast (2.4.0)
|
23
|
-
concurrent-ruby (1.1.5)
|
24
|
-
diff-lcs (1.3)
|
25
|
-
docile (1.3.2)
|
26
|
-
ffaker (2.11.0)
|
27
|
-
i18n (1.6.0)
|
28
|
-
concurrent-ruby (~> 1.0)
|
29
|
-
jaro_winkler (1.5.3)
|
30
|
-
json (2.2.0)
|
31
|
-
minitest (5.11.3)
|
32
|
-
parallel (1.17.0)
|
33
|
-
parser (2.6.3.0)
|
34
|
-
ast (~> 2.4.0)
|
35
|
-
pg (1.1.4)
|
36
|
-
rainbow (3.0.0)
|
37
|
-
rake (12.3.2)
|
38
|
-
rspec (3.8.0)
|
39
|
-
rspec-core (~> 3.8.0)
|
40
|
-
rspec-expectations (~> 3.8.0)
|
41
|
-
rspec-mocks (~> 3.8.0)
|
42
|
-
rspec-core (3.8.2)
|
43
|
-
rspec-support (~> 3.8.0)
|
44
|
-
rspec-expectations (3.8.4)
|
45
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
-
rspec-support (~> 3.8.0)
|
47
|
-
rspec-mocks (3.8.1)
|
48
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
-
rspec-support (~> 3.8.0)
|
50
|
-
rspec-support (3.8.2)
|
51
|
-
rubocop (0.72.0)
|
52
|
-
jaro_winkler (~> 1.5.1)
|
53
|
-
parallel (~> 1.10)
|
54
|
-
parser (>= 2.6)
|
55
|
-
rainbow (>= 2.2.2, < 4.0)
|
56
|
-
ruby-progressbar (~> 1.7)
|
57
|
-
unicode-display_width (>= 1.4.0, < 1.7)
|
58
|
-
rubocop-performance (1.4.0)
|
59
|
-
rubocop (>= 0.71.0)
|
60
|
-
rubocop-rspec (1.33.0)
|
61
|
-
rubocop (>= 0.60.0)
|
62
|
-
ruby-progressbar (1.10.1)
|
63
|
-
simplecov (0.17.0)
|
64
|
-
docile (~> 1.1)
|
65
|
-
json (>= 1.8, < 3)
|
66
|
-
simplecov-html (~> 0.10.0)
|
67
|
-
simplecov-html (0.10.2)
|
68
|
-
thread_safe (0.3.6)
|
69
|
-
tzinfo (1.2.5)
|
70
|
-
thread_safe (~> 0.1)
|
71
|
-
unicode-display_width (1.6.0)
|
72
|
-
yard (0.9.20)
|
73
|
-
yardstick (0.9.9)
|
74
|
-
yard (~> 0.8, >= 0.8.7.2)
|
75
|
-
|
76
|
-
PLATFORMS
|
77
|
-
ruby
|
78
|
-
|
79
|
-
DEPENDENCIES
|
80
|
-
active_record-pgcrypto!
|
81
|
-
bundler
|
82
|
-
ffaker
|
83
|
-
pg
|
84
|
-
rake
|
85
|
-
rspec
|
86
|
-
rubocop-performance
|
87
|
-
rubocop-rspec
|
88
|
-
simplecov
|
89
|
-
yardstick
|
90
|
-
|
91
|
-
BUNDLED WITH
|
92
|
-
1.17.2
|
data/Rakefile
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
2
|
-
require 'rspec/core/rake_task'
|
3
|
-
require 'rubocop/rake_task'
|
4
|
-
require 'yaml'
|
5
|
-
require 'yardstick/rake/verify'
|
6
|
-
|
7
|
-
desc('Documentation stats and measurements')
|
8
|
-
task('qa:docs') do
|
9
|
-
yaml = YAML.load_file('.yardstick.yml')
|
10
|
-
config = Yardstick::Config.coerce(yaml)
|
11
|
-
measure = Yardstick.measure(config)
|
12
|
-
measure.puts
|
13
|
-
coverage = Yardstick.round_percentage(measure.coverage * 100)
|
14
|
-
exit(1) if coverage < config.threshold
|
15
|
-
end
|
16
|
-
|
17
|
-
RuboCop::RakeTask.new('qa:code')
|
18
|
-
|
19
|
-
desc('Run QA tasks')
|
20
|
-
task(qa: ['qa:docs', 'qa:code'])
|
21
|
-
|
22
|
-
RSpec::Core::RakeTask.new(spec: :qa)
|
23
|
-
task(default: :spec)
|
@@ -1,33 +0,0 @@
|
|
1
|
-
lib = File.expand_path('lib', __dir__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'active_record/pgcrypto/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = 'active_record-pgcrypto'
|
7
|
-
spec.version = ActiveRecord::PGCrypto::VERSION
|
8
|
-
spec.authors = ['Stas SUȘCOV']
|
9
|
-
spec.email = ['stas@nerd.ro']
|
10
|
-
|
11
|
-
spec.summary = 'PGCrypto for ActiveRecord'
|
12
|
-
spec.description = 'PostgreSQL PGCrypto support for ActiveRecord models.'
|
13
|
-
spec.homepage = 'https://github.com/stas/active_record-pgcrypto'
|
14
|
-
spec.license = 'MIT'
|
15
|
-
|
16
|
-
# Specify which files should be added to the gem when it is released.
|
17
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
18
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
19
|
-
end
|
20
|
-
spec.require_paths = ['lib']
|
21
|
-
|
22
|
-
spec.add_dependency 'activerecord', ENV['RAILS_VERSION']
|
23
|
-
|
24
|
-
spec.add_development_dependency 'bundler'
|
25
|
-
spec.add_development_dependency 'ffaker'
|
26
|
-
spec.add_development_dependency 'pg'
|
27
|
-
spec.add_development_dependency 'rake'
|
28
|
-
spec.add_development_dependency 'rspec'
|
29
|
-
spec.add_development_dependency 'rubocop-performance'
|
30
|
-
spec.add_development_dependency 'rubocop-rspec'
|
31
|
-
spec.add_development_dependency 'simplecov'
|
32
|
-
spec.add_development_dependency 'yardstick'
|
33
|
-
end
|