fix(web): исправить некорректное отображение подписи 'Н/Д' для токенов и улучшить regex санитаризации
This commit is contained in:
parent
e738dd0c5d
commit
c9c9586bff
2 changed files with 9 additions and 4 deletions
|
|
@ -78,7 +78,7 @@ def health_check():
|
|||
def sanitize_snapshot(snap_dict: Any) -> Any:
|
||||
import re
|
||||
secret_patterns = [
|
||||
re.compile(r'(access_token|refresh_token|api_key|token|password|secret|key)=([^\s&,"]+)', re.IGNORECASE),
|
||||
re.compile(r'((?:access_token|refresh_token|api_key|token|password|secret|key)=)([^\s&,"]+)', re.IGNORECASE),
|
||||
re.compile(r'(sk-[a-zA-Z0-9_\-]{8,})'),
|
||||
re.compile(r'(gho_[a-zA-Z0-9_\-]{8,})'),
|
||||
re.compile(r'(Bearer\s+)([a-zA-Z0-9_\-\.]{8,})', re.IGNORECASE),
|
||||
|
|
@ -88,7 +88,7 @@ def sanitize_snapshot(snap_dict: Any) -> Any:
|
|||
res = val
|
||||
for pat in secret_patterns:
|
||||
if pat.groups == 2:
|
||||
res = pat.sub(r'\1=***', res)
|
||||
res = pat.sub(r'\g<1>***', res)
|
||||
elif pat.groups == 1:
|
||||
res = pat.sub(r'***', res)
|
||||
return res
|
||||
|
|
|
|||
|
|
@ -777,15 +777,20 @@ function renderAnalyticsView() {
|
|||
// KPI 4: Tokens (Honesty rule: null means N/D, never 0)
|
||||
const tokensEl = document.getElementById('analytics-tokens-total');
|
||||
const tokensSubEl = document.getElementById('analytics-tokens-sub');
|
||||
const hasTokens = global.total_tokens !== null && global.total_tokens !== undefined;
|
||||
if (tokensEl) {
|
||||
if (global.total_tokens !== null && global.total_tokens !== undefined) {
|
||||
if (hasTokens) {
|
||||
tokensEl.textContent = global.total_tokens.toLocaleString('ru-RU');
|
||||
} else {
|
||||
tokensEl.textContent = 'Н/Д';
|
||||
}
|
||||
}
|
||||
if (tokensSubEl) {
|
||||
tokensSubEl.textContent = 'Н/Д: провайдеры не отдают данные о токенах';
|
||||
if (hasTokens) {
|
||||
tokensSubEl.textContent = 'Учитывается провайдером';
|
||||
} else {
|
||||
tokensSubEl.textContent = 'Н/Д: провайдеры не отдают данные о токенах';
|
||||
}
|
||||
}
|
||||
|
||||
// Providers Table
|
||||
|
|
|
|||
Loading…
Reference in a new issue