Skip to content

Commit

Permalink
CDK: Improve filter_secrets skip empty string (#15684)
Browse files Browse the repository at this point in the history
* Improve `filter_secrets` skip empty string

Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
  • Loading branch information
grubberr authored Aug 16, 2022
1 parent 5a7b213 commit 4e6cb05
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions airbyte-cdk/python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.1.75
- Improve `filter_secrets` skip empty secret

## 0.1.74
- Replace JelloRecordExtractor with DpathRecordExtractor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ def filter_secrets(string: str) -> str:
# TODO this should perform a maximal match for each secret. if "x" and "xk" are both secret values, and this method is called twice on
# the input "xk", then depending on call order it might only obfuscate "*k". This is a bug.
for secret in __SECRETS_FROM_CONFIG:
string = string.replace(str(secret), "****")
if secret:
string = string.replace(str(secret), "****")
return string
2 changes: 1 addition & 1 deletion airbyte-cdk/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name="airbyte-cdk",
version="0.1.74",
version="0.1.75",
description="A framework for writing Airbyte Connectors.",
long_description=README,
long_description_content_type="text/markdown",
Expand Down
5 changes: 5 additions & 0 deletions airbyte-cdk/python/unit_tests/utils/test_secret_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ def test_secret_filtering():
filtered = filter_secrets(sensitive_str)
assert filtered == sensitive_str

# the empty secret should not affect the result
update_secrets([""])
filtered = filter_secrets(sensitive_str)
assert filtered == sensitive_str

update_secrets([SECRET_STRING_VALUE, SECRET_STRING_2_VALUE])
filtered = filter_secrets(sensitive_str)
assert filtered == f"**** {NOT_SECRET_VALUE} **** ****"

0 comments on commit 4e6cb05

Please sign in to comment.