tidus 1.2.4 → 1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e856d718f2b4408d674dbd77073588f3da9f9c26dd8f9f61f9d4c1bbb674d525
|
4
|
+
data.tar.gz: ed491dc4694a926936fe3d8c879a48894ae6ef77685730004c63e1cd6e1e1493
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7ceb7506c37c5c9fd66fc5f417e8318b566ad8fcf900341c61a0cc3423bf69fe8066194c8cb1610296ecfe36fc48fd3ded8361904ab29d449e99828c17a54c8
|
7
|
+
data.tar.gz: 885933234f25620860632d23ea8e1567034ee9455840b1ebde57e5a88a25c4cb4803ed66a45b2ae9ffdcac93bb95eeb03ddc052557d116097207a638451282d8
|
@@ -1,15 +1,27 @@
|
|
1
1
|
module Tidus
|
2
2
|
module Postgresql
|
3
3
|
class EmailAnonymizer
|
4
|
+
|
4
5
|
def self.anonymize(table_name, column_name, options = {})
|
5
6
|
name = "#{table_name}.#{column_name}"
|
6
|
-
options[:length]
|
7
|
+
length = options[:length] || 15
|
8
|
+
anonymize_domain = options[:anonymize_domain] || false
|
7
9
|
|
8
10
|
return "CASE WHEN ((#{name})::text ~~ '%@%'::text) " +
|
9
|
-
"THEN (((\"left\"(md5((#{name})::text), #{
|
10
|
-
"||
|
11
|
+
"THEN (((\"left\"(md5((#{name})::text), #{length}) || '@'::text) " +
|
12
|
+
"|| #{domain_part(name, anonymize_domain, length)}))::character varying " +
|
11
13
|
"ELSE #{name} END"
|
12
14
|
end
|
15
|
+
|
16
|
+
def self.domain_part(name, anonymize_domain, length)
|
17
|
+
if anonymize_domain
|
18
|
+
return "(\"left\"(md5(split_part((#{name})::text, '@'::text, 2)::text), #{length}) " +
|
19
|
+
"|| '.com')"
|
20
|
+
end
|
21
|
+
|
22
|
+
return "split_part((#{name})::text, '@'::text, 2)"
|
23
|
+
end
|
24
|
+
|
13
25
|
end
|
14
26
|
end
|
15
27
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Tidus
|
2
|
+
module Postgresql
|
3
|
+
class Sha256Anonymizer
|
4
|
+
|
5
|
+
def self.anonymize(table_name, column_name, options = {})
|
6
|
+
name = "#{table_name}.#{column_name}"
|
7
|
+
|
8
|
+
length = options[:length] || 64
|
9
|
+
|
10
|
+
return "SUBSTR(ENCODE(DIGEST(#{name}, 'sha256')::TEXT, 'HEX'), 0, #{length.to_i + 1})"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/tidus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tidus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Schoknecht
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -90,9 +90,11 @@ files:
|
|
90
90
|
- lib/tidus/strategies/postgresql/overlay_anonymizer.rb
|
91
91
|
- lib/tidus/strategies/postgresql/regex_replace_anonymizer.rb
|
92
92
|
- lib/tidus/strategies/postgresql/remove_json_keys_anonymizer.rb
|
93
|
+
- lib/tidus/strategies/postgresql/sha256_anonymizer.rb
|
93
94
|
- lib/tidus/strategies/postgresql/text_anonymizer.rb
|
94
95
|
- lib/tidus/strategies/regex_replace_anonymizer.rb
|
95
96
|
- lib/tidus/strategies/remove_json_keys_anonymizer.rb
|
97
|
+
- lib/tidus/strategies/sha256_anonymizer.rb
|
96
98
|
- lib/tidus/strategies/sqlite3/null_anonymizer.rb
|
97
99
|
- lib/tidus/strategies/static_anonymizer.rb
|
98
100
|
- lib/tidus/strategies/text_anonymizer.rb
|
@@ -116,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
118
|
- !ruby/object:Gem::Version
|
117
119
|
version: '0'
|
118
120
|
requirements: []
|
119
|
-
rubygems_version: 3.
|
121
|
+
rubygems_version: 3.4.13
|
120
122
|
signing_key:
|
121
123
|
specification_version: 4
|
122
124
|
summary: Gem for creating anonymization views.
|