mirror of https://github.com/Icinga/icinga2.git
Fix config parser ignoring forbidden "ignore" in template definition
fixes #9535
This commit is contained in:
parent
61006d8a32
commit
b4236091f9
|
@ -456,6 +456,7 @@ object:
|
||||||
{
|
{
|
||||||
context->m_ObjectAssign.push(true);
|
context->m_ObjectAssign.push(true);
|
||||||
context->m_SeenAssign.push(false);
|
context->m_SeenAssign.push(false);
|
||||||
|
context->m_SeenIgnore.push(false);
|
||||||
context->m_Assign.push(NULL);
|
context->m_Assign.push(NULL);
|
||||||
context->m_Ignore.push(NULL);
|
context->m_Ignore.push(NULL);
|
||||||
}
|
}
|
||||||
|
@ -473,6 +474,9 @@ object:
|
||||||
bool seen_assign = context->m_SeenAssign.top();
|
bool seen_assign = context->m_SeenAssign.top();
|
||||||
context->m_SeenAssign.pop();
|
context->m_SeenAssign.pop();
|
||||||
|
|
||||||
|
bool seen_ignore = context->m_SeenIgnore.top();
|
||||||
|
context->m_SeenIgnore.pop();
|
||||||
|
|
||||||
Expression *ignore = context->m_Ignore.top();
|
Expression *ignore = context->m_Ignore.top();
|
||||||
context->m_Ignore.pop();
|
context->m_Ignore.pop();
|
||||||
|
|
||||||
|
@ -491,6 +495,9 @@ object:
|
||||||
filter = new LogicalAndExpression(assign, rex, DebugInfoRange(@2, @5));
|
filter = new LogicalAndExpression(assign, rex, DebugInfoRange(@2, @5));
|
||||||
} else
|
} else
|
||||||
filter = assign;
|
filter = assign;
|
||||||
|
} else if (seen_ignore) {
|
||||||
|
if (!ObjectRule::IsValidSourceType(type))
|
||||||
|
BOOST_THROW_EXCEPTION(ScriptError("object rule 'ignore' cannot be used for type '" + type + "'", DebugInfoRange(@2, @4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$$ = new ObjectExpression(abstract, type, $4, filter, context->GetZone(), $5, $6, DebugInfoRange(@2, @5));
|
$$ = new ObjectExpression(abstract, type, $4, filter, context->GetZone(), $5, $6, DebugInfoRange(@2, @5));
|
||||||
|
@ -600,6 +607,8 @@ lterm: type
|
||||||
if ((context->m_Apply.empty() || !context->m_Apply.top()) && (context->m_ObjectAssign.empty() || !context->m_ObjectAssign.top()))
|
if ((context->m_Apply.empty() || !context->m_Apply.top()) && (context->m_ObjectAssign.empty() || !context->m_ObjectAssign.top()))
|
||||||
BOOST_THROW_EXCEPTION(ScriptError("'ignore' keyword not valid in this context.", @$));
|
BOOST_THROW_EXCEPTION(ScriptError("'ignore' keyword not valid in this context.", @$));
|
||||||
|
|
||||||
|
context->m_SeenIgnore.top() = true;
|
||||||
|
|
||||||
if (context->m_Ignore.top())
|
if (context->m_Ignore.top())
|
||||||
context->m_Ignore.top() = new LogicalOrExpression(context->m_Ignore.top(), $3, @$);
|
context->m_Ignore.top() = new LogicalOrExpression(context->m_Ignore.top(), $3, @$);
|
||||||
else
|
else
|
||||||
|
@ -1041,6 +1050,7 @@ apply:
|
||||||
{
|
{
|
||||||
context->m_Apply.push(true);
|
context->m_Apply.push(true);
|
||||||
context->m_SeenAssign.push(false);
|
context->m_SeenAssign.push(false);
|
||||||
|
context->m_SeenIgnore.push(false);
|
||||||
context->m_Assign.push(NULL);
|
context->m_Assign.push(NULL);
|
||||||
context->m_Ignore.push(NULL);
|
context->m_Ignore.push(NULL);
|
||||||
context->m_FKVar.push("");
|
context->m_FKVar.push("");
|
||||||
|
|
|
@ -130,6 +130,7 @@ public:
|
||||||
std::stack<bool> m_Apply;
|
std::stack<bool> m_Apply;
|
||||||
std::stack<bool> m_ObjectAssign;
|
std::stack<bool> m_ObjectAssign;
|
||||||
std::stack<bool> m_SeenAssign;
|
std::stack<bool> m_SeenAssign;
|
||||||
|
std::stack<bool> m_SeenIgnore;
|
||||||
std::stack<Expression *> m_Assign;
|
std::stack<Expression *> m_Assign;
|
||||||
std::stack<Expression *> m_Ignore;
|
std::stack<Expression *> m_Ignore;
|
||||||
std::stack<String> m_FKVar;
|
std::stack<String> m_FKVar;
|
||||||
|
|
Loading…
Reference in New Issue