SIGN IN SIGN UP

sdk: Fix decision log masking of input object

The sdk package allows you to pass arbitrary Go objects as the input
document. This is fine for evaluation (as long as the object can be
parsed to an AST), but is problematic for decision log masking, as the
masking logic expects the input on the event to be either a
map[string]interface{} or a []interface{}, and for inner types of the
object to also be similarly generic. Currently, the decision log masking
silently fails if the input object is not of the correct type.

This patch addresses this by rebuilding the input Go type for the
decision log from the parsed AST of the original input object. This
generates a Go type that does not break the masking logic, provided the
input is of a type that can be masked. The conversion from the AST only
happens if the decision logs plugin is actually registered with the
manager to avoid wasting cycles if decision logs are not enabled.

A test is added to cover the masking case for the SDK.

Signed-off-by: Erik Paulson <epaulson10@gmail.com>
E
Erik Paulson committed
4b627094e1894fa48846cb08cf1dd9689460b5b6
Parent: 322cdd5
Committed by Ashutosh Narkar <anarkar4387@gmail.com> on 7/14/2023, 6:59:14 PM