Skip to content
Merged
Changes from 6 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7589139
Secret masking in output_schema feature is added
shivani-orch Apr 29, 2021
4495271
Update test_util_output_schema.py
mahesh-orch Apr 29, 2021
475d631
Update output_schema.py
mahesh-orch May 10, 2021
335d993
Update test_util_output_schema.py
mahesh-orch May 10, 2021
bc7eaeb
Merge branch 'StackStorm:master' into secret_masking
mahesh-orch May 10, 2021
78fad6b
Update execution.py
mahesh-orch May 10, 2021
b4ae25a
Merge branch 'StackStorm:master' into secret_masking
mahesh-orch May 12, 2021
2720762
Moving logic to /st2common/models/db/execution.py
mahesh-orch May 12, 2021
4511f05
added code for masking output schema secret params
mahesh-orch May 12, 2021
1e38f98
adding a unit test and updating existing tests
mahesh-orch May 12, 2021
8f8822a
Update st2common/st2common/models/api/execution.py
mahesh-orch May 12, 2021
a97f531
Update st2common/st2common/models/api/execution.py
mahesh-orch May 12, 2021
f65c27d
Adding blank lines in st2common/st2common/models/api/execution.py
mahesh-orch May 12, 2021
b220ae4
Updating /st2common/tests/unit/test_db_execution.py
mahesh-orch May 12, 2021
86ae3cf
Add unit tests to cover masking of output for various action runners
m4dcoder May 15, 2021
38b46a5
Minor clean up to codes added for troubleshooting
m4dcoder May 15, 2021
71ff4bf
shifted output schema secret masking block
mahesh-orch May 15, 2021
adc1afd
Moved output masking block to output_schema.py
mahesh-orch May 15, 2021
4ef3765
added unit tests for mask secret output
mahesh-orch May 15, 2021
67461d9
adding new file
mahesh-orch May 15, 2021
2006d26
adding new file
mahesh-orch May 15, 2021
d9a1f84
updating my_action.yaml
mahesh-orch May 15, 2021
83d3214
updating test_output_schema.py
mahesh-orch May 15, 2021
217b5b2
updating dummy_pack_1/my_action.py
mahesh-orch May 15, 2021
fd4399c
updating output_schema.py for using output_key
mahesh-orch May 17, 2021
3a97ad1
Refactor mask_secret_output function to be more robust
m4dcoder May 17, 2021
241cdca
Minor fix to test on number of actions
m4dcoder May 17, 2021
0f3b105
Merge remote-tracking branch 'origin' into secret_masking
m4dcoder May 17, 2021
66afa34
adding a workflow unit test for ouptut schema
mahesh-orch May 18, 2021
5f99494
adding python action for workflow test
mahesh-orch May 18, 2021
399a8ab
adding workflow for unit test for output schema
mahesh-orch May 18, 2021
ab92762
adding action with output schema
mahesh-orch May 18, 2021
46f11c6
adding python action with output schema
mahesh-orch May 18, 2021
add83a0
updating test_data_flow.py
mahesh-orch May 18, 2021
7739f23
updating test_data_flow.py
mahesh-orch May 19, 2021
024b038
adding unit tests for GET API for output schema
mahesh-orch May 20, 2021
595df23
Refactor the test case for testing secret output in task of workflow
m4dcoder May 20, 2021
674f3c3
Minor fix to output schema unit test due to changes in a workflow
m4dcoder May 20, 2021
914a566
Add entry to CHANGELOG for masking of secrets in execution output
m4dcoder May 20, 2021
386b252
Removed unused test fixtures
m4dcoder May 20, 2021
b8402b4
Fix masking of secret output for workflows
m4dcoder May 20, 2021
dc65601
Minor fix to show_secrets param in get_one of output controller
m4dcoder May 20, 2021
575eae9
Add PR # to the changelog entry
m4dcoder May 20, 2021
5c2fe79
Merge remote-tracking branch 'origin' into secret_masking
m4dcoder May 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions st2common/st2common/models/api/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from st2common.models.api.action import RunnerTypeAPI, ActionAPI, LiveActionAPI
from st2common import log as logging
from st2common.util.deep_copy import fast_deepcopy_dict
from st2common.constants.secrets import MASKED_ATTRIBUTE_VALUE

__all__ = ["ActionExecutionAPI", "ActionExecutionOutputAPI"]

Expand Down Expand Up @@ -151,10 +152,35 @@ class ActionExecutionAPI(BaseAPI):

@classmethod
def from_model(cls, model, mask_secrets=False):
doc = cls._from_model(model, mask_secrets=mask_secrets)
"""
Retrieve provided DB model instance and create API model class instance for the same.

:param model: DB model class instance.
:type model: :class: ``ActionExecutionDB``

doc["result"] = ActionExecutionDB.result.parse_field_value(doc["result"])
:param mask_secrets: flag to mask the secrets or not.
:type mask_secrets: ``boolean``

:return: cls(**attrs): to be displayed in CLI or Web UI with masked secrets.
:rtype: class: ``ActionExecutionAPI``
"""

doc = cls._from_model(model, mask_secrets=mask_secrets)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mahesh-orch If you follow _from_model, you'll see that there is already a line that mask secrets at https://github.com/StackStorm/st2/blob/master/st2common/st2common/models/api/base.py#L118. This calls a model specific function to mask secrets. The specific function for ActionExecutionDB is at https://github.com/StackStorm/st2/blob/master/st2common/st2common/models/db/execution.py#L107. Can you move the logic for output schema into this function?

output_schema_result = ActionExecutionDB.result.parse_field_value(doc["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 in doc["action"]["output_schema"]:
if (
doc.get("action", {})
.get("output_schema", {})
.get(key)
.get("secret", False)
):
output_schema_result["result"][key] = MASKED_ATTRIBUTE_VALUE

doc["result"] = output_schema_result
start_timestamp = model.start_timestamp
start_timestamp_iso = isotime.format(start_timestamp, offset=False)
doc["start_timestamp"] = start_timestamp_iso
Expand Down