mirror of
https://github.com/splunk/security_content
synced 2026-06-08 17:32:49 +00:00
3b58b30516
Adding custom functions & playbooks
24 lines
960 B
Python
24 lines
960 B
Python
def json_safe_format(json_input=None, **kwargs):
|
|
"""
|
|
Load JSON string in a non-strict mode to allow unescaped control characters to be correctly escaped before passing them on to actions that require it.
|
|
|
|
Args:
|
|
json_input: String in JSON format with possible unescaped control characters.
|
|
|
|
Returns a JSON-serializable object that implements the configured data paths:
|
|
json_output: JSON-serializable string with correctly escaped control characters.
|
|
"""
|
|
############################ Custom Code Goes Below This Line #################################
|
|
import json
|
|
import phantom.rules as phantom
|
|
|
|
outputs = {}
|
|
|
|
safe_json = json.dumps(json.loads(json_input, strict=False))
|
|
|
|
outputs['json_output'] = safe_json
|
|
|
|
# Return a JSON-serializable object
|
|
assert json.dumps(outputs) # Will raise an exception if the :outputs: object is not JSON-serializable
|
|
return outputs
|