techservicesillinois / vcrpy-cleaner

Sensitive data cleaners for network cassettes captured by the VCR.py testing library.
0 stars 0 forks source link

Add empty string protection to env_cleaners #31

Closed edthedev closed 3 months ago

edthedev commented 4 months ago

Context

https://github.com/techservicesillinois/secops-splunk-illinois-midpoint/pull/52#discussion_r1669032304

When CLEAN_STRINGS is unset in the command line environment (i.e. forgetting to source the .env file) cleaner output can inject a set of 'CLEANEDCLEANEDCLEANEDCLEAND' in random strings in the cassette.

This can be prevented by an extra check for empty strings (if clean_me.strip() != '':):

    for clean_me in clean_strings:
        if clean_me.strip() != '':
            dirty = dirty.replace(clean_me, 'CLEANED')

Tasks

Reference

https://github.com/techservicesillinois/vcrpy-cleaner/blob/9b4c3b816d735a31ccefbe2fa17bc57ea7ef5026/src/vcr_cleaner/cleaners/env_strings.py#L59-L60