Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying allowed outgoing ips #2138

Open
wants to merge 7 commits into
base: develop/firewall
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/helpers/assessment_autograde_core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,13 @@ def tango_add_job(course, assessment, upload_file_list, callback_url, job_name,
"timeout" => @autograde_prop.autograde_timeout,
"callback_url" => callback_url,
"jobName" => job_name,
"disable_network" => assessment.disable_network }.to_json
"disable_network" => assessment.disable_network
}
unless assessment.allowed_outgoing_ips.nil? || assessment.allowed_outgoing_ips.empty?
job_properties["allowed_outgoing_ips"] = assessment.allowed_outgoing_ips.split(/\s*,\s*/)
end
evanyeyeye marked this conversation as resolved.
Show resolved Hide resolved
begin
response = TangoClient.addjob("#{course.name}-#{assessment.name}", job_properties)
response = TangoClient.addjob("#{course.name}-#{assessment.name}", job_properties.to_json)
rescue TangoClient::TangoException => e
COURSE_LOGGER.log("Error while adding job to the queue: #{e.message}")
raise AutogradeError.new("Error while adding job to the queue", :tango_add_job, e.message)
Expand Down
2 changes: 2 additions & 0 deletions app/views/assessments/_edit_advanced.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<% end %>

<%= f.check_box :disable_network, help_text: "Disable network access for autograding containers." %>
<%= f.text_field :allowed_outgoing_ips,
help_text: "Specify allowed outgoing IPs for autograding containers (comma separated). If left empty, all outgoing connections are allowed." %>
<%= f.check_box :allow_unofficial,
help_text: "Allow unofficial submission. Unless you know what you're doing, leave this unchecked." %>
<%= f.check_box :embedded_quiz,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddAllowedOutgoingIPsToAssessment < ActiveRecord::Migration[6.1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work, I think Rails expects the name to be AddAllowedOutgoingIpsToAssessment with the p as lowercase.

def change
add_column :assessments, :allowed_outgoing_ips, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2024_03_16_162826) do
ActiveRecord::Schema.define(version: 2024_04_01_200408) do

create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
Expand Down Expand Up @@ -119,6 +119,7 @@
t.boolean "allow_student_assign_group", default: true
t.boolean "is_positive_grading", default: false
t.boolean "disable_network", default: false
t.string "allowed_outgoing_ips"
end

create_table "attachments", force: :cascade do |t|
Expand Down