active_record-pgcrypto 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +16 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +17 -0
- data/.github/workflows/ci.yml +32 -5
- data/.gitignore +1 -0
- data/Dockerfile +1 -1
- data/README.md +14 -11
- data/lib/active_record/pgcrypto/symmetric_coder.rb +12 -0
- data/lib/active_record/pgcrypto/version.rb +1 -1
- metadata +4 -3
- data/Gemfile.lock +0 -92
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6225d8f7dd8ecd182236f45d3a9d68884207891563ae550c03f0b3038e3a31d4
|
4
|
+
data.tar.gz: 21543ff3b8587257c94acd367e4e40dbbbd484c2030e231eaefd03d6bf86e47a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a2bcca8231ecc1ebfe00dfdb61ef55311f736de9b6752ab2a6c8e09f4fd2a70b53df4a07c80dd7dd5509f3d32c750c20e506a361a3bbfeade1bbc22362fdad9
|
7
|
+
data.tar.gz: 0ac5f283a26ebc13f1c601fcafb02b13a6ae8c52d7f0366e33eac32a33a06189b396a6a99e3b4e54ec6bac13be3d1b43183388876e4bf998fdfdf1e3be4d8453
|
@@ -0,0 +1,17 @@
|
|
1
|
+
## What is the current behavior?
|
2
|
+
|
3
|
+
<!-- Please describe the current behavior that you are modifying, or link to a
|
4
|
+
relevant issue. -->
|
5
|
+
|
6
|
+
## What is the new behavior?
|
7
|
+
|
8
|
+
<!-- Please describe the behavior or changes that are being added here. -->
|
9
|
+
|
10
|
+
## Checklist
|
11
|
+
|
12
|
+
Please make sure the following requirements are complete:
|
13
|
+
|
14
|
+
- [ ] Tests for the changes have been added (for bug fixes / features)
|
15
|
+
- [ ] Docs have been reviewed and added / updated if needed (for bug fixes /
|
16
|
+
features)
|
17
|
+
- [ ] All automated checks pass (CI/CD)
|
data/.github/workflows/ci.yml
CHANGED
@@ -1,20 +1,47 @@
|
|
1
1
|
name: CI
|
2
2
|
|
3
|
-
on: [push]
|
3
|
+
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
|
-
|
6
|
+
ruby_rails_matrix:
|
7
7
|
runs-on: ubuntu-18.04
|
8
8
|
|
9
|
+
services:
|
10
|
+
postgres:
|
11
|
+
image: postgres:11.6
|
12
|
+
env:
|
13
|
+
POSTGRES_USER: postgres
|
14
|
+
POSTGRES_PASSWORD: postgres
|
15
|
+
POSTGRES_DB: postgres
|
16
|
+
ports:
|
17
|
+
- 5432/tcp
|
18
|
+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
19
|
+
|
9
20
|
strategy:
|
10
21
|
matrix:
|
22
|
+
ruby: [2.4, 2.7]
|
11
23
|
rails: [4, 5, 6]
|
24
|
+
exclude:
|
25
|
+
- ruby: 2.4
|
26
|
+
rails: 6
|
27
|
+
- ruby: 2.7
|
28
|
+
rails: 4
|
12
29
|
|
13
30
|
steps:
|
14
31
|
- uses: actions/checkout@master
|
15
32
|
|
16
|
-
- name:
|
17
|
-
|
33
|
+
- name: Sets up the environment
|
34
|
+
uses: actions/setup-ruby@v1
|
35
|
+
with:
|
36
|
+
ruby-version: ${{ matrix.ruby }}
|
18
37
|
|
19
38
|
- name: Runs code QA and tests
|
20
|
-
|
39
|
+
env:
|
40
|
+
RAILS_VERSION: ~> ${{ matrix.rails }}
|
41
|
+
DATABASE_URL: postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres?pool=5
|
42
|
+
run: |
|
43
|
+
rm -rf Gemfile.lock
|
44
|
+
gem uninstall bundler -a --force
|
45
|
+
gem install bundler -v '~> 1'
|
46
|
+
bundle
|
47
|
+
rake
|
data/.gitignore
CHANGED
data/Dockerfile
CHANGED
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
|
|
@@ -55,6 +55,18 @@ module ActiveRecord
|
|
55
55
|
)
|
56
56
|
end
|
57
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
|
+
|
58
70
|
# Wraps the value into an [Arel::Node] with SQL calls for decryption
|
59
71
|
#
|
60
72
|
# @return [Arel::Node]
|
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.4
|
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: 2020-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -157,6 +157,8 @@ executables: []
|
|
157
157
|
extensions: []
|
158
158
|
extra_rdoc_files: []
|
159
159
|
files:
|
160
|
+
- ".github/ISSUE_TEMPLATE.md"
|
161
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
160
162
|
- ".github/workflows/ci.yml"
|
161
163
|
- ".gitignore"
|
162
164
|
- ".rubocop.yml"
|
@@ -164,7 +166,6 @@ files:
|
|
164
166
|
- CODE_OF_CONDUCT.md
|
165
167
|
- Dockerfile
|
166
168
|
- Gemfile
|
167
|
-
- Gemfile.lock
|
168
169
|
- LICENSE.txt
|
169
170
|
- README.md
|
170
171
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
active_record-pgcrypto (0.2.3)
|
5
|
-
activerecord (>= 3.2)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
activemodel (6.0.1)
|
11
|
-
activesupport (= 6.0.1)
|
12
|
-
activerecord (6.0.1)
|
13
|
-
activemodel (= 6.0.1)
|
14
|
-
activesupport (= 6.0.1)
|
15
|
-
activesupport (6.0.1)
|
16
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
-
i18n (>= 0.7, < 2)
|
18
|
-
minitest (~> 5.1)
|
19
|
-
tzinfo (~> 1.1)
|
20
|
-
zeitwerk (~> 2.2)
|
21
|
-
ast (2.4.0)
|
22
|
-
concurrent-ruby (1.1.5)
|
23
|
-
diff-lcs (1.3)
|
24
|
-
docile (1.3.2)
|
25
|
-
ffaker (2.13.0)
|
26
|
-
i18n (1.7.0)
|
27
|
-
concurrent-ruby (~> 1.0)
|
28
|
-
jaro_winkler (1.5.4)
|
29
|
-
json (2.2.0)
|
30
|
-
minitest (5.13.0)
|
31
|
-
parallel (1.19.0)
|
32
|
-
parser (2.6.5.0)
|
33
|
-
ast (~> 2.4.0)
|
34
|
-
pg (1.1.4)
|
35
|
-
rainbow (3.0.0)
|
36
|
-
rake (13.0.1)
|
37
|
-
rspec (3.9.0)
|
38
|
-
rspec-core (~> 3.9.0)
|
39
|
-
rspec-expectations (~> 3.9.0)
|
40
|
-
rspec-mocks (~> 3.9.0)
|
41
|
-
rspec-core (3.9.0)
|
42
|
-
rspec-support (~> 3.9.0)
|
43
|
-
rspec-expectations (3.9.0)
|
44
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
-
rspec-support (~> 3.9.0)
|
46
|
-
rspec-mocks (3.9.0)
|
47
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
-
rspec-support (~> 3.9.0)
|
49
|
-
rspec-support (3.9.0)
|
50
|
-
rubocop (0.76.0)
|
51
|
-
jaro_winkler (~> 1.5.1)
|
52
|
-
parallel (~> 1.10)
|
53
|
-
parser (>= 2.6)
|
54
|
-
rainbow (>= 2.2.2, < 4.0)
|
55
|
-
ruby-progressbar (~> 1.7)
|
56
|
-
unicode-display_width (>= 1.4.0, < 1.7)
|
57
|
-
rubocop-performance (1.5.1)
|
58
|
-
rubocop (>= 0.71.0)
|
59
|
-
rubocop-rspec (1.36.0)
|
60
|
-
rubocop (>= 0.68.1)
|
61
|
-
ruby-progressbar (1.10.1)
|
62
|
-
simplecov (0.17.1)
|
63
|
-
docile (~> 1.1)
|
64
|
-
json (>= 1.8, < 3)
|
65
|
-
simplecov-html (~> 0.10.0)
|
66
|
-
simplecov-html (0.10.2)
|
67
|
-
thread_safe (0.3.6)
|
68
|
-
tzinfo (1.2.5)
|
69
|
-
thread_safe (~> 0.1)
|
70
|
-
unicode-display_width (1.6.0)
|
71
|
-
yard (0.9.20)
|
72
|
-
yardstick (0.9.9)
|
73
|
-
yard (~> 0.8, >= 0.8.7.2)
|
74
|
-
zeitwerk (2.2.1)
|
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.3
|