glacier_on_rails 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -0
- data/app/models/application_database/postgres_adapter.rb +12 -1
- data/app/models/glacier_db_archive.rb +2 -0
- data/glacier_on_rails.gemspec +2 -2
- data/spec/features/application_data_backup_spec.rb +23 -0
- data/spec/models/postgres_adapter_spec.rb +21 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e064638350da90807ab8f7c14b788295bbdba127
|
4
|
+
data.tar.gz: 409fb6e65fd668c57265f8040f231e30a3c8f1a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f38b8ea5ed087142468409256cad1d3a448ce036a6a8950c4593ebc2a70533c18f12a06733b3b1fd69f487d31e96d06953f1f7412b01ac29d4db8fd1c41047f2
|
7
|
+
data.tar.gz: 3618d038b088fdfb83bf6ea31fab36647bc4e96a8c5efac6836f167dc7c03578a77169a85ca9802c63becf8bcb1659b08a0ee7fb0a5ba14e8fa1a8606da397be
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -9,6 +9,13 @@ class ApplicationDatabase::PostgresAdapter < ApplicationDatabase::BaseAdapter
|
|
9
9
|
super(message)
|
10
10
|
end
|
11
11
|
end
|
12
|
+
class PgPassFilePermissionsError < StandardError
|
13
|
+
def initialize
|
14
|
+
message = "password file #{File.expand_path("~/.pgpass")} has group or world access; permissions should be u=rw (0600)"
|
15
|
+
AwsLog.error "ApplicationDatabase::PostgresAdapter::PgPassFilePermissionsError exception: #{message}"
|
16
|
+
super(message)
|
17
|
+
end
|
18
|
+
end
|
12
19
|
|
13
20
|
RestoreExclusions = %w{ application_data_backups
|
14
21
|
glacier_archives
|
@@ -17,7 +24,11 @@ class ApplicationDatabase::PostgresAdapter < ApplicationDatabase::BaseAdapter
|
|
17
24
|
RestoreList = GlacierArchive::BackupFileDir.join('restore.list')
|
18
25
|
|
19
26
|
def contents
|
20
|
-
|
27
|
+
if db_config["password"].present?
|
28
|
+
password_file = File.expand_path("~/.pgpass")
|
29
|
+
raise PgPassFileMissing unless File.exists?(password_file)
|
30
|
+
raise PgPassFilePermissionsError unless sprintf("%o", File.stat(password_file).mode) =~ /600$/
|
31
|
+
end
|
21
32
|
`#{pg_dump} -w -Fc -U #{db_config['username']} #{db_config['database']}`
|
22
33
|
end
|
23
34
|
|
@@ -11,6 +11,8 @@ class GlacierDbArchive < GlacierArchive
|
|
11
11
|
|
12
12
|
def archive_contents
|
13
13
|
ApplicationDatabase.new.contents
|
14
|
+
rescue ApplicationDatabase::PostgresAdapter::PgPassFilePermissionsError
|
15
|
+
nil
|
14
16
|
rescue ApplicationDatabase::PostgresAdapter::PgPassFileMissing
|
15
17
|
nil
|
16
18
|
rescue ApplicationDatabase::MissingConfigurationKeys
|
data/glacier_on_rails.gemspec
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "glacier_on_rails"
|
6
|
-
s.version = "0.9.
|
6
|
+
s.version = "0.9.9"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.authors = ["Les Nightingill"]
|
10
|
-
s.date = "2017-07-
|
10
|
+
s.date = "2017-07-13"
|
11
11
|
s.description = "Rails engine for database backup/restore to/from Amazon Glacier, including file attachments."
|
12
12
|
s.email = ["codehacker@comcast.net"]
|
13
13
|
s.files = Dir.glob("{{app,config,db,lib,script,spec}/**/*,*}").reject{|f| f =~ /(cache|\.log|\.gem$)/}
|
@@ -195,4 +195,27 @@ feature "backup_now", :js => true do
|
|
195
195
|
expect(aws_log).to match /ApplicationDatabase::PostgresAdapter::PgPassFileMissing exception: #{File.expand_path("~/.pgpass")} file not found, cannot dump database contents/
|
196
196
|
end
|
197
197
|
end
|
198
|
+
|
199
|
+
context "when database password file has incorrect permissions" do
|
200
|
+
before do
|
201
|
+
@config = ActiveRecord::Base.configurations[Rails.env].dup
|
202
|
+
ActiveRecord::Base.configurations[Rails.env].merge!({"password" => "sekret"})
|
203
|
+
allow(File).to receive(:exists?)
|
204
|
+
allow(File).to receive(:exists?).with(File.expand_path("~/.pgpass")).and_return(true)
|
205
|
+
status = Struct.new(:mode).new(33204) # octal: 100664
|
206
|
+
allow(File).to receive(:stat)
|
207
|
+
allow(File).to receive(:stat).with(File.expand_path("~/.pgpass")).and_return(status)
|
208
|
+
end
|
209
|
+
|
210
|
+
after do
|
211
|
+
ActiveRecord::Base.configurations[Rails.env] = @config
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should not create a new application_data_backup" do
|
215
|
+
expect{page.find('#backup_now').click; wait_for_ajax}.not_to change{ApplicationDataBackup.count}
|
216
|
+
expect(page).not_to have_selector("#application_data_backups .application_data_backup")
|
217
|
+
expect(flash_message).to eq "failed to create backup"
|
218
|
+
expect(aws_log).to match /#{Regexp.escape ApplicationDatabase::PostgresAdapter::PgPassFilePermissionsError.new.message}/
|
219
|
+
end
|
220
|
+
end
|
198
221
|
end
|
@@ -13,7 +13,7 @@ describe "PostgresAdapter#contents dependence on password file ~/.pgpass" do
|
|
13
13
|
before do
|
14
14
|
ActiveRecord::Base.configurations[Rails.env].merge!({"password" => nil })
|
15
15
|
allow(File).to receive(:exists?)
|
16
|
-
allow(File).to receive(:exists?).with("~/.pgpass").and_return(false)
|
16
|
+
allow(File).to receive(:exists?).with(File.expand_path("~/.pgpass")).and_return(false)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should not raise an exception" do
|
@@ -25,7 +25,7 @@ describe "PostgresAdapter#contents dependence on password file ~/.pgpass" do
|
|
25
25
|
before do
|
26
26
|
ActiveRecord::Base.configurations[Rails.env].merge!({"password" => "sekret"})
|
27
27
|
allow(File).to receive(:exists?)
|
28
|
-
allow(File).to receive(:exists?).with("~/.pgpass").and_return(false)
|
28
|
+
allow(File).to receive(:exists?).with(File.expand_path("~/.pgpass")).and_return(false)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should raise an exception" do
|
@@ -38,12 +38,31 @@ describe "PostgresAdapter#contents dependence on password file ~/.pgpass" do
|
|
38
38
|
ActiveRecord::Base.configurations[Rails.env].merge!({"password" => "sekret"})
|
39
39
|
allow(File).to receive(:exists?)
|
40
40
|
allow(File).to receive(:exists?).with(File.expand_path("~/.pgpass")).and_return(true)
|
41
|
+
status = Struct.new(:mode).new(33152) # octal: 100600
|
42
|
+
allow(File).to receive(:stat)
|
43
|
+
allow(File).to receive(:stat).with(File.expand_path("~/.pgpass")).and_return(status)
|
41
44
|
end
|
42
45
|
|
43
46
|
it "should not raise an exception" do
|
44
47
|
expect{ ApplicationDatabase.new.contents }.not_to raise_exception
|
45
48
|
end
|
46
49
|
end
|
50
|
+
|
51
|
+
context "pgpass file has incorrect permissions" do
|
52
|
+
before do
|
53
|
+
ActiveRecord::Base.configurations[Rails.env].merge!({"password" => "sekret"})
|
54
|
+
allow(File).to receive(:exists?)
|
55
|
+
allow(File).to receive(:exists?).with(File.expand_path("~/.pgpass")).and_return(true)
|
56
|
+
status = Struct.new(:mode).new(33204) # octal: 100664
|
57
|
+
allow(File).to receive(:stat)
|
58
|
+
allow(File).to receive(:stat).with(File.expand_path("~/.pgpass")).and_return(status)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should raise an exception" do
|
62
|
+
expect{ ApplicationDatabase.new.contents }.to raise_exception ApplicationDatabase::PostgresAdapter::PgPassFilePermissionsError
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
47
66
|
end
|
48
67
|
|
49
68
|
describe "PostgresAdapter#create_object_restoral_list_omitting_exclusions" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glacier_on_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Les Nightingill
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|