blind_index 2.2.0 → 2.3.0

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
  SHA256:
3
- metadata.gz: 80c561a0a96707de1176ae314d4d884e03390de9b8c4e23049d3649d7576937e
4
- data.tar.gz: ea819c68b4d1a44c492799225d3250a86186cca1a355a3ab2e65a02069ae4062
3
+ metadata.gz: 89f2640c25eea46ce76f32e3f8c725744f356c1037bc719c7cf2e1ab2728a1ee
4
+ data.tar.gz: 984cf9b1d682d5662129e0ce9dee0047c3c57fbbc6d2922913bc59c0024334dc
5
5
  SHA512:
6
- metadata.gz: 44835258443127734b6940287e1768935884c86b53d90bb5c39a9a5db372b937649f81e5a6f16d9e4605cb78b19824759b019461491176cb4b2e0bfd1330858d
7
- data.tar.gz: ddeeb0f625335d49e86ab0a5ff2350a7ae8c5b74ffd0322d7504763818b05ee6c648ea0d85b395c2f197266adfcb18015b37e556d6cbee04aea32f943d0123cd
6
+ metadata.gz: 99d6f55c8664ba560ac4f7171a402eb6a18347d7be1bfb70425b8f506ba829c808a1e18fc26fda5d8eb7bb88ec7cdcce989e0aadd7e94c22cbfefc915f01150d
7
+ data.tar.gz: b9df49cf70f1e62e2bc753c0dc065c5fb236b38962cc3bdd7d15d6a7068521aaacd051ac996a9fc05018c48a32b4ca84494f268abee9900b447d3fb107416063
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 2.3.0 (2022-01-16)
2
+
3
+ - Added blind indexes to `filter_attributes`
4
+ - Dropped support for Ruby < 2.6 and Rails < 5.2
5
+
1
6
  ## 2.2.0 (2020-09-07)
2
7
 
3
8
  - Added support for `where` with table in Active Record 5.2+
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017-2020 Andrew Kane
1
+ Copyright (c) 2017-2021 Andrew Kane
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -6,7 +6,7 @@ Works with [Lockbox](https://github.com/ankane/lockbox) ([full example](https://
6
6
 
7
7
  Learn more about [securing sensitive data in Rails](https://ankane.org/sensitive-data-rails)
8
8
 
9
- [![Build Status](https://travis-ci.org/ankane/blind_index.svg?branch=master)](https://travis-ci.org/ankane/blind_index)
9
+ [![Build Status](https://github.com/ankane/blind_index/workflows/build/badge.svg?branch=master)](https://github.com/ankane/blind_index/actions)
10
10
 
11
11
  ## How It Works
12
12
 
@@ -262,6 +262,7 @@ For Mongoid, use:
262
262
  ```ruby
263
263
  class User
264
264
  field :email_bidx, type: String
265
+ index({email_bidx: 1})
265
266
  end
266
267
  ```
267
268
 
@@ -1,26 +1,6 @@
1
1
  module BlindIndex
2
2
  module Extensions
3
3
  module TableMetadata
4
- if ActiveRecord::VERSION::STRING.to_f < 5.2
5
- def resolve_column_aliases(hash)
6
- new_hash = super
7
- if has_blind_indexes?
8
- hash.each_key do |key|
9
- if key.respond_to?(:to_sym) && (bi = klass.blind_indexes[key.to_sym]) && !new_hash[key].is_a?(ActiveRecord::StatementCache::Substitute)
10
- value = new_hash.delete(key)
11
- new_hash[bi[:bidx_attribute]] =
12
- if value.is_a?(Array)
13
- value.map { |v| BlindIndex.generate_bidx(v, **bi) }
14
- else
15
- BlindIndex.generate_bidx(value, **bi)
16
- end
17
- end
18
- end
19
- end
20
- new_hash
21
- end
22
- end
23
-
24
4
  # memoize for performance
25
5
  def has_blind_indexes?
26
6
  unless defined?(@has_blind_indexes)
@@ -57,20 +37,11 @@ module BlindIndex
57
37
  end
58
38
 
59
39
  # change attribute name here instead of validate_each for better error message
60
- if ActiveRecord::VERSION::STRING.to_f >= 5.2
61
- def build_relation(klass, attribute, value)
62
- if klass.respond_to?(:blind_indexes) && (bi = klass.blind_indexes[attribute])
63
- attribute = bi[:bidx_attribute]
64
- end
65
- super(klass, attribute, value)
66
- end
67
- else
68
- def build_relation(klass, table, attribute, value)
69
- if klass.respond_to?(:blind_indexes) && (bi = klass.blind_indexes[attribute])
70
- attribute = bi[:bidx_attribute]
71
- end
72
- super(klass, table, attribute, value)
40
+ def build_relation(klass, attribute, value)
41
+ if klass.respond_to?(:blind_indexes) && (bi = klass.blind_indexes[attribute])
42
+ attribute = bi[:bidx_attribute]
73
43
  end
44
+ super(klass, attribute, value)
74
45
  end
75
46
  end
76
47
 
@@ -36,6 +36,14 @@ module BlindIndex
36
36
  key ||= -> { BlindIndex.index_key(table: try(:table_name) || collection_name.to_s, bidx_attribute: bidx_attribute, master_key: options[:master_key], encode: false) }
37
37
 
38
38
  class_eval do
39
+ activerecord = defined?(ActiveRecord) && self < ActiveRecord::Base
40
+
41
+ if activerecord && ActiveRecord::VERSION::MAJOR >= 6
42
+ # blind index value isn't really sensitive
43
+ # but don't need to show it in the Rails console
44
+ self.filter_attributes += [/\A#{Regexp.escape(bidx_attribute)}\z/]
45
+ end
46
+
39
47
  @blind_indexes ||= {}
40
48
 
41
49
  unless respond_to?(:blind_indexes)
@@ -69,8 +77,6 @@ module BlindIndex
69
77
  end
70
78
 
71
79
  if callback
72
- activerecord = defined?(ActiveRecord) && self < ActiveRecord::Base
73
-
74
80
  # TODO reuse module
75
81
  m = Module.new do
76
82
  define_method "#{attribute}=" do |value|
@@ -1,3 +1,3 @@
1
1
  module BlindIndex
2
- VERSION = "2.2.0"
2
+ VERSION = "2.3.0"
3
3
  end
data/lib/blind_index.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  # dependencies
2
2
  require "active_support"
3
- require "openssl"
4
3
  require "argon2/kdf"
5
4
 
5
+ # stdlib
6
+ require "openssl"
7
+
6
8
  # modules
7
9
  require "blind_index/backfill"
8
10
  require "blind_index/key_generator"
@@ -140,14 +142,8 @@ ActiveSupport.on_load(:active_record) do
140
142
 
141
143
  ActiveRecord::TableMetadata.prepend(BlindIndex::Extensions::TableMetadata)
142
144
  ActiveRecord::DynamicMatchers::Method.prepend(BlindIndex::Extensions::DynamicMatchers)
143
-
144
- unless ActiveRecord::VERSION::STRING.to_f == 5.1
145
- ActiveRecord::Validations::UniquenessValidator.prepend(BlindIndex::Extensions::UniquenessValidator)
146
- end
147
-
148
- if ActiveRecord::VERSION::STRING.to_f >= 5.2
149
- ActiveRecord::PredicateBuilder.prepend(BlindIndex::Extensions::PredicateBuilder)
150
- end
145
+ ActiveRecord::Validations::UniquenessValidator.prepend(BlindIndex::Extensions::UniquenessValidator)
146
+ ActiveRecord::PredicateBuilder.prepend(BlindIndex::Extensions::PredicateBuilder)
151
147
  end
152
148
 
153
149
  ActiveSupport.on_load(:mongoid) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blind_index
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-08 00:00:00.000000000 Z
11
+ date: 2022-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
19
+ version: '5.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: '5'
26
+ version: '5.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: argon2-kdf
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,134 +38,8 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.1.1
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: minitest
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: attr_encrypted
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: activerecord
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: sqlite3
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: scrypt
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: benchmark-ips
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: lockbox
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0.2'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0.2'
167
- description:
168
- email: andrew@chartkick.com
41
+ description:
42
+ email: andrew@ankane.org
169
43
  executables: []
170
44
  extensions: []
171
45
  extra_rdoc_files: []
@@ -184,7 +58,7 @@ homepage: https://github.com/ankane/blind_index
184
58
  licenses:
185
59
  - MIT
186
60
  metadata: {}
187
- post_install_message:
61
+ post_install_message:
188
62
  rdoc_options: []
189
63
  require_paths:
190
64
  - lib
@@ -192,15 +66,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
192
66
  requirements:
193
67
  - - ">="
194
68
  - !ruby/object:Gem::Version
195
- version: '2.4'
69
+ version: '2.6'
196
70
  required_rubygems_version: !ruby/object:Gem::Requirement
197
71
  requirements:
198
72
  - - ">="
199
73
  - !ruby/object:Gem::Version
200
74
  version: '0'
201
75
  requirements: []
202
- rubygems_version: 3.1.2
203
- signing_key:
76
+ rubygems_version: 3.3.3
77
+ signing_key:
204
78
  specification_version: 4
205
79
  summary: Securely search encrypted database fields
206
80
  test_files: []