forked from open-policy-agent/opa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
322cdd5
commit 4b62709
Showing
2 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters