Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDK: implement custom logging formatter to obfuscate secrets #3764

Closed
keu opened this issue May 31, 2021 · 1 comment · Fixed by #8211
Closed

CDK: implement custom logging formatter to obfuscate secrets #3764

keu opened this issue May 31, 2021 · 1 comment · Fixed by #8211
Assignees
Labels
CDK Connector Development Kit type/enhancement New feature or request

Comments

@keu
Copy link
Contributor

keu commented May 31, 2021

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

@keu keu added type/enhancement New feature or request zazmic CDK Connector Development Kit priority/high High priority labels May 31, 2021
@sherifnada sherifnada removed the zazmic label Aug 6, 2021
@sherifnada sherifnada removed the priority/high High priority label Sep 3, 2021
@avida avida assigned avida and eliziario and unassigned avida Sep 12, 2021
@eliziario
Copy link
Contributor

eliziario commented Sep 20, 2021

Scoping Report

  • Implement the suggested implementation

  • Figure out how to initialize the list of secrets for a given exec context

  • Create tests for scenarios: normal log statements, exceptions

#1279

@VasylLazebnyk VasylLazebnyk linked a pull request Nov 24, 2021 that will close this issue
40 tasks
eliziario added a commit that referenced this issue Dec 7, 2021
* Secure logger implementation minus still broken new tests

* Secure logger implementation and unit tests

* code review changes

* filter text on uncaught exceptions

* auto-formatting

* Mistaken change left in code

* filter text on uncaught exceptions

* Simplify code, remove LoggingFilter and move obfuscation functionality to Formatter

* Update airbyte-cdk/python/airbyte_cdk/entrypoint.py

Co-authored-by: Eugene Kulak <widowmakerreborn@gmail.com>

* Obfuscate Secrets in Logging, code review changes

* Obfuscate Secrets in Logging, code review changes, unit test fixes

* CHANGELOG.md

Co-authored-by: Eugene Kulak <widowmakerreborn@gmail.com>
schlattk pushed a commit to schlattk/airbyte that referenced this issue Jan 4, 2022
* Secure logger implementation minus still broken new tests

* Secure logger implementation and unit tests

* code review changes

* filter text on uncaught exceptions

* auto-formatting

* Mistaken change left in code

* filter text on uncaught exceptions

* Simplify code, remove LoggingFilter and move obfuscation functionality to Formatter

* Update airbyte-cdk/python/airbyte_cdk/entrypoint.py

Co-authored-by: Eugene Kulak <widowmakerreborn@gmail.com>

* Obfuscate Secrets in Logging, code review changes

* Obfuscate Secrets in Logging, code review changes, unit test fixes

* CHANGELOG.md

Co-authored-by: Eugene Kulak <widowmakerreborn@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CDK Connector Development Kit type/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants