lib: fix complex objects being included in event context for ak_create_event

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-11-15 16:51:02 +01:00
parent e5241ac574
commit d67ec1b62f
1 changed files with 4 additions and 1 deletions

View File

@ -99,13 +99,16 @@ class BaseEvaluator:
def expr_event_create(self, action: str, **kwargs): def expr_event_create(self, action: str, **kwargs):
"""Create event with supplied data and try to extract as much relevant data """Create event with supplied data and try to extract as much relevant data
from the context""" from the context"""
# If the result was a complex variable, we don't want to re-use it
self._context.pop("result", None)
self._context.pop("handler", None)
kwargs["context"] = self._context kwargs["context"] = self._context
event = Event.new( event = Event.new(
action, action,
app=self._filename, app=self._filename,
**kwargs, **kwargs,
) )
if "request" in self._context and isinstance(PolicyRequest, self._context["request"]): if "request" in self._context and isinstance(self._context["request"], PolicyRequest):
policy_request: PolicyRequest = self._context["request"] policy_request: PolicyRequest = self._context["request"]
if policy_request.http_request: if policy_request.http_request:
event.from_http(policy_request) event.from_http(policy_request)