blind_index 2.4.0 → 2.7.0
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/CHANGELOG.md +26 -3
- data/LICENSE.txt +1 -1
- data/README.md +1 -11
- data/lib/blind_index/backfill.rb +5 -1
- data/lib/blind_index/extensions.rb +11 -3
- data/lib/blind_index/key_generator.rb +1 -0
- data/lib/blind_index/model.rb +1 -1
- data/lib/blind_index/version.rb +1 -1
- data/lib/blind_index.rb +3 -3
- metadata +8 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09a84d8781deda821fd4cb201a99f0817a0138cce41f2b8feee581fc75d7fd4d'
|
4
|
+
data.tar.gz: 257e5c5d3504e90bb2ffa90dca2cdd21c853d0a3708d64b05cf044b324506cbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4bb3008b73f2e5587d7655384380b7323b8c73303e1634f1e279c14022728ca77d1b4a4259c5afa1bfd134a0fd69c26035316ac8f3a5b3005b269be617c2de1
|
7
|
+
data.tar.gz: 164b7986d27128b8830dddf90fe4501081da58e4b8995ab2dc6cb57ae697fc33da378824bfcec0d32ae12ded0795b61d2814f45d6af65ecdbbd95179a9a6be03
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
## 2.7.0 (2025-05-04)
|
2
|
+
|
3
|
+
- Dropped support for Ruby < 3.2 and Active Record < 7.1
|
4
|
+
- Dropped support for Mongoid < 8
|
5
|
+
|
6
|
+
## 2.6.2 (2025-02-23)
|
7
|
+
|
8
|
+
- Fixed querying with normalized attributes
|
9
|
+
|
10
|
+
## 2.6.1 (2024-11-01)
|
11
|
+
|
12
|
+
- Fixed issue with `includes` and Active Record 7
|
13
|
+
|
14
|
+
## 2.6.0 (2024-10-07)
|
15
|
+
|
16
|
+
- Removed dependency on `scrypt` gem for scrypt algorithm
|
17
|
+
- Dropped support for Active Record < 7
|
18
|
+
|
19
|
+
## 2.5.0 (2024-06-03)
|
20
|
+
|
21
|
+
- Added support for Mongoid 9
|
22
|
+
- Dropped support for Ruby < 3.1
|
23
|
+
|
1
24
|
## 2.4.0 (2023-07-02)
|
2
25
|
|
3
26
|
- Dropped support for Ruby < 3 and Rails < 6.1
|
@@ -77,7 +100,7 @@ Breaking changes
|
|
77
100
|
|
78
101
|
- Added `size` option
|
79
102
|
- Added sanity checks for Argon2 cost parameters
|
80
|
-
- Fixed
|
103
|
+
- Fixed Active Record callback issues introduced in 0.3.3
|
81
104
|
|
82
105
|
## 0.3.3 (2018-11-12)
|
83
106
|
|
@@ -106,13 +129,13 @@ Breaking changes
|
|
106
129
|
|
107
130
|
## 0.2.0 (2018-05-11)
|
108
131
|
|
109
|
-
- Added support for
|
132
|
+
- Added support for Active Record 4.2
|
110
133
|
- Improved validation support when multiple blind indexes
|
111
134
|
- Fixed `nil` handling
|
112
135
|
|
113
136
|
## 0.1.1 (2018-04-09)
|
114
137
|
|
115
|
-
- Added support for
|
138
|
+
- Added support for Active Record 5.2
|
116
139
|
- Added `callback` option
|
117
140
|
- Added support for `key` proc
|
118
141
|
- Fixed error inheritance
|
data/LICENSE.txt
CHANGED
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
|
-
[](https://github.com/ankane/blind_index/actions)
|
10
10
|
|
11
11
|
## How It Works
|
12
12
|
|
@@ -385,16 +385,6 @@ One alternative to blind indexing is to use a deterministic encryption scheme, l
|
|
385
385
|
1. You can keep encryption consistent for all fields (both searchable and non-searchable)
|
386
386
|
2. Blind indexing supports expressions
|
387
387
|
|
388
|
-
## Upgrading
|
389
|
-
|
390
|
-
### 2.0.0
|
391
|
-
|
392
|
-
2.0.0 brings a number of improvements.
|
393
|
-
|
394
|
-
- Blind indexes are updated immediately instead of in a `before_validation` callback
|
395
|
-
- Better Lockbox integration - no need to generate a separate key
|
396
|
-
- There’s a new gem for Argon2 that has no dependencies and (officially) supports Windows
|
397
|
-
|
398
388
|
## History
|
399
389
|
|
400
390
|
View the [changelog](https://github.com/ankane/blind_index/blob/master/CHANGELOG.md)
|
data/lib/blind_index/backfill.rb
CHANGED
@@ -4,7 +4,7 @@ module BlindIndex
|
|
4
4
|
|
5
5
|
def initialize(relation, batch_size:, columns:)
|
6
6
|
@relation = relation
|
7
|
-
@transaction = @relation.respond_to?(:transaction)
|
7
|
+
@transaction = @relation.respond_to?(:transaction) && !mongoid_relation?(relation.all)
|
8
8
|
@batch_size = batch_size
|
9
9
|
@blind_indexes = @relation.blind_indexes
|
10
10
|
filter_columns!(columns) if columns
|
@@ -100,6 +100,10 @@ module BlindIndex
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
+
def mongoid_relation?(relation)
|
104
|
+
defined?(Mongoid::Criteria) && relation.is_a?(Mongoid::Criteria)
|
105
|
+
end
|
106
|
+
|
103
107
|
def with_transaction
|
104
108
|
if @transaction
|
105
109
|
@relation.transaction do
|
@@ -14,12 +14,20 @@ module BlindIndex
|
|
14
14
|
# https://github.com/rails/rails/commit/56f30962b84fc53b76001301fb830c1594fd377e
|
15
15
|
def build(attribute, value, *args)
|
16
16
|
if table.has_blind_indexes? && (bi = table.send(:klass).blind_indexes[attribute.name.to_sym]) && !value.is_a?(ActiveRecord::StatementCache::Substitute)
|
17
|
+
model = table.send(:klass)
|
18
|
+
attribute_name = attribute.name.to_sym
|
19
|
+
cast =
|
20
|
+
if model.respond_to?(:normalized_attributes) && model.normalized_attributes.include?(attribute_name)
|
21
|
+
->(v) { model.normalize_value_for(attribute_name, v) }
|
22
|
+
else
|
23
|
+
->(v) { v }
|
24
|
+
end
|
17
25
|
attribute = attribute.relation[bi[:bidx_attribute]]
|
18
26
|
value =
|
19
|
-
if value.is_a?(Array)
|
20
|
-
value.map { |v| BlindIndex.generate_bidx(v, **bi) }
|
27
|
+
if value.is_a?(Array) || (defined?(Set) && value.is_a?(Set))
|
28
|
+
value.map { |v| BlindIndex.generate_bidx(cast.call(v), **bi) }
|
21
29
|
else
|
22
|
-
BlindIndex.generate_bidx(value, **bi)
|
30
|
+
BlindIndex.generate_bidx(cast.call(value), **bi)
|
23
31
|
end
|
24
32
|
end
|
25
33
|
|
data/lib/blind_index/model.rb
CHANGED
@@ -38,7 +38,7 @@ module BlindIndex
|
|
38
38
|
class_eval do
|
39
39
|
activerecord = defined?(ActiveRecord) && self < ActiveRecord::Base
|
40
40
|
|
41
|
-
if activerecord
|
41
|
+
if activerecord
|
42
42
|
# blind index value isn't really sensitive
|
43
43
|
# but don't need to show it in the Rails console
|
44
44
|
self.filter_attributes += [/\A#{Regexp.escape(bidx_attribute)}\z/]
|
data/lib/blind_index/version.rb
CHANGED
data/lib/blind_index.rb
CHANGED
@@ -51,7 +51,7 @@ module BlindIndex
|
|
51
51
|
|
52
52
|
# check size
|
53
53
|
size = (options[:size] || 32).to_i
|
54
|
-
raise BlindIndex::Error, "Size must be between 1 and 32" unless (1..32).
|
54
|
+
raise BlindIndex::Error, "Size must be between 1 and 32" unless (1..32).cover?(size)
|
55
55
|
|
56
56
|
value = value.to_s
|
57
57
|
|
@@ -70,7 +70,7 @@ module BlindIndex
|
|
70
70
|
Argon2::KDF.argon2id(value, salt: key, t: t, m: m, p: 1, length: size)
|
71
71
|
when :pbkdf2_sha256
|
72
72
|
iterations = cost_options[:iterations] || options[:iterations] || (options[:slow] ? 100000 : 10000)
|
73
|
-
OpenSSL::
|
73
|
+
OpenSSL::KDF.pbkdf2_hmac(value, salt: key, iterations: iterations, length: size, hash: "sha256")
|
74
74
|
when :argon2i
|
75
75
|
t = (cost_options[:t] || 3).to_i
|
76
76
|
# use same bounds as rbnacl
|
@@ -86,7 +86,7 @@ module BlindIndex
|
|
86
86
|
n = cost_options[:n] || 4096
|
87
87
|
r = cost_options[:r] || 8
|
88
88
|
cp = cost_options[:p] || 1
|
89
|
-
|
89
|
+
OpenSSL::KDF.scrypt(value, salt: key, N: n, r: r, p: cp, length: size)
|
90
90
|
else
|
91
91
|
raise BlindIndex::Error, "Unknown algorithm"
|
92
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blind_index
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activesupport
|
@@ -16,29 +15,28 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
18
|
+
version: '7.1'
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
25
|
+
version: '7.1'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: argon2-kdf
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - ">="
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
32
|
+
version: '0.2'
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - ">="
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
41
|
-
description:
|
39
|
+
version: '0.2'
|
42
40
|
email: andrew@ankane.org
|
43
41
|
executables: []
|
44
42
|
extensions: []
|
@@ -58,7 +56,6 @@ homepage: https://github.com/ankane/blind_index
|
|
58
56
|
licenses:
|
59
57
|
- MIT
|
60
58
|
metadata: {}
|
61
|
-
post_install_message:
|
62
59
|
rdoc_options: []
|
63
60
|
require_paths:
|
64
61
|
- lib
|
@@ -66,15 +63,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
63
|
requirements:
|
67
64
|
- - ">="
|
68
65
|
- !ruby/object:Gem::Version
|
69
|
-
version: '3'
|
66
|
+
version: '3.2'
|
70
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
68
|
requirements:
|
72
69
|
- - ">="
|
73
70
|
- !ruby/object:Gem::Version
|
74
71
|
version: '0'
|
75
72
|
requirements: []
|
76
|
-
rubygems_version: 3.
|
77
|
-
signing_key:
|
73
|
+
rubygems_version: 3.6.7
|
78
74
|
specification_version: 4
|
79
75
|
summary: Securely search encrypted database fields
|
80
76
|
test_files: []
|