MCPcopy Create free account
hub / github.com/StackStorm/st2 / get_secret_parameters

Function get_secret_parameters

st2common/st2common/util/secrets.py:28–136  ·  view source on GitHub ↗

Filter the provided parameters dict and return a dict of parameters which are marked as secret. Every key in the dict is the parameter name and values are the parameter type: >>> d = get_secret_parameters(params) >>> d { "param_a": "string", "param_b": "boolean"

(parameters)

Source from the content-addressed store, hash-verified

26
27
28def get_secret_parameters(parameters):
29 """
30 Filter the provided parameters dict and return a dict of parameters which are marked as
31 secret. Every key in the dict is the parameter name and values are the parameter type:
32
33 >>> d = get_secret_parameters(params)
34 >>> d
35 {
36 "param_a": "string",
37 "param_b": "boolean",
38 "param_c": "integer"
39 }
40
41 If a paramter is a dictionary or a list, then the value will be a nested dictionary
42 containing information about that sub-object:
43
44 >>> d = get_secret_parameters(params)
45 >>> d
46 {
47 "param_dict": {
48 "nested_a": "boolean",
49 "nested_b": "string",
50 },
51 "param_list": {
52 "nested_dict: {
53 "param_c": "integer"
54 }
55 }
56 }
57
58 Note: in JSON Schema, we're assuming lists contain the same data type for every element
59
60
61 :param parameters: Dictionary with runner or action parameters schema specification.
62 :type parameters: ``dict``
63
64 :rtype ``list``
65 """
66
67 secret_parameters = {}
68 parameters_type = parameters.get("type")
69 # If the parameter itself is secret, then skip all processing below it
70 # and return the type of this parameter.
71 #
72 # **This causes the _full_ object / array tree to be secret (no children will be shown).**
73 #
74 # **Important** that we do this check first, so in case this parameter
75 # is an `object` or `array`, and the user wants the full thing
76 # to be secret, that it is marked as secret.
77 if parameters.get("secret", False):
78 return parameters_type
79
80 iterator = None
81 if parameters_type == "object":
82 # if this is an object, then iterate over the properties within
83 # the object
84 # result = dict
85 iterator = six.iteritems(parameters.get("properties", {}))

Callers 5

mask_secretsMethod · 0.90
mask_secretsMethod · 0.90
mask_secretsMethod · 0.90
mask_secretsMethod · 0.90
mask_secretsMethod · 0.90

Calls 1

getMethod · 0.45

Tested by

no test coverage detected