本文整理汇总了Python中st2common.util.secrets.get_secret_parameters函数的典型用法代码示例。如果您正苦于以下问题:Python get_secret_parameters函数的具体用法?Python get_secret_parameters怎么用?Python get_secret_parameters使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_secret_parameters函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mask_secrets
def mask_secrets(self, value):
result = copy.deepcopy(value)
runner_parameters = result['runner_parameters']
action_parameters = result['action_parameters']
runner_parameters_specs = self._runner_type_db.runner_parameters
action_parameters_sepcs = self._action_db.parameters
secret_runner_parameters = get_secret_parameters(parameters=runner_parameters_specs)
secret_action_parameters = get_secret_parameters(parameters=action_parameters_sepcs)
runner_parameters = mask_secret_parameters(parameters=runner_parameters,
secret_parameters=secret_runner_parameters)
action_parameters = mask_secret_parameters(parameters=action_parameters,
secret_parameters=secret_action_parameters)
result['runner_parameters'] = runner_parameters
result['action_parameters'] = action_parameters
return result
示例2: mask_secrets
def mask_secrets(self, value):
result = copy.deepcopy(value)
execution_parameters = value['parameters']
parameters = {}
# pylint: disable=no-member
parameters.update(value.get('action', {}).get('parameters', {}))
parameters.update(value.get('runner', {}).get('runner_parameters', {}))
secret_parameters = get_secret_parameters(parameters=parameters)
result['parameters'] = mask_secret_parameters(parameters=execution_parameters,
secret_parameters=secret_parameters)
return result
示例3: mask_secrets
def mask_secrets(self, value):
result = copy.deepcopy(value)
liveaction = result['liveaction']
parameters = {}
# pylint: disable=no-member
parameters.update(value.get('action', {}).get('parameters', {}))
parameters.update(value.get('runner', {}).get('runner_parameters', {}))
secret_parameters = get_secret_parameters(parameters=parameters)
result['parameters'] = mask_secret_parameters(parameters=result.get('parameters', {}),
secret_parameters=secret_parameters)
if 'parameters' in liveaction:
liveaction['parameters'] = mask_secret_parameters(parameters=liveaction['parameters'],
secret_parameters=secret_parameters)
if liveaction.get('action', '') == 'st2.inquiry.respond':
# Special case to mask parameters for `st2.inquiry.respond` action
# In this case, this execution is just a plain python action, not
# an inquiry, so we don't natively have a handle on the response
# schema.
#
# To prevent leakage, we can just mask all response fields.
#
# Note: The 'string' type in secret_parameters doesn't matter,
# it's just a placeholder to tell mask_secret_parameters()
# that this parameter is indeed a secret parameter and to
# mask it.
result['parameters']['response'] = mask_secret_parameters(
parameters=liveaction['parameters']['response'],
secret_parameters={p: 'string' for p in liveaction['parameters']['response']}
)
# TODO(mierdin): This logic should be moved to the dedicated Inquiry
# data model once it exists.
if self.runner.get('name') == "inquirer":
schema = result['result'].get('schema', {})
response = result['result'].get('response', {})
# We can only mask response secrets if response and schema exist and are
# not empty
if response and schema:
result['result']['response'] = mask_inquiry_response(response, schema)
return result
示例4: mask_secrets
def mask_secrets(self, value):
"""
Process the model dictionary and mask secret values.
:type value: ``dict``
:param value: Document dictionary.
:rtype: ``dict``
"""
result = copy.deepcopy(value)
config_schema = config_schema_access.get_by_pack(result['pack'])
secret_parameters = get_secret_parameters(parameters=config_schema.attributes)
result['values'] = mask_secret_parameters(parameters=result['values'],
secret_parameters=secret_parameters)
return result
示例5: mask_secrets
def mask_secrets(self, value):
from st2common.util import action_db
result = copy.deepcopy(value)
execution_parameters = value['parameters']
# TODO: This results into two DB looks, we should cache action and runner type object
# for each liveaction...
#
# ,-'"-.
# . f .--. \
# .\._,\._',' j_
# 7______""-'__`,
parameters = action_db.get_action_parameters_specs(action_ref=self.action)
secret_parameters = get_secret_parameters(parameters=parameters)
result['parameters'] = mask_secret_parameters(parameters=execution_parameters,
secret_parameters=secret_parameters)
return result
示例6: test_get_secret_parameters_secret_nested_objects
def test_get_secret_parameters_secret_nested_objects(self):
result = secrets.get_secret_parameters(TEST_SECRET_NESTED_OBJECTS_SCHEMA)
self.assertEqual(TEST_SECRET_NESTED_OBJECTS_SECRET_PARAMS, result)
示例7: test_get_secret_parameters_secret_root_object
def test_get_secret_parameters_secret_root_object(self):
result = secrets.get_secret_parameters(TEST_SECRET_ROOT_OBJECT_SCHEMA)
self.assertEqual(TEST_SECRET_ROOT_OBJECT_SECRET_PARAMS, result)
示例8: test_get_secret_parameters_secret_nested_arrays
def test_get_secret_parameters_secret_nested_arrays(self):
result = secrets.get_secret_parameters(TEST_SECRET_NESTED_ARRAYS_SCHEMA)
self.assertEqual(TEST_SECRET_NESTED_ARRAYS_SECRET_PARAMS, result)
示例9: test_get_secret_parameters_secret_root_array
def test_get_secret_parameters_secret_root_array(self):
result = secrets.get_secret_parameters(TEST_SECRET_ROOT_ARRAY_SCHEMA)
self.assertEqual(TEST_SECRET_ROOT_ARRAY_SECRET_PARAMS, result)
示例10: test_get_secret_parameters_nested_array_with_object
def test_get_secret_parameters_nested_array_with_object(self):
result = secrets.get_secret_parameters(TEST_NESTED_ARRAY_WITH_OBJECT_SCHEMA)
self.assertEqual(TEST_NESTED_ARRAY_WITH_OBJECT_SECRET_PARAMS, result)
示例11: test_get_secret_parameters_nested_object_with_double_array
def test_get_secret_parameters_nested_object_with_double_array(self):
result = secrets.get_secret_parameters(TEST_NESTED_OBJECT_WITH_DOUBLE_ARRAY_SCHEMA)
self.assertEqual(TEST_NESTED_OBJECT_WITH_DOUBLE_ARRAY_SECRET_PARAMS, result)
示例12: test_get_secret_parameters_no_secrets
def test_get_secret_parameters_no_secrets(self):
result = secrets.get_secret_parameters(TEST_NO_SECRETS_SCHEMA)
self.assertEqual(TEST_NO_SECRETS_SECRET_PARAMS, result)
示例13: test_get_secret_parameters_flat
def test_get_secret_parameters_flat(self):
result = secrets.get_secret_parameters(TEST_FLAT_SCHEMA)
self.assertEqual(TEST_FLAT_SECRET_PARAMS, result)