mirror of
https://github.com/onyx-dot-app/onyx.git
synced 2026-10-22 11:22:49 -05:00
19 lines
553 B
Python
19 lines
553 B
Python
from typing import Any
|
|
|
|
|
|
def mask_string(sensitive_str: str) -> str:
|
|
return "****...**" + sensitive_str[-4:]
|
|
|
|
|
|
def mask_credential_dict(credential_dict: dict[str, Any]) -> dict[str, str]:
|
|
masked_creds = {}
|
|
for key, val in credential_dict.items():
|
|
if not isinstance(val, str):
|
|
raise ValueError(
|
|
f"Unable to mask credentials of type other than string, cannot process request."
|
|
f"Recieved type: {type(val)}"
|
|
)
|
|
|
|
masked_creds[key] = mask_string(val)
|
|
return masked_creds
|