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: 1ab6c8984ca856fa25dbb98b938fa15e0cbc7adbaf7933ad99ad42a27bd12ac1
4
- data.tar.gz: 637691557e333d4517bd9b1bb68a2e0ea2a0c4836b214afd785c3faea1fa4de9
3
+ metadata.gz: e856d718f2b4408d674dbd77073588f3da9f9c26dd8f9f61f9d4c1bbb674d525
4
+ data.tar.gz: ed491dc4694a926936fe3d8c879a48894ae6ef77685730004c63e1cd6e1e1493
5
5
  SHA512:
6
- metadata.gz: d55046ce42f820775c03b6a86c2785260910fbea9ec6385643ea3ec69c365e784990cd0d5959e126857b5eb394852cf51341c9e71f30116007d6d1fe9b997713
7
- data.tar.gz: 684b00ba589772505f7237f32a12fd3f17e503d705bed9ec7bf3a8dfee2f3b6597780a69979d6e269fa5d7f6aabdef1a28635a48d0021e99bba8ebff15e7beba
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] ||= 15
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), #{options[:length]}) || '@'::text) " +
10
- "|| split_part((#{name})::text, '@'::text, 2)))::character varying " +
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
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+
3
+ module Tidus
4
+ class Sha256Anonymizer < Tidus::BaseSelector
5
+ end
6
+ end
data/lib/tidus/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tidus
2
- VERSION = "1.2.4"
2
+ VERSION = "1.3.0"
3
3
  end
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.2.4
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-02-03 00:00:00.000000000 Z
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.1.6
121
+ rubygems_version: 3.4.13
120
122
  signing_key:
121
123
  specification_version: 4
122
124
  summary: Gem for creating anonymization views.