Skip to content

Commit

Permalink
chore(cloud): keep up the first 5 characters for cloud redact
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwentao committed Dec 16, 2024
1 parent dbbe1f8 commit 589b8c9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions midealocal/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def get_preset_account_cloud() -> dict[str, str]:
}


block = "\u2588"
block = "*"


def _redact_data(data: str) -> str:
Expand All @@ -132,8 +132,10 @@ def _redact_data(data: str) -> str:
if len(item) == 0:
break
m = len(item)
elm = r"\b" + item + r"\b"
data = re.sub(elm, block * m, data)
visible = item[:5] # Keep up to the first 5 characters
redacted = visible + block * (m - len(visible)) # Use block for masking
elm = re.escape(item) # Escape regex metacharacters
data = re.sub(elm, redacted, data)
return data


Expand Down

0 comments on commit 589b8c9

Please sign in to comment.