File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,10 +165,15 @@ def importAsmtFromTar
165165 redirect_to ( action : "install_assessment" )
166166 return
167167 end
168+ rescue SyntaxError => e
169+ flash [ :error ] = "Error parsing assessment configuration file:"
170+ # escape so that <compiled> doesn't get treated as a html tag
171+ flash [ :error ] += "<br><pre>#{ CGI . escapeHTML e . to_s } </pre>"
172+ flash [ :html_safe ] = true
173+ redirect_to ( action : "install_assessment" ) && return
168174 rescue StandardError => e
169175 flash [ :error ] = "Error while reading the tarball -- #{ e . message } ."
170- redirect_to ( action : "install_assessment" )
171- return
176+ redirect_to ( action : "install_assessment" ) && return
172177 end
173178
174179 # Check if the assessment already exists.
@@ -925,7 +930,15 @@ def valid_asmt_tar(tar_extract)
925930 else
926931 return false unless asmt_name
927932
928- asmt_rb_exists = true if pathname == "#{ asmt_name } /#{ asmt_name } .rb"
933+ if pathname == "#{ asmt_name } /#{ asmt_name } .rb"
934+ # We only ever read once, so no need to rewind after
935+ config_source = entry . read
936+
937+ # validate syntax of config
938+ RubyVM ::InstructionSequence . compile ( config_source )
939+
940+ asmt_rb_exists = true
941+ end
929942 asmt_yml_exists = true if pathname == "#{ asmt_name } /#{ asmt_name } .yml"
930943 end
931944 end
You can’t perform that action at this time.
0 commit comments