in tools/stix-to-ecs/extra/clean_stix.py [0:0]
def cleaning_callback(node: typing.Any) -> typing.Any:
"""
The function clean (or correct) a Json node if possible according to the following rules:
- "x_open_cti_*" -> "x_*".
- "white" -> "clear".
:param: The Json node to be processed.
:return: The Json node post processing.
"""
if type(node) is dict:
for k in list(node.keys()):
if k.startswith(OPENCTI):
node[k.replace(OPENCTI, "x_")] = node.pop(k)
if k == "name" or k == "tlp":
if (tmp := node[k].lower()).endswith(OLD_TLP):
tmp = tmp.replace(OLD_TLP, NEW_TLP)
node[k] = tmp.upper() if node[k].isupper() else tmp
return node