diff --git a/src/settings/_config_as_yaml.py b/src/settings/_config_as_yaml.py index b6570e6..95e55cf 100644 --- a/src/settings/_config_as_yaml.py +++ b/src/settings/_config_as_yaml.py @@ -17,10 +17,10 @@ def filter_internal_attributes(data, internal_attributes, hide_internal_attr): def clean_dict(data, sensitive_attributes, internal_attributes, hide_internal_attr): """Clean a dictionary by masking sensitive attributes and filtering internal ones.""" - cleaned = { + masked = { k: mask_sensitive_value(v, k, sensitive_attributes) for k, v in data.items() } - return filter_internal_attributes(cleaned, internal_attributes, hide_internal_attr) + return filter_internal_attributes(masked, internal_attributes, hide_internal_attr) def clean_list(obj, sensitive_attributes, internal_attributes, hide_internal_attr): @@ -57,7 +57,8 @@ def clean_object(obj, sensitive_attributes, internal_attributes, hide_internal_a return clean_dict( vars(obj), sensitive_attributes, internal_attributes, hide_internal_attr ) - return mask_sensitive_value(obj, "", sensitive_attributes) + + return obj def get_config_as_yaml( @@ -92,13 +93,13 @@ def get_config_as_yaml( # Process dict or class-like object config else: - cleaned_obj = clean_object( - obj, - sensitive_attributes, - internal_attributes, - hide_internal_attr, - ) - if cleaned_obj: + if not key in internal_attributes and hide_internal_attr: + cleaned_obj = clean_object( + obj, + sensitive_attributes, + internal_attributes, + hide_internal_attr, + ) config_output[key] = cleaned_obj return yaml.dump( diff --git a/src/settings/_constants.py b/src/settings/_constants.py index d9c59f0..904560e 100644 --- a/src/settings/_constants.py +++ b/src/settings/_constants.py @@ -11,7 +11,7 @@ class Envs: self.use_config_yaml = False # Overwritten later if config file exists def config_as_yaml(self): - return get_config_as_yaml(self.__dict__) + return get_config_as_yaml(vars(self), internal_attributes={"in_docker"}) class Paths: