pgdump_scrambler 0.4.1 → 0.5.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: da5d3c9bc68d351090dfabdab28ad0bd216515554d61f8d4a06381eba5fc1ce4
4
- data.tar.gz: 0e01334e4769d064ff9d3e2ebbca847f389ec12157b7ac299f8c89568937e2fc
3
+ metadata.gz: 2e7f5dfba9c232b88797b7bd41d467f2d78522df69c709923c8a37ad73258aa7
4
+ data.tar.gz: e4afb18633a51c9349af4182ea4c25f27b377d10c2b7c2b784dda45d942cec37
5
5
  SHA512:
6
- metadata.gz: 3b12790519c8980cc4b208f3e9ad6b137d83ab970acfc2d03cf21793893ed376a67e7d47c2f0d83afb4c675320ba6548125c22dc2d8e66050c70c1414fa76f89
7
- data.tar.gz: 98f6af73aa1b377c4c31e365c65dcefa1b90cb8c6f3b1c69220270a519db0d9b55e0fb9440ba843c0dffb9819d3b0f63592935656feaf18d8fd438d8f314ed82
6
+ metadata.gz: 182f6d023f2343404876af457a404b2e2c1c9410d951d8b1f68c1408861c42bd132db424ffe7fb292cbebaf78c7d355f83ecdb571c7cfa6f7d28c6c6b10cbe98
7
+ data.tar.gz: 79174375c3ae4f02a0d9b244d602fbba6258a8d8bfffe7be2e72c2939c25ae77e7acd73e074b1a60ce18519c3ad31562a74ba2dd2a68e47e38e671d34ad27370
data/CHANGELOG.md CHANGED
@@ -1,13 +1,21 @@
1
+ ## [0.5.0] - 2024-03-01
2
+
3
+ - Resolve ERB on loading config/database.yml
4
+
1
5
  ## [0.4.1] - 2023-10-19
6
+
2
7
  - Fix S3 upload
3
8
 
4
9
  ## [0.4.0] - 2023-10-18
10
+
5
11
  - Add scramble functions
6
12
  - Support ARM64 Linux/Mac
7
13
 
8
14
  ## [0.3.0] - 2023-04-13
15
+
9
16
  - Prefer using YAML.safe_load over YAML.load
10
17
  - Test with Rails 7.0
11
18
 
12
19
  ### Fixes
20
+
13
21
  - Fix JSON number format error
data/Gemfile.lock CHANGED
@@ -1,165 +1,195 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pgdump_scrambler (0.4.1)
4
+ pgdump_scrambler (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actioncable (7.0.4.3)
10
- actionpack (= 7.0.4.3)
11
- activesupport (= 7.0.4.3)
9
+ actioncable (7.1.1)
10
+ actionpack (= 7.1.1)
11
+ activesupport (= 7.1.1)
12
12
  nio4r (~> 2.0)
13
13
  websocket-driver (>= 0.6.1)
14
- actionmailbox (7.0.4.3)
15
- actionpack (= 7.0.4.3)
16
- activejob (= 7.0.4.3)
17
- activerecord (= 7.0.4.3)
18
- activestorage (= 7.0.4.3)
19
- activesupport (= 7.0.4.3)
14
+ zeitwerk (~> 2.6)
15
+ actionmailbox (7.1.1)
16
+ actionpack (= 7.1.1)
17
+ activejob (= 7.1.1)
18
+ activerecord (= 7.1.1)
19
+ activestorage (= 7.1.1)
20
+ activesupport (= 7.1.1)
20
21
  mail (>= 2.7.1)
21
22
  net-imap
22
23
  net-pop
23
24
  net-smtp
24
- actionmailer (7.0.4.3)
25
- actionpack (= 7.0.4.3)
26
- actionview (= 7.0.4.3)
27
- activejob (= 7.0.4.3)
28
- activesupport (= 7.0.4.3)
25
+ actionmailer (7.1.1)
26
+ actionpack (= 7.1.1)
27
+ actionview (= 7.1.1)
28
+ activejob (= 7.1.1)
29
+ activesupport (= 7.1.1)
29
30
  mail (~> 2.5, >= 2.5.4)
30
31
  net-imap
31
32
  net-pop
32
33
  net-smtp
33
- rails-dom-testing (~> 2.0)
34
- actionpack (7.0.4.3)
35
- actionview (= 7.0.4.3)
36
- activesupport (= 7.0.4.3)
37
- rack (~> 2.0, >= 2.2.0)
34
+ rails-dom-testing (~> 2.2)
35
+ actionpack (7.1.1)
36
+ actionview (= 7.1.1)
37
+ activesupport (= 7.1.1)
38
+ nokogiri (>= 1.8.5)
39
+ rack (>= 2.2.4)
40
+ rack-session (>= 1.0.1)
38
41
  rack-test (>= 0.6.3)
39
- rails-dom-testing (~> 2.0)
40
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
41
- actiontext (7.0.4.3)
42
- actionpack (= 7.0.4.3)
43
- activerecord (= 7.0.4.3)
44
- activestorage (= 7.0.4.3)
45
- activesupport (= 7.0.4.3)
42
+ rails-dom-testing (~> 2.2)
43
+ rails-html-sanitizer (~> 1.6)
44
+ actiontext (7.1.1)
45
+ actionpack (= 7.1.1)
46
+ activerecord (= 7.1.1)
47
+ activestorage (= 7.1.1)
48
+ activesupport (= 7.1.1)
46
49
  globalid (>= 0.6.0)
47
50
  nokogiri (>= 1.8.5)
48
- actionview (7.0.4.3)
49
- activesupport (= 7.0.4.3)
51
+ actionview (7.1.1)
52
+ activesupport (= 7.1.1)
50
53
  builder (~> 3.1)
51
- erubi (~> 1.4)
52
- rails-dom-testing (~> 2.0)
53
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
54
- activejob (7.0.4.3)
55
- activesupport (= 7.0.4.3)
54
+ erubi (~> 1.11)
55
+ rails-dom-testing (~> 2.2)
56
+ rails-html-sanitizer (~> 1.6)
57
+ activejob (7.1.1)
58
+ activesupport (= 7.1.1)
56
59
  globalid (>= 0.3.6)
57
- activemodel (7.0.4.3)
58
- activesupport (= 7.0.4.3)
59
- activerecord (7.0.4.3)
60
- activemodel (= 7.0.4.3)
61
- activesupport (= 7.0.4.3)
62
- activestorage (7.0.4.3)
63
- actionpack (= 7.0.4.3)
64
- activejob (= 7.0.4.3)
65
- activerecord (= 7.0.4.3)
66
- activesupport (= 7.0.4.3)
60
+ activemodel (7.1.1)
61
+ activesupport (= 7.1.1)
62
+ activerecord (7.1.1)
63
+ activemodel (= 7.1.1)
64
+ activesupport (= 7.1.1)
65
+ timeout (>= 0.4.0)
66
+ activestorage (7.1.1)
67
+ actionpack (= 7.1.1)
68
+ activejob (= 7.1.1)
69
+ activerecord (= 7.1.1)
70
+ activesupport (= 7.1.1)
67
71
  marcel (~> 1.0)
68
- mini_mime (>= 1.1.0)
69
- activesupport (7.0.4.3)
72
+ activesupport (7.1.1)
73
+ base64
74
+ bigdecimal
70
75
  concurrent-ruby (~> 1.0, >= 1.0.2)
76
+ connection_pool (>= 2.2.5)
77
+ drb
71
78
  i18n (>= 1.6, < 2)
72
79
  minitest (>= 5.1)
80
+ mutex_m
73
81
  tzinfo (~> 2.0)
74
82
  ast (2.4.2)
75
83
  base64 (0.1.1)
84
+ bigdecimal (3.1.4)
76
85
  builder (3.2.4)
77
86
  concurrent-ruby (1.2.2)
87
+ connection_pool (2.4.1)
78
88
  crass (1.0.6)
79
89
  date (3.3.3)
80
90
  diff-lcs (1.5.0)
91
+ drb (2.1.1)
92
+ ruby2_keywords
81
93
  erubi (1.12.0)
82
- globalid (1.1.0)
83
- activesupport (>= 5.0)
84
- i18n (1.12.0)
94
+ globalid (1.2.1)
95
+ activesupport (>= 6.1)
96
+ i18n (1.14.1)
85
97
  concurrent-ruby (~> 1.0)
98
+ io-console (0.6.0)
99
+ irb (1.8.3)
100
+ rdoc
101
+ reline (>= 0.3.8)
86
102
  json (2.6.3)
87
103
  language_server-protocol (3.17.0.3)
88
- loofah (2.20.0)
104
+ loofah (2.21.4)
89
105
  crass (~> 1.0.2)
90
- nokogiri (>= 1.5.9)
106
+ nokogiri (>= 1.12.0)
91
107
  mail (2.8.1)
92
108
  mini_mime (>= 0.1.1)
93
109
  net-imap
94
110
  net-pop
95
111
  net-smtp
96
112
  marcel (1.0.2)
97
- method_source (1.0.0)
98
- mini_mime (1.1.2)
99
- minitest (5.18.0)
100
- net-imap (0.3.4)
113
+ mini_mime (1.1.5)
114
+ minitest (5.20.0)
115
+ mutex_m (0.1.2)
116
+ net-imap (0.4.1)
101
117
  date
102
118
  net-protocol
103
119
  net-pop (0.1.2)
104
120
  net-protocol
105
121
  net-protocol (0.2.1)
106
122
  timeout
107
- net-smtp (0.3.3)
123
+ net-smtp (0.4.0)
108
124
  net-protocol
109
125
  nio4r (2.5.9)
110
- nokogiri (1.14.3-x86_64-linux)
126
+ nokogiri (1.15.4-x86_64-linux)
111
127
  racc (~> 1.4)
112
128
  parallel (1.23.0)
113
129
  parser (3.2.2.4)
114
130
  ast (~> 2.4.1)
115
131
  racc
116
- racc (1.6.2)
117
- rack (2.2.6.4)
132
+ psych (5.1.1.1)
133
+ stringio
134
+ racc (1.7.1)
135
+ rack (3.0.8)
136
+ rack-session (2.0.0)
137
+ rack (>= 3.0.0)
118
138
  rack-test (2.1.0)
119
139
  rack (>= 1.3)
120
- rails (7.0.4.3)
121
- actioncable (= 7.0.4.3)
122
- actionmailbox (= 7.0.4.3)
123
- actionmailer (= 7.0.4.3)
124
- actionpack (= 7.0.4.3)
125
- actiontext (= 7.0.4.3)
126
- actionview (= 7.0.4.3)
127
- activejob (= 7.0.4.3)
128
- activemodel (= 7.0.4.3)
129
- activerecord (= 7.0.4.3)
130
- activestorage (= 7.0.4.3)
131
- activesupport (= 7.0.4.3)
140
+ rackup (2.1.0)
141
+ rack (>= 3)
142
+ webrick (~> 1.8)
143
+ rails (7.1.1)
144
+ actioncable (= 7.1.1)
145
+ actionmailbox (= 7.1.1)
146
+ actionmailer (= 7.1.1)
147
+ actionpack (= 7.1.1)
148
+ actiontext (= 7.1.1)
149
+ actionview (= 7.1.1)
150
+ activejob (= 7.1.1)
151
+ activemodel (= 7.1.1)
152
+ activerecord (= 7.1.1)
153
+ activestorage (= 7.1.1)
154
+ activesupport (= 7.1.1)
132
155
  bundler (>= 1.15.0)
133
- railties (= 7.0.4.3)
134
- rails-dom-testing (2.0.3)
135
- activesupport (>= 4.2.0)
156
+ railties (= 7.1.1)
157
+ rails-dom-testing (2.2.0)
158
+ activesupport (>= 5.0.0)
159
+ minitest
136
160
  nokogiri (>= 1.6)
137
- rails-html-sanitizer (1.5.0)
138
- loofah (~> 2.19, >= 2.19.1)
139
- railties (7.0.4.3)
140
- actionpack (= 7.0.4.3)
141
- activesupport (= 7.0.4.3)
142
- method_source
161
+ rails-html-sanitizer (1.6.0)
162
+ loofah (~> 2.21)
163
+ nokogiri (~> 1.14)
164
+ railties (7.1.1)
165
+ actionpack (= 7.1.1)
166
+ activesupport (= 7.1.1)
167
+ irb
168
+ rackup (>= 1.0.0)
143
169
  rake (>= 12.2)
144
- thor (~> 1.0)
145
- zeitwerk (~> 2.5)
170
+ thor (~> 1.0, >= 1.2.2)
171
+ zeitwerk (~> 2.6)
146
172
  rainbow (3.1.1)
147
173
  rake (13.0.6)
174
+ rdoc (6.5.0)
175
+ psych (>= 4.0.0)
148
176
  regexp_parser (2.8.2)
177
+ reline (0.3.9)
178
+ io-console (~> 0.5)
149
179
  rexml (3.2.6)
150
180
  rspec (3.12.0)
151
181
  rspec-core (~> 3.12.0)
152
182
  rspec-expectations (~> 3.12.0)
153
183
  rspec-mocks (~> 3.12.0)
154
- rspec-core (3.12.1)
184
+ rspec-core (3.12.2)
155
185
  rspec-support (~> 3.12.0)
156
- rspec-expectations (3.12.2)
186
+ rspec-expectations (3.12.3)
157
187
  diff-lcs (>= 1.2.0, < 2.0)
158
188
  rspec-support (~> 3.12.0)
159
- rspec-mocks (3.12.5)
189
+ rspec-mocks (3.12.6)
160
190
  diff-lcs (>= 1.2.0, < 2.0)
161
191
  rspec-support (~> 3.12.0)
162
- rspec-support (3.12.0)
192
+ rspec-support (3.12.1)
163
193
  rubocop (1.57.1)
164
194
  base64 (~> 0.1.1)
165
195
  json (~> 2.3)
@@ -183,15 +213,18 @@ GEM
183
213
  rubocop-capybara (~> 2.17)
184
214
  rubocop-factory_bot (~> 2.22)
185
215
  ruby-progressbar (1.13.0)
186
- thor (1.2.1)
187
- timeout (0.3.2)
216
+ ruby2_keywords (0.0.5)
217
+ stringio (3.0.8)
218
+ thor (1.3.0)
219
+ timeout (0.4.0)
188
220
  tzinfo (2.0.6)
189
221
  concurrent-ruby (~> 1.0)
190
222
  unicode-display_width (2.5.0)
191
- websocket-driver (0.7.5)
223
+ webrick (1.8.1)
224
+ websocket-driver (0.7.6)
192
225
  websocket-extensions (>= 0.1.0)
193
226
  websocket-extensions (0.1.5)
194
- zeitwerk (2.6.7)
227
+ zeitwerk (2.6.12)
195
228
 
196
229
  PLATFORMS
197
230
  x86_64-linux
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'pgdump_scrambler/utils'
3
4
  require 'open3'
5
+
4
6
  module PgdumpScrambler
5
7
  class Dumper
6
8
  def initialize(config, db_config = {})
@@ -12,13 +14,19 @@ module PgdumpScrambler
12
14
  def run
13
15
  puts 'Executing pg_dump...'
14
16
  puts full_command
15
- raise 'pg_dump failed!' unless system(full_command)
17
+ raise 'pg_dump failed!' unless system(env_vars, full_command)
16
18
 
17
19
  puts 'Done!'
18
20
  end
19
21
 
20
22
  private
21
23
 
24
+ def env_vars
25
+ vars = {}
26
+ vars['PGPASSWORD'] = @db_config['password'] if @db_config['password']
27
+ vars
28
+ end
29
+
22
30
  def full_command
23
31
  [pgdump_command, obfuscator_command, 'gzip -c'].compact.join(' | ') + "> #{@output_path}"
24
32
  end
@@ -32,7 +40,6 @@ module PgdumpScrambler
32
40
 
33
41
  def pgdump_command
34
42
  command = []
35
- command << "PGPASSWORD=#{Shellwords.escape(@db_config['password'])}" if @db_config['password']
36
43
  command << 'pg_dump'
37
44
  command << @config.pgdump_args if @config.pgdump_args
38
45
  command << "--username=#{Shellwords.escape(@db_config['username'])}" if @db_config['username']
@@ -50,12 +57,7 @@ module PgdumpScrambler
50
57
  def load_database_yml
51
58
  return unless defined?(Rails)
52
59
 
53
- db_config = YAML.safe_load_file(
54
- Rails.root.join('config', 'database.yml'),
55
- permitted_classes: [],
56
- permitted_symbols: [],
57
- aliases: true
58
- )
60
+ db_config = Utils.load_yaml_with_erb(Rails.root.join('config', 'database.yml'))
59
61
  db_config[Rails.env]
60
62
  end
61
63
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require 'erb'
5
+
6
+ module PgdumpScrambler
7
+ module Utils
8
+ module_function
9
+
10
+ def load_yaml_with_erb(path)
11
+ yaml_content = File.read(path)
12
+ resolved = ERB.new(yaml_content).result
13
+ YAML.safe_load(
14
+ resolved,
15
+ permitted_classes: [],
16
+ permitted_symbols: [],
17
+ aliases: true
18
+ )
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgdumpScrambler
4
- VERSION = '0.4.1'
4
+ VERSION = '0.5.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgdump_scrambler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shunichi Ikegami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-19 00:00:00.000000000 Z
11
+ date: 2024-03-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Scramble pg_dump columns.
14
14
  email:
@@ -38,6 +38,7 @@ files:
38
38
  - lib/pgdump_scrambler/railtie.rb
39
39
  - lib/pgdump_scrambler/s3_request.rb
40
40
  - lib/pgdump_scrambler/s3_uploader.rb
41
+ - lib/pgdump_scrambler/utils.rb
41
42
  - lib/pgdump_scrambler/version.rb
42
43
  - lib/tasks/pgdump_scrambler_tasks.rake
43
44
  - libexec/pgdump-obfuscator-darwin-amd64
@@ -68,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
69
  - !ruby/object:Gem::Version
69
70
  version: '0'
70
71
  requirements: []
71
- rubygems_version: 3.4.10
72
+ rubygems_version: 3.2.33
72
73
  signing_key:
73
74
  specification_version: 4
74
75
  summary: Scramble pg_dump columns