tidus 1.2.4 → 1.3.2

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: 97e5c63dd6fb5b0b3aba2bb7ff592263993f3fa0c241fc38e6b017bbcb85b003
4
+ data.tar.gz: 473e8cfcc317cc578f9e1419bee4dfbb8b5fc063dca6f64868eb974a598e90e1
5
5
  SHA512:
6
- metadata.gz: d55046ce42f820775c03b6a86c2785260910fbea9ec6385643ea3ec69c365e784990cd0d5959e126857b5eb394852cf51341c9e71f30116007d6d1fe9b997713
7
- data.tar.gz: 684b00ba589772505f7237f32a12fd3f17e503d705bed9ec7bf3a8dfee2f3b6597780a69979d6e269fa5d7f6aabdef1a28635a48d0021e99bba8ebff15e7beba
6
+ metadata.gz: 26463c2f04d7ffb41f59fa87f8a7dadc3b21400b6c54e311fd9efb795ac79dc9e9ea1b39fc4ba5a6ffbd069262821c2ca40d1ea45503719eb172e0ed55fe8794
7
+ data.tar.gz: 8690be5c03957451a8bd16777cb6166c952debbdf8d36398f5173bd1912bbf5850ef1e1a81a9fa4f96d66a327e58164ec267133cc1f60fd213cfb86b225950e9
@@ -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')::BYTEA, '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.2"
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schoknecht
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-03 00:00:00.000000000 Z
11
+ date: 2023-07-17 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
@@ -101,7 +103,7 @@ homepage: ''
101
103
  licenses:
102
104
  - MIT
103
105
  metadata: {}
104
- post_install_message:
106
+ post_install_message:
105
107
  rdoc_options: []
106
108
  require_paths:
107
109
  - lib
@@ -116,8 +118,8 @@ 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
120
- signing_key:
121
+ rubygems_version: 3.4.10
122
+ signing_key:
121
123
  specification_version: 4
122
124
  summary: Gem for creating anonymization views.
123
125
  test_files: []