mirror of https://github.com/Icinga/icinga2.git
Merge pull request #7122 from Icinga/bugfix/evaluatefilter-change-globals
FilterUtility::EvaluateFilter(): ensure not to modify the global namespace
This commit is contained in:
commit
ab97d606db
|
@ -89,6 +89,8 @@ bool FilterUtility::EvaluateFilter(ScriptFrame& frame, Expression *filter,
|
||||||
ASSERT(frame.Self.IsObjectType<Namespace>());
|
ASSERT(frame.Self.IsObjectType<Namespace>());
|
||||||
|
|
||||||
frameNS = frame.Self;
|
frameNS = frame.Self;
|
||||||
|
|
||||||
|
ASSERT(frameNS != ScriptGlobal::GetGlobals());
|
||||||
}
|
}
|
||||||
|
|
||||||
frameNS->Set("obj", target);
|
frameNS->Set("obj", target);
|
||||||
|
@ -239,9 +241,9 @@ std::vector<Value> FilterUtility::GetFilterTargets(const QueryDescription& qd, c
|
||||||
if (qd.Types.find(type) == qd.Types.end())
|
if (qd.Types.find(type) == qd.Types.end())
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type specified for this query."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type specified for this query."));
|
||||||
|
|
||||||
ScriptFrame frame(true);
|
|
||||||
frame.Sandboxed = true;
|
|
||||||
Namespace::Ptr frameNS = new Namespace();
|
Namespace::Ptr frameNS = new Namespace();
|
||||||
|
ScriptFrame frame(true, frameNS);
|
||||||
|
frame.Sandboxed = true;
|
||||||
|
|
||||||
if (query->Contains("filter")) {
|
if (query->Contains("filter")) {
|
||||||
String filter = HttpUtility::GetLastParameter(query, "filter");
|
String filter = HttpUtility::GetLastParameter(query, "filter");
|
||||||
|
@ -255,8 +257,6 @@ std::vector<Value> FilterUtility::GetFilterTargets(const QueryDescription& qd, c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.Self = frameNS;
|
|
||||||
|
|
||||||
provider->FindTargets(type, std::bind(&FilteredAddTarget,
|
provider->FindTargets(type, std::bind(&FilteredAddTarget,
|
||||||
std::ref(permissionFrame), permissionFilter,
|
std::ref(permissionFrame), permissionFilter,
|
||||||
std::ref(frame), &*ufilter, std::ref(result), variableName, _1));
|
std::ref(frame), &*ufilter, std::ref(result), variableName, _1));
|
||||||
|
|
Loading…
Reference in New Issue