From 5e252d8b1708fac97ae612380391bafa7020f51f Mon Sep 17 00:00:00 2001 From: Rodolphe Breard Date: Sun, 5 May 2019 21:18:40 +0200 Subject: [PATCH] Forbid unknown configuration fields If a configuration field has a typo in its name, the configuration should show an error message instead of silently ignoring this field, which could create unwanted behavior. --- acmed/src/config.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/acmed/src/config.rs b/acmed/src/config.rs index 449b1ae..e7046f1 100644 --- a/acmed/src/config.rs +++ b/acmed/src/config.rs @@ -9,6 +9,7 @@ use std::io::prelude::*; use std::path::Path; #[derive(Deserialize)] +#[serde(deny_unknown_fields)] pub struct Config { pub global: Option, pub endpoint: Vec, @@ -110,6 +111,7 @@ impl Config { } #[derive(Deserialize)] +#[serde(deny_unknown_fields)] pub struct GlobalOptions { pub accounts_directory: Option, pub certificates_directory: Option, @@ -122,6 +124,7 @@ pub struct GlobalOptions { } #[derive(Clone, Deserialize)] +#[serde(deny_unknown_fields)] pub struct Endpoint { pub name: String, pub url: String, @@ -129,6 +132,7 @@ pub struct Endpoint { } #[derive(Deserialize)] +#[serde(deny_unknown_fields)] pub struct Hook { pub name: String, #[serde(rename = "type")] @@ -163,18 +167,21 @@ pub enum HookType { } #[derive(Deserialize)] +#[serde(deny_unknown_fields)] pub struct Group { pub name: String, pub hooks: Vec, } #[derive(Clone, Debug, Deserialize)] +#[serde(deny_unknown_fields)] pub struct Account { pub name: String, pub email: String, } #[derive(Deserialize)] +#[serde(deny_unknown_fields)] pub struct Certificate { pub account: String, pub endpoint: String, @@ -271,6 +278,7 @@ impl Certificate { } #[derive(Clone, Debug, Deserialize)] +#[serde(deny_unknown_fields)] pub struct Domain { pub challenge: String, pub dns: String,