better masking
This commit is contained in:
@@ -16,7 +16,8 @@ class PrintableConfig:
|
|||||||
for key, val in vars(self).items():
|
for key, val in vars(self).items():
|
||||||
|
|
||||||
if key.endswith("_secret") or ("key" in key):
|
if key.endswith("_secret") or ("key" in key):
|
||||||
val = "****"
|
val = str(val)
|
||||||
|
val = val[:3] + "*"*(len(val) - 3)
|
||||||
|
|
||||||
if isinstance(val, Tuple):
|
if isinstance(val, Tuple):
|
||||||
flattened_val = "["
|
flattened_val = "["
|
||||||
@@ -27,6 +28,14 @@ class PrintableConfig:
|
|||||||
lines += f"{key}: {str(val)}".split("\n")
|
lines += f"{key}: {str(val)}".split("\n")
|
||||||
return "\n" + "\n ".join(lines)
|
return "\n" + "\n ".join(lines)
|
||||||
|
|
||||||
|
def is_secrete(self, inp:str):
|
||||||
|
sec_list = ["secret", "api_key"]
|
||||||
|
for sec in sec_list:
|
||||||
|
if sec in inp:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
# Base instantiate configs
|
# Base instantiate configs
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
Reference in New Issue
Block a user