aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/commands/console
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikac.hu>2019-03-23 16:47:26 +0900
committerPrem Sichanugrist <s@sikac.hu>2019-03-23 19:31:03 +0900
commitb27105252bce6a69f6d57c05d4ea28d20e84f8ae (patch)
tree13072d72ae90d7c83597b6c832799454aba13b75 /railties/lib/rails/commands/console
parentefb706daad0e2e1039c6abb4879c837ef8bf4d10 (diff)
downloadrails-b27105252bce6a69f6d57c05d4ea28d20e84f8ae.tar.gz
rails-b27105252bce6a69f6d57c05d4ea28d20e84f8ae.tar.bz2
rails-b27105252bce6a69f6d57c05d4ea28d20e84f8ae.zip
Add config.disable_sandbox option to Rails console
A long-running `rails console --sandbox` could cause a database server to become out-of-memory as it's holding on to changes that happen on the database. Given that it's common for Ruby on Rails application with huge traffic to have separate write database and read database, we should allow the developers to disable this sandbox option to prevent someone from accidentally causing the Denial-of-Service on their server.
Diffstat (limited to 'railties/lib/rails/commands/console')
-rw-r--r--railties/lib/rails/commands/console/console_command.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/railties/lib/rails/commands/console/console_command.rb b/railties/lib/rails/commands/console/console_command.rb
index e35faa5b01..7a9eaefea1 100644
--- a/railties/lib/rails/commands/console/console_command.rb
+++ b/railties/lib/rails/commands/console/console_command.rb
@@ -26,6 +26,12 @@ module Rails
@options = options
app.sandbox = sandbox?
+
+ if sandbox? && app.config.disable_sandbox
+ puts "Error: Unable to start console in sandbox mode as sandbox mode is disabled (config.disable_sandbox is true)."
+ exit 1
+ end
+
app.load_console
@console = app.config.console || IRB