Format and process the extra attribute value.
(key, value)
| 71 | |
| 72 | |
| 73 | def process_attribute_value(key, value): |
| 74 | """ |
| 75 | Format and process the extra attribute value. |
| 76 | """ |
| 77 | if not cfg.CONF.log.mask_secrets: |
| 78 | return value |
| 79 | |
| 80 | blacklisted_attribute_names = ( |
| 81 | MASKED_ATTRIBUTES_BLACKLIST + cfg.CONF.log.mask_secrets_blacklist |
| 82 | ) |
| 83 | |
| 84 | # NOTE: This can be expensive when processing large dicts or objects |
| 85 | if isinstance(value, SIMPLE_TYPES): |
| 86 | if key in blacklisted_attribute_names: |
| 87 | value = MASKED_ATTRIBUTE_VALUE |
| 88 | elif isinstance(value, dict): |
| 89 | # Note: We don't want to modify the original value |
| 90 | value = fast_deepcopy_dict(value) |
| 91 | |
| 92 | for dict_key, dict_value in six.iteritems(value): |
| 93 | value[dict_key] = process_attribute_value(key=dict_key, value=dict_value) |
| 94 | |
| 95 | return value |
| 96 | |
| 97 | |
| 98 | class ObjectJSONEncoder(json.JSONEncoder): |
no test coverage detected