Skip to content

CDK: implement custom logging formatter to obfuscate secrets #3764

Closed
@keu

Description

Tell us about the problem you're trying to solve

Currently, we have multiple ways to expose credentials in logs (info, exceptions, tests)

Describe the solution you’d like

The only real way to secure credentials is to control logging output with a logging Formatter attached to the root logger.
This handler will get the connector's config and will replace all occurrence of values from fields marked as secret.

class SecureFormatter(logging.Formatter):
    """ Custom formatter to prevent secrets leaking
    """
    def format(self, record: 'logging.LogRecord') -> str:
        msg = super().format(record)
        for secret in secrets:
            msg = msg.replace(secret, '***')
        return msg

Describe the alternative you’ve considered or used

do manually

┆Issue is synchronized with this Asana task by Unito

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

CDKConnector Development Kittype/enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions