SECURITY: Remove runaway cpu/memory tests.

These should not be in the public plugin accessible via a GET. At
the very least they should require an environment variable and
CSRF protection. I'm removing them because they don't seem commonly
used.
This commit is contained in:
Robin Ward 2018-06-15 15:23:57 -04:00
parent 8f6be9c592
commit ed4b88166e
3 changed files with 2 additions and 26 deletions

View File

@ -64,7 +64,7 @@ module DockerManager
repo = DockerManager::GitRepo.find(params[:path])
raise Discourse::NotFound unless repo.present?
repo.update! if Rails.env == 'production'
repo.update_remote! if Rails.env == 'production'
render json: {
latest: {
@ -103,27 +103,5 @@ module DockerManager
end
render plain: ps_output
end
def runaway_cpu
Thread.new do
a = 1
while true
a += 1
end
end
render plain: "Killing CPU on #{Process.pid}"
end
def runaway_mem
Thread.new do
a = []
while true
a << Array.new(50_000_000 / 8)
sleep 30
end
end
render plain: "Leaking memory on #{Process.pid}"
end
end
end

View File

@ -7,7 +7,5 @@ DockerManager::Engine.routes.draw do
get "admin/docker/ps" => "admin#ps", constraints: AdminConstraint.new
post "admin/docker/upgrade" => "admin#upgrade", constraints: AdminConstraint.new
delete "admin/docker/upgrade" => "admin#reset_upgrade", constraints: AdminConstraint.new
get "admin/docker/runaway_cpu" => "admin#runaway_cpu", constraints: AdminConstraint.new
get "admin/docker/runaway_mem" => "admin#runaway_mem", constraints: AdminConstraint.new
get 'admin/docker/csrf' => 'admin#csrf', constraints: AdminConstraint.new
end

View File

@ -59,7 +59,7 @@ class DockerManager::GitRepo
url
end
def update!
def update_remote!
`cd #{path} && git remote update`
end