mirror of
https://github.com/Icinga/icinga2.git
synced 2025-06-11 01:00:22 +02:00
Improve error logging for match/regex/cidr_match functions and unsupported dictionary usage
fixes #6442
This commit is contained in:
parent
f80715c484
commit
8e682ce9b1
@ -108,10 +108,14 @@ bool ScriptUtils::CastBool(const Value& value)
|
|||||||
bool ScriptUtils::Regex(const std::vector<Value>& args)
|
bool ScriptUtils::Regex(const std::vector<Value>& args)
|
||||||
{
|
{
|
||||||
if (args.size() < 2)
|
if (args.size() < 2)
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Regular expression and text must be specified."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Regular expression and text must be specified for regex()."));
|
||||||
|
|
||||||
String pattern = args[0];
|
String pattern = args[0];
|
||||||
const Value& argTexts = args[1];
|
const Value& argTexts = args[1];
|
||||||
|
|
||||||
|
if (argTexts.IsObjectType<Dictionary>())
|
||||||
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Dictionaries are not supported by regex()."));
|
||||||
|
|
||||||
MatchType mode;
|
MatchType mode;
|
||||||
|
|
||||||
if (args.size() > 2)
|
if (args.size() > 2)
|
||||||
@ -158,10 +162,14 @@ bool ScriptUtils::Regex(const std::vector<Value>& args)
|
|||||||
bool ScriptUtils::Match(const std::vector<Value>& args)
|
bool ScriptUtils::Match(const std::vector<Value>& args)
|
||||||
{
|
{
|
||||||
if (args.size() < 2)
|
if (args.size() < 2)
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Pattern and text must be specified."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Pattern and text must be specified for match()."));
|
||||||
|
|
||||||
String pattern = args[0];
|
String pattern = args[0];
|
||||||
const Value& argTexts = args[1];
|
const Value& argTexts = args[1];
|
||||||
|
|
||||||
|
if (argTexts.IsObjectType<Dictionary>())
|
||||||
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Dictionaries are not supported by match()."));
|
||||||
|
|
||||||
MatchType mode;
|
MatchType mode;
|
||||||
|
|
||||||
if (args.size() > 2)
|
if (args.size() > 2)
|
||||||
@ -199,10 +207,14 @@ bool ScriptUtils::Match(const std::vector<Value>& args)
|
|||||||
bool ScriptUtils::CidrMatch(const std::vector<Value>& args)
|
bool ScriptUtils::CidrMatch(const std::vector<Value>& args)
|
||||||
{
|
{
|
||||||
if (args.size() < 2)
|
if (args.size() < 2)
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("CIDR and IP address must be specified."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("CIDR and IP address must be specified for cidr_match()."));
|
||||||
|
|
||||||
String pattern = args[0];
|
String pattern = args[0];
|
||||||
const Value& argIps = args[1];
|
const Value& argIps = args[1];
|
||||||
|
|
||||||
|
if (argIps.IsObjectType<Dictionary>())
|
||||||
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Dictionaries are not supported by cidr_match()."));
|
||||||
|
|
||||||
MatchType mode;
|
MatchType mode;
|
||||||
|
|
||||||
if (args.size() > 2)
|
if (args.size() > 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user