crypt_keeper 0.21.0 → 0.22.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73363a22fbcc6bdbe4ecb9be144d088cc99348a7
4
- data.tar.gz: 25c86e1d17a14f387db29b85e1f88fe4b96f0bcb
3
+ metadata.gz: 3297d5e1a03266d6b1d74f5e9fee1fbba49dd295
4
+ data.tar.gz: f7621fbc63a9e94341105919bc839d8917d3f37b
5
5
  SHA512:
6
- metadata.gz: 3d04d80a51df14a595006ca5824d5e561be8b325cf1f390deb4b8952ec53d5b716cb029e13b30b74a485270cea83134bdf6605b1f16f54179599d2a96ff5acc8
7
- data.tar.gz: 1e1b123878d3f9fd77337d9df4b6d30ac13de7bdfb2b2a2420cebefb03965bec58a931cb394ecf24657b712c117fe460f97da4c1c7accbab85620af14f5732d8
6
+ metadata.gz: 2de5ef53aaa8f9d2e255f3c9b68c2996dae3eb2f49919ecceeb335fefbaaaa4ca98b1b0aa0ffb71aaf672ad2f7e0b6ed4edcbc721201f411cf6e8ba368984ab2
7
+ data.tar.gz: 82a701bd3b4c2a56394fdb205ecc0e24bb856028d0ccdbc61867ae0184b76967de02de7ddd07927fd00e16a6ad0d670f2d5442fc37ad408152ccc5eac900b574
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- crypt_keeper (0.20.0)
4
+ crypt_keeper (0.21.0)
5
5
  activerecord (>= 3.1, < 4.3)
6
6
  activesupport (>= 3.1, < 4.3)
7
7
  aes (~> 0.5.0)
@@ -117,4 +117,4 @@ DEPENDENCIES
117
117
  sqlite3
118
118
 
119
119
  BUNDLED WITH
120
- 1.12.4
120
+ 1.12.5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- crypt_keeper (0.20.0)
4
+ crypt_keeper (0.21.0)
5
5
  activerecord (>= 3.1, < 4.3)
6
6
  activesupport (>= 3.1, < 4.3)
7
7
  aes (~> 0.5.0)
@@ -117,4 +117,4 @@ DEPENDENCIES
117
117
  sqlite3
118
118
 
119
119
  BUNDLED WITH
120
- 1.12.4
120
+ 1.12.5
@@ -13,7 +13,10 @@ require 'crypt_keeper/provider/postgres_pgp_public_key'
13
13
  module CryptKeeper
14
14
  class << self
15
15
  attr_accessor :stub_encryption
16
- alias_method :stub_encryption?, :stub_encryption
16
+ alias_method :stub_encryption?, :stub_encryption
17
+
18
+ attr_accessor :silence_logs
19
+ alias_method :silence_logs?, :silence_logs
17
20
  end
18
21
  end
19
22
 
@@ -16,6 +16,8 @@ module CryptKeeper
16
16
  payload = event.payload[:sql]
17
17
  .encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
18
18
 
19
+ return if CryptKeeper.silence_logs? && payload =~ filter
20
+
19
21
  event.payload[:sql] = payload.gsub(filter) do |_|
20
22
  "#{$1}([FILTERED])"
21
23
  end
@@ -16,6 +16,8 @@ module CryptKeeper
16
16
  payload = event.payload[:sql]
17
17
  .encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
18
18
 
19
+ return if CryptKeeper.silence_logs? && payload =~ filter
20
+
19
21
  event.payload[:sql] = payload.gsub(filter) do |_|
20
22
  "#{$~[:operation]}([FILTERED])"
21
23
  end
@@ -1,3 +1,3 @@
1
1
  module CryptKeeper
2
- VERSION = "0.21.0"
2
+ VERSION = "0.22.0"
3
3
  end
@@ -2,6 +2,10 @@ require 'spec_helper'
2
2
 
3
3
  module CryptKeeper::LogSubscriber
4
4
  describe MysqlAes do
5
+ before do
6
+ CryptKeeper.silence_logs = false
7
+ end
8
+
5
9
  use_mysql
6
10
 
7
11
  context "AES encryption" do
@@ -56,6 +60,14 @@ module CryptKeeper::LogSubscriber
56
60
  string_encoding_query = "SELECT aes_encrypt('hi \255', 'test')"
57
61
  subject.sql(ActiveSupport::Notifications::Event.new(:sql, 1, 1, 1, { sql: string_encoding_query }))
58
62
  end
63
+
64
+ it "skips logging if CryptKeeper.silence_logs is set" do
65
+ CryptKeeper.silence_logs = true
66
+
67
+ subject.should_not_receive(:sql_without_mysql_aes)
68
+
69
+ subject.sql(ActiveSupport::Notifications::Event.new(:sql, 1, 1, 1, { sql: input_query }))
70
+ end
59
71
  end
60
72
  end
61
73
  end
@@ -2,6 +2,10 @@ require 'spec_helper'
2
2
 
3
3
  module CryptKeeper::LogSubscriber
4
4
  describe PostgresPgp do
5
+ before do
6
+ CryptKeeper.silence_logs = false
7
+ end
8
+
5
9
  use_postgres
6
10
 
7
11
  context "Symmetric encryption" do
@@ -56,6 +60,14 @@ module CryptKeeper::LogSubscriber
56
60
  string_encoding_query = "SELECT pgp_sym_encrypt('hi \255', 'test')"
57
61
  subject.sql(ActiveSupport::Notifications::Event.new(:sql, 1, 1, 1, { sql: string_encoding_query }))
58
62
  end
63
+
64
+ it "skips logging if CryptKeeper.silence_logs is set" do
65
+ CryptKeeper.silence_logs = true
66
+
67
+ subject.should_not_receive(:sql_without_postgres_pgp)
68
+
69
+ subject.sql(ActiveSupport::Notifications::Event.new(:sql, 1, 1, 1, { sql: input_query }))
70
+ end
59
71
  end
60
72
 
61
73
  context "Public key encryption" do
@@ -98,6 +110,14 @@ module CryptKeeper::LogSubscriber
98
110
 
99
111
  subject.sql(ActiveSupport::Notifications::Event.new(:sql, 1, 1, 1, { sql: input_query.downcase }))
100
112
  end
113
+
114
+ it "skips logging if CryptKeeper.silence_logs is set" do
115
+ CryptKeeper.silence_logs = true
116
+
117
+ subject.should_not_receive(:sql_without_postgres_pgp)
118
+
119
+ subject.sql(ActiveSupport::Notifications::Event.new(:sql, 1, 1, 1, { sql: input_query }))
120
+ end
101
121
  end
102
122
  end
103
123
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crypt_keeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Mazzi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-21 00:00:00.000000000 Z
11
+ date: 2016-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord