From 2cc33b7fb38bb897c57da3bee1cf875385e92633 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 10 Nov 2015 07:59:10 +0100 Subject: [PATCH] Don't validate arguments/parameters that aren't strings refs #10539 --- lib/base/object.cpp | 2 +- lib/icinga/command.cpp | 23 +++++++---------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/lib/base/object.cpp b/lib/base/object.cpp index 4eeef78db..b15965ca7 100644 --- a/lib/base/object.cpp +++ b/lib/base/object.cpp @@ -48,7 +48,7 @@ Object::~Object(void) */ String Object::ToString(void) const { - return "Object of type '" + Utility::GetTypeName(typeid(*this)) + "'"; + return "Object of type '" + GetReflectionType()->GetName() + "'"; } #ifdef I2_DEBUG diff --git a/lib/icinga/command.cpp b/lib/icinga/command.cpp index e029322f5..1a01421bf 100644 --- a/lib/icinga/command.cpp +++ b/lib/icinga/command.cpp @@ -50,30 +50,21 @@ void Command::Validate(int types, const ValidationUtils& utils) Dictionary::Ptr argdict = arginfo; if (argdict->Contains("value")) { - String argvalue = argdict->Get("value"); + Value argvalue = argdict->Get("value"); - if (!MacroProcessor::ValidateMacroString(argvalue)) + if (argvalue.IsString() && !MacroProcessor::ValidateMacroString(argvalue)) BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("arguments")(kv.first)("value"), "Validation failed: Closing $ not found in macro format string '" + argvalue + "'.")); } if (argdict->Contains("set_if")) { - String argsetif = argdict->Get("set_if"); + Value argsetif = argdict->Get("set_if"); - if (!MacroProcessor::ValidateMacroString(argsetif)) + if (argsetif.IsString() && !MacroProcessor::ValidateMacroString(argsetif)) BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("arguments")(kv.first)("set_if"), "Closing $ not found in macro format string '" + argsetif + "'.")); } - } else if (arginfo.IsObjectType()) { - continue; /* we cannot evaluate macros in functions */ - } else { - argval = arginfo; - - if (argval.IsEmpty()) - continue; - - String argstr = argval; - - if (!MacroProcessor::ValidateMacroString(argstr)) - BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("arguments")(kv.first), "Closing $ not found in macro format string '" + argstr + "'.")); + } else if (arginfo.IsString()) { + if (!MacroProcessor::ValidateMacroString(arginfo)) + BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("arguments")(kv.first), "Closing $ not found in macro format string '" + arginfo + "'.")); } } } -- 2.40.0