From da4a15a351f778afe7b00eb596501a78a2ae5caf Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 14 Jan 2020 11:22:42 +0100 Subject: [PATCH] src/api2/types.rs: define and use PASSWORD_REGEX --- src/api2/types.rs | 2 ++ src/config/remotes.rs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api2/types.rs b/src/api2/types.rs index 23753842..eb9c4310 100644 --- a/src/api2/types.rs +++ b/src/api2/types.rs @@ -32,6 +32,8 @@ const_regex!{ pub SHA256_HEX_REGEX = r"^[a-f0-9]{64}$"; // fixme: define in common_regex ? pub SYSTEMD_DATETIME_REGEX = r"^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}(:\d{2})?)?$"; // fixme: define in common_regex ? + pub PASSWORD_REGEX = r"^[[:^cntrl:]]*$"; // everything but control characters + /// Regex for safe identifiers. /// /// This diff --git a/src/config/remotes.rs b/src/config/remotes.rs index 8fc26a51..46f3b780 100644 --- a/src/config/remotes.rs +++ b/src/config/remotes.rs @@ -14,9 +14,9 @@ lazy_static! { static ref CONFIG: SectionConfig = init(); } -// fixme: define better schemas - pub const REMOTE_PASSWORD_SCHEMA: Schema = StringSchema::new("Password or auth token for remote host.") + .format(&PASSWORD_REGEX) + .min_length(1) .max_length(1024) .schema();