Moved output masking block to output_schema.py
@@ -25,11 +25,11 @@ from st2common.models.db import stormbase
from st2common.fields import JSONDictEscapedFieldCompatibilityField
from st2common.fields import ComplexDateTimeField
from st2common.util import date as date_utils
+from st2common.util import output_schema
from st2common.util.secrets import get_secret_parameters
from st2common.util.secrets import mask_inquiry_response
from st2common.util.secrets import mask_secret_parameters
from st2common.constants.types import ResourceType
-from st2common.constants.secrets import MASKED_ATTRIBUTE_VALUE
__all__ = ["ActionExecutionDB", "ActionExecutionOutputDB"]
@@ -157,16 +157,10 @@ class ActionExecutionDB(stormbase.StormFoundationDB):
output_schema_result = ActionExecutionDB.result.parse_field_value(
result["result"]
)
-
- # accessing parameters marked secret as true in the output_schema
- # and masking them for the result in action execution API
- if output_schema_result:
- for key, spec in six.iteritems(result["action"]["output_schema"]):
- if spec.get("secret", False):
- # TODO: Change to output_schema_result[output_key][key] = MASKED_ATTRIBUTE_VALUE
- output_schema_result["result"][key] = MASKED_ATTRIBUTE_VALUE
-
- result["result"] = output_schema_result
+ masked_output_schema_result = output_schema.mask_secret_output(
+ value, output_schema_result
+ )
+ result["result"] = masked_output_schema_result
# TODO(mierdin): This logic should be moved to the dedicated Inquiry
# data model once it exists.
