Skip to content

Commit

Permalink
Move sanity checks for dangerous parameters to main.rs to ensure they…
Browse files Browse the repository at this point in the history
… are only set via command line flags. This change causes the application to panic if these parameters are set in the configuration file, enforcing the use of command line options for setting them.
  • Loading branch information
anipaul2 committed May 12, 2023
1 parent 1a89c5d commit 5e97fce
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions teos/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ async fn main() {
// Load conf (from file or defaults) and patch it with the command line parameters received (if any)
let mut conf = config::from_file::<Config>(&conf_file_path);
let is_default = conf.is_default();
if conf.overwrite_key {
eprintln!("The 'overwrite_key' parameter cannot be set in the configuration file. Please pass it as a command-line argument if necessary.");
std::process::exit(1);
}
if conf.force_update {
eprintln!("The 'force_update' parameter cannot be set in the configuration file. Please pass it as a command-line argument if necessary.");
std::process::exit(1);
}
conf.patch_with_options(opt);
conf.verify().unwrap_or_else(|e| {
eprintln!("{e}");
Expand Down

0 comments on commit 5e97fce

Please sign in to comment.