ITADN

May missing required on `public_keys` arg for `create` command

#310ClosedRealHinome 创建于 2025-06-28
questionmlar
R
RealHinomecommented
Hello, ## Description While testing the `create` command of MLAR, I noticed that omitting the `--pubkey` (`-p`) argument causes the following runtime error: ```bs $ cargo run --bin mlar --release create --output test $DIRECTORY [!] Command ended with error: MlaError(ConfigError(EncryptionKeyIsMissing)) ``` This error is only caught later via: ```rs if let Err(err) = res { eprintln!("[!] Command ended with error: {err:?}"); std::process::exit(1); } ``` ## Fix suggestion It seems that the `public_keys` argument is not declared as required in Clap, unlike the `output` argument. Adding `.required(true)` to the `-p` / `--pubkey` arg (e.g., around [line 1042](https://github.com/ANSSI-FR/MLA/blob/master/mlar/src/main.rs#L1042)) would make the CLI more robust and provide earlier feedback to the user. If `output_args` is reused across commands and you need `-p` to remain optional elsewhere, you could define `pkey_arg` separately and inject it as required in create, like: ```rs let pkey_arg = Arg::new("public_keys") .short('p') .long("pubkey") .value_name("PUBKEY") .help("Path to the public key used for encryption") .takes_value(true); // no `.required(true)` here // In `create` command. .arg(p_key_arg.clone().required(true)) ``` This avoids breaking other commands that may use the same `output_args` structure with different requirements. There are also some minor inconsistencies in formatting (e.g., missing spaces) that could be polished for improved readability. If you'd like me to do the RP, or if it's a false positive, I'll be happy to help. It may even be another error if you don't need a key to create this archive. Regards, Hinome
关闭于 2025-06-29 6 条评论