You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: crates/tmc-langs-framework/src/plugin.rs
+25-9Lines changed: 25 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -217,6 +217,7 @@ pub trait LanguagePlugin {
217
217
/// Extracts student files from the compressed project.
218
218
/// It finds the project dir from the zip and extracts the student files from there.
219
219
/// Overwrites all files.
220
+
/// Important: does not extract .tmcproject.yml from the students' submission as they control that file and they could use it to modify the test files.
220
221
fnextract_student_files(
221
222
compressed_project:implRead + Seek,
222
223
compression:Compression,
@@ -230,15 +231,6 @@ pub trait LanguagePlugin {
230
231
let project_dir = Self::find_project_dir_in_archive(&mut archive)?;
231
232
log::debug!("Project directory in archive: {}", project_dir.display());
232
233
233
-
// extract config file if any
234
-
let tmc_project_yml_path = project_dir.join(".tmcproject.yml");
// This branch is used when a student downloads their old submission, and we take the files from the stub (the exercise template) instead of the clone path. This makes sure they cannot see the hidden tests in the downloaded file.
57
57
extract_with_filter(
58
58
plugin,
59
59
stub_zip,
@@ -70,7 +70,7 @@ pub fn prepare_submission(
70
70
false,
71
71
)?;
72
72
}else{
73
-
// else, copy clone path
73
+
// This code branch is used when we package a submission for the sandbox. We use the clone path because it contains the hidden tests, and we want the sandbox to run them.
74
74
for entry inWalkDir::new(stub_clone_path).min_depth(1){
75
75
let entry = entry?;
76
76
@@ -101,8 +101,25 @@ pub fn prepare_submission(
101
101
log::debug!("extracting student files");
102
102
let file = file_util::open_file(submission.archive)?;
103
103
if submission.extract_naively{
104
+
// If the stub contains a .tmcproject.yml, preserve it so the student's cannot override it
105
+
let tmcproject_path = extract_dest_path.join(".tmcproject.yml");
106
+
let preserved_tmcproject = if tmcproject_path.exists(){
// This code branch is used when we package a submission for the sandbox. This extraction method makes sure we don't allow the student to update the files they are not allowed to edit.
0 commit comments