fix(cli): reject empty HMAC keys
--hmac "" silently produced an empty-byte HMAC key at the protocol boundary, so an accidentally-empty shell expansion (--hmac "$VAR") could look like auth was deliberately enabled while actually using a predictable empty key. Reject a zero-length --hmac value at parse time in the client CLI, the TUI client (via the shared CommonClientArgs), and the server CLI. Non-empty values, including whitespace-only ones, are accepted exactly as supplied.
This commit is contained in:
4 files changed
+51
-1
No files matched your search
@@ -296,6 +296,19 @@ mod tests {
|
||||
assert!(help.contains("--loose"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_empty_hmac_key_is_rejected() {
|
||||
let err = parse(&["--hmac", "", "127.0.0.1:2112"]).unwrap_err();
|
||||
assert!(err.to_string().contains("HMAC key must not be empty"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_non_empty_hmac_key_is_accepted() {
|
||||
let args = parse(&["--hmac", "secret", "127.0.0.1:2112"]).unwrap();
|
||||
let config = args.prepare().unwrap().client;
|
||||
assert_eq!(config.hmac_key, Some(b"secret".to_vec()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn output_format_summary_policy_is_table_only() {
|
||||
assert!(OutputFormat::Table.prints_summary());
|
||||
|
||||
Reference in new issue
Block a user