From a1ec4579fefcfe4c19af66748a51c3e2aeed6a58 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Thu, 16 Feb 2023 23:56:19 +0100 Subject: [PATCH] Properly cancel code execution if running is prohibited --- .rubocop_todo.yml | 2 +- app/controllers/submissions_controller.rb | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f7ea2557..2518e7ae 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -20,7 +20,7 @@ Metrics/CyclomaticComplexity: Max: 20 Metrics/PerceivedComplexity: - Max: 23 + Max: 25 # We don't want to change previous migrations... # diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 3465bfa0..0404a314 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -110,7 +110,7 @@ class SubmissionsController < ApplicationController client_socket = tubesock client_socket.onopen do |_event| - return kill_client_socket(client_socket) if @embed_options[:disable_run] + kill_client_socket(client_socket) and return true if @embed_options[:disable_run] end client_socket.onclose do |_event| @@ -160,6 +160,9 @@ class SubmissionsController < ApplicationController end end + # If running is not allowed (and the socket is closed), we can stop here. + return true if @embed_options[:disable_run] + @testrun[:output] = +'' durations = @submission.run(@file) do |socket, starting_time| runner_socket = socket