From 233d23a527f6eebd29324618e1c53de574256f39 Mon Sep 17 00:00:00 2001 From: Miroslav Prasil Date: Wed, 18 Jul 2018 11:54:33 +0100 Subject: [PATCH 1/2] Return 404 in case the path doesn't match instead of 500 --- src/api/web.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/api/web.rs b/src/api/web.rs index 8c4ae0a..33a8d30 100644 --- a/src/api/web.rs +++ b/src/api/web.rs @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf}; use rocket::request::Request; use rocket::response::{self, NamedFile, Responder}; use rocket::response::content::Content; -use rocket::http::ContentType; +use rocket::http::{ContentType, Status}; use rocket::Route; use rocket_contrib::{Json, Value}; @@ -49,14 +49,19 @@ struct WebHeaders(R); impl<'r, R: Responder<'r>> Responder<'r> for WebHeaders { fn respond_to(self, req: &Request) -> response::Result<'r> { - let mut res = self.0.respond_to(req)?; + match self.0.respond_to(req) { + Ok(mut res) => { + res.set_raw_header("Referrer-Policy", "same-origin"); + res.set_raw_header("X-Frame-Options", "SAMEORIGIN"); + res.set_raw_header("X-Content-Type-Options", "nosniff"); + res.set_raw_header("X-XSS-Protection", "1; mode=block"); - res.set_raw_header("Referrer-Policy", "same-origin"); - res.set_raw_header("X-Frame-Options", "SAMEORIGIN"); - res.set_raw_header("X-Content-Type-Options", "nosniff"); - res.set_raw_header("X-XSS-Protection", "1; mode=block"); - - Ok(res) + Ok(res) + }, + Err(_) => { + Err(Status::NotFound) + } + } } } From 2dc1427027cb2c5436ec8ebc4d11d6b0964d803a Mon Sep 17 00:00:00 2001 From: Miroslav Prasil Date: Wed, 18 Jul 2018 12:04:48 +0100 Subject: [PATCH 2/2] Bump the version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2fda83d..31445dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bitwarden_rs" -version = "0.10.0" +version = "0.11.0" authors = ["Daniel GarcĂ­a "] [dependencies]