Closed edthedev closed 1 year ago
Here's code that's working in secops-soar-tdx:
# TODO: Move clean_env_string into the vcr_cleaner library for shared use.
def clean_env_strings(request: dict, response: dict):
clean_strings = os.environ.get('CLEAN_STRINGS', "").split(',')
if 'bytes' in str(type(response['body']['string'])):
return
body = response['body']['string']
for clean_me in clean_strings:
body = body.replace(clean_me, 'CLEANED')
response['body']['string'] = body
Context
Would be helpful to have a function that replaces any given string (ideally set in an environment variable, so that sensitive strings can be added) from response and body text.