From: Alexander A. Klimov Date: Tue, 16 Apr 2019 13:53:44 +0000 (+0200) Subject: FilterUtility::EvaluateFilter(): ensure not to modify the global namespace X-Git-Tag: v2.11.0-rc1~149^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bdadb53940f1187d60a4679675af164dbb63f37c;p=icinga2 FilterUtility::EvaluateFilter(): ensure not to modify the global namespace --- diff --git a/lib/remote/filterutility.cpp b/lib/remote/filterutility.cpp index c74af5be3..4493012f1 100644 --- a/lib/remote/filterutility.cpp +++ b/lib/remote/filterutility.cpp @@ -89,6 +89,8 @@ bool FilterUtility::EvaluateFilter(ScriptFrame& frame, Expression *filter, ASSERT(frame.Self.IsObjectType()); frameNS = frame.Self; + + ASSERT(frameNS != ScriptGlobal::GetGlobals()); } frameNS->Set("obj", target); @@ -238,9 +240,9 @@ std::vector FilterUtility::GetFilterTargets(const QueryDescription& qd, c if (qd.Types.find(type) == qd.Types.end()) BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type specified for this query.")); - ScriptFrame frame(true); - frame.Sandboxed = true; Namespace::Ptr frameNS = new Namespace(); + ScriptFrame frame(true, frameNS); + frame.Sandboxed = true; if (query->Contains("filter")) { String filter = HttpUtility::GetLastParameter(query, "filter"); @@ -254,8 +256,6 @@ std::vector FilterUtility::GetFilterTargets(const QueryDescription& qd, c } } - frame.Self = frameNS; - provider->FindTargets(type, std::bind(&FilteredAddTarget, std::ref(permissionFrame), permissionFilter, std::ref(frame), &*ufilter, std::ref(result), variableName, _1));