import copy
import six


def obscure(src, sensitive_keys=['password']):
    """
    Return a deep copy of src (MutableMapping) with sensitive keys obscured.

    >>> nested = dict(password='top secret')
    >>> d = dict(a=1, b=2, password='very secret', nested=nested)
    >>> obscure(d)['a']
    1
    >>> obscure(d)['password']
    '********'
    >>> obscure(d)['nested']['password']
    '********'

    >>> type(obscure(ConfigDict(d)))
    <class 'vr.launch.config.ConfigDict'>
    """
    result = copy.copy(src)

    for key, value in six.iteritems(result):
        if isinstance(value, dict):
            result[key] = obscure(value, sensitive_keys)
        elif key in sensitive_keys:
            result[key] = '********'
    return result