Skip to content

Commit

Permalink
Add disallowed files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamesthe1 committed Jan 25, 2025
1 parent 3b59871 commit db64559
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/main_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,11 @@ impl MyWindow {
return;
}

if let Err((guid, e_msg)) = Self::check_mod_security(&active_mod_files) {
self.show_popup(format!("Mod security failure: {}\nCaused by: {}", e_msg, guid), log::Level::Error);
return;
}

if let Err((guid, mod_conflicts, file_conflicts)) = Self::check_file_conflicts(&active_mod_files) {
let files_str = file_conflicts.join(", ");
let mods_str = mod_conflicts.join(", ");
Expand Down Expand Up @@ -647,6 +652,27 @@ impl MyWindow {
}
}

fn check_mod_security(active_mod_files: &Vec<ModFile>) -> Result<(), (String, String)> {
for mod_file in active_mod_files.iter() {
let guid = mod_file.metadata.guid.clone();
let mod_zip = match open_archive(&mod_file.filepath) {
Err(_) => continue,
Ok(z) => z
};

for entry in mod_zip.file_names() {
if entry.ends_with(".exe") || entry.ends_with(".dll") {
return Err((guid, format!("DISALLOWED FILE {}, REPORT IMMEDIATELY", entry)));
}

if entry == "data.win" {
return Err((guid, "data.win is not allowed to be overridden".to_string()));
}
}
}
Ok(())
}

fn validate_mod_selection(active_mod_files: &Vec<ModFile>) -> Result<(), (Vec<String>, Vec<String>)> {
let mut deps_unsatisfied: Vec<String> = vec![];
let mut mods_blame: Vec<String> = vec![];
Expand Down

0 comments on commit db64559

Please sign in to comment.