Skip to content

Commit

Permalink
Disable submission delete by default. Use ENABLE_SUBMISSION_DELETE co…
Browse files Browse the repository at this point in the history
…nfig variable.
  • Loading branch information
hermanzdosilovic committed Dec 31, 2019
1 parent 3365e3c commit 79e1de9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def index
end

def destroy
if !Config::ENABLE_SUBMISSION_DELETE
render json: { error: "delete not allowed" }, status: :bad_request
return
end

render_invalid_field_error and return if has_invalid_field

submission = Submission.find_by!(token: params[:token])
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Config
ENABLE_COMPILER_OPTIONS = ENV["ENABLE_COMPILER_OPTIONS"] != "false"
ALLOWED_LANGUAGES_FOR_COMPILER_OPTIONS = ENV["ALLOWED_LANGUAGES_FOR_COMPILER_OPTIONS"].to_s.strip.split
ENABLE_COMMAND_LINE_ARGUMENTS = ENV["ENABLE_COMMAND_LINE_ARGUMENTS"] != "false"
ENABLE_SUBMISSION_DELETE = ENV["ENABLE_SUBMISSION_DELETE"] == "true"
MAX_QUEUE_SIZE = (ENV['MAX_QUEUE_SIZE'].presence || 100).to_i
CPU_TIME_LIMIT = (ENV['CPU_TIME_LIMIT'].presence || 2).to_f
MAX_CPU_TIME_LIMIT = (ENV['MAX_CPU_TIME_LIMIT'].presence || 15).to_f
Expand Down Expand Up @@ -34,6 +35,7 @@ def self.config_info
"enable_compiler_options": ENABLE_COMPILER_OPTIONS,
"allowed_languages_for_compile_options": ALLOWED_LANGUAGES_FOR_COMPILER_OPTIONS,
"enable_command_line_arguments": ENABLE_COMMAND_LINE_ARGUMENTS,
"enable_submission_delete": ENABLE_SUBMISSION_DELETE,
"max_queue_size": MAX_QUEUE_SIZE,
"cpu_time_limit": CPU_TIME_LIMIT,
"max_cpu_time_limit": MAX_CPU_TIME_LIMIT,
Expand Down
6 changes: 5 additions & 1 deletion judge0-api.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ ALLOWED_LANGUAGES_FOR_COMPILER_OPTIONS=
# Default: true
ENABLE_COMMAND_LINE_ARGUMENTS=

# If enabled autorized users can delete a submission.
# Default: false
ENABLE_SUBMISSION_DELETE=

# Default runtime limit for every program (in seconds). Decimal numbers are allowed.
# Time in which the OS assigns the processor to different tasks is not counted.
# Default: 2
Expand Down Expand Up @@ -198,7 +202,7 @@ MAX_PROCESSES_AND_OR_THREADS=
MAX_MAX_PROCESSES_AND_OR_THREADS=

# If true then CPU_TIME_LIMIT will be used as per process and thread.
# Default false, i.e. CPU_TIME_LIMIT is set as a total limit for all processes and threads.
# Default: false, i.e. CPU_TIME_LIMIT is set as a total limit for all processes and threads.
ENABLE_PER_PROCESS_AND_THREAD_TIME_LIMIT=

# If false, user won't be able to set ENABLE_PER_PROCESS_AND_THREAD_TIME_LIMIT.
Expand Down

0 comments on commit 79e1de9

Please sign in to comment.