hashicorp / sentinel-sdk

This SDK allows developers to extend Sentinel to source external information for use in their policies.
Mozilla Public License 2.0
51 stars 13 forks source link

Ensure values of maps that are empty maps are string keyed #50

Closed cam-stitt closed 3 years ago

cam-stitt commented 3 years ago

There is an issue within the json import where empty map values cannot be passed at any level into the marshal method. This fixes this issue by translating any empty map value into map[string]interface{}. Although it could be argued that assuming a key type of string is a strange assumption, there should not be any side effects due to it's inherent emptiness.

Furthermore, it could be argued that this solution should be handled by the json import itself. I did not believe that to be the ideal use case as it would require heavy use of reflect in a relatively simple package. By placing it here, there is no additional reflection needed (apart from when making the map).