Skip to content

Commit

Permalink
fix: updated __repr__ to hide account key for AzureLibraryAdapter
Browse files Browse the repository at this point in the history
Update __repr__ to censor sensitive information.

Signed-Off By Artem Maslov [email protected]. By including this sign-off line I agree to the terms of the Contributor License Agreement
  • Loading branch information
Artem Maslov authored and poodlewars committed Apr 18, 2024
1 parent 0859017 commit 3b52859
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python/arcticdb/adapters/azure_library_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def __init__(self, uri: str, encoding_version: EncodingVersion, *args, **kwargs)
super().__init__(uri, self._encoding_version)

def __repr__(self):
return "azure(endpoint=%s, container=%s)" % (self._endpoint, self._container)
censored_endpoint = re.sub(r"AccountKey=.+?;", "AccountKey=...;", self._endpoint)
return "azure(endpoint=%s, container=%s)" % (censored_endpoint, self._container)

@property
def config_library(self):
Expand Down
6 changes: 6 additions & 0 deletions python/tests/integration/arcticdb/test_arctic.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ def test_delete_date_range(arctic_library):
assert lib["symbol"].version == 1


def test_azure_repr_body_censored(arctic_library):
ac_library_repr = repr(arctic_library)
if "AccountKey=" in ac_library_repr:
assert "AccountKey=..." in ac_library_repr.split(";")


def _test_mongo_repr_body(mongo_storage: MongoDatabase):
# The arctic_uri has the PrefixingLibraryAdapterDecorator logic in it, so use mongo_uri
ac = Arctic(f"{mongo_storage.mongo_uri}/?maxPoolSize=10")
Expand Down

0 comments on commit 3b52859

Please sign in to comment.