From e710452eacecafc02bbc91da44d37f27c5ba5e25 Mon Sep 17 00:00:00 2001 From: Tim Bruijnzeels Date: Tue, 10 Sep 2019 21:26:35 +0200 Subject: [PATCH] Quick fix for issue where '-' in handle name is not accepted. See issue #83 for remaining work. --- client/src/options.rs | 15 ++++++++++++++- daemon/src/http/mod.rs | 2 +- daemon/src/http/server.rs | 3 --- pubd/src/lib.rs | 2 +- pubd/src/pubserver.rs | 8 ++++++-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/client/src/options.rs b/client/src/options.rs index d17e2652..23448e8c 100644 --- a/client/src/options.rs +++ b/client/src/options.rs @@ -397,7 +397,17 @@ impl Options { if let Some(m) = matches.subcommand_matches("cas") { if let Some(m) = m.subcommand_matches("add") { - let handle = Handle::from(m.value_of("handle").unwrap()); + let handle_str = m.value_of("handle").unwrap(); + + // TODO: Issue #83 Allow '\' and '/' as well as per RFC 8183 + if !handle_str + .bytes() + .all(|b| b.is_ascii_alphanumeric() || b == b'_' || b == b'-') + { + return Err(Error::InvalidHandle); + } + + let handle = Handle::from(handle_str); let token = Token::from(m.value_of("token").unwrap()); let pub_mode = CertAuthPubMode::Embedded; @@ -690,6 +700,9 @@ pub enum Error { #[display(fmt = "{}", _0)] InvalidRouteDelta(AuthorizationFmtError), + + #[display(fmt = "The publisher handle may only contain -_A-Za-z0-9, (\\ /) see issue #83")] + InvalidHandle, } impl From for Error { diff --git a/daemon/src/http/mod.rs b/daemon/src/http/mod.rs index fd66b034..02c30332 100644 --- a/daemon/src/http/mod.rs +++ b/daemon/src/http/mod.rs @@ -1,2 +1,2 @@ pub mod server; -pub mod ssl; \ No newline at end of file +pub mod ssl; diff --git a/daemon/src/http/server.rs b/daemon/src/http/server.rs index e817dd60..2c09943f 100644 --- a/daemon/src/http/server.rs +++ b/daemon/src/http/server.rs @@ -96,13 +96,10 @@ pub fn start(config: &Config) -> Result<(), Error> { .data(web::Json::::configure(|cfg| { cfg.limit(256 * 1024 * 1024) })) - // Identity exchanges for remote publishers .route("/rfc8181/{handle}", post().to(rfc8181)) - // Provisioning for remote krill clients .route("/rfc6492/{handle}", post().to(rfc6492)) - // RRDP repository .route("/rrdp/{path:.*}", get().to(serve_rrdp_files)) .route( diff --git a/pubd/src/lib.rs b/pubd/src/lib.rs index 149cda3d..56f3163d 100644 --- a/pubd/src/lib.rs +++ b/pubd/src/lib.rs @@ -6,8 +6,8 @@ extern crate rand; extern crate rpki; #[macro_use] extern crate serde; -extern crate uuid; extern crate krill_commons; +extern crate uuid; pub mod publishers; pub mod repo; diff --git a/pubd/src/pubserver.rs b/pubd/src/pubserver.rs index bb5e6955..ee9c55d1 100644 --- a/pubd/src/pubserver.rs +++ b/pubd/src/pubserver.rs @@ -141,7 +141,11 @@ impl PubServer { fn verify_handle(&self, handle: &Handle) -> Result<(), Error> { let name = handle.as_str(); - if !name.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'_') { + // TODO: Issue #83 Allow '\' and '/' as well as per RFC 8183 + if !name + .bytes() + .all(|b| b.is_ascii_alphanumeric() || b == b'_' || b == b'-') + { return Err(Error::InvalidHandle(name.to_string())); } @@ -246,7 +250,7 @@ pub enum Error { IoError(io::Error), #[display( - fmt = "The publisher handle may only contain a-ZA-Z0-9 and _. You sent: {}", + fmt = "The publisher handle may only contain -_A-Za-z0-9, (\\ /) see issue #83, got: {}", _0 )] InvalidHandle(String),