Files
Qlyra/lib/core/utils/log_redact.dart
T
klockky 4e500ef087 fix(security): close critical findings #1-3 from issue #17
- TLS: validate cert chain by default; debug-menu toggle to disable
  - Logs: redact secrets in sender/dispatcher payloads
  - Identity: per-install mt_instanceid/deviceId, per-launch clientSessionId
2026-05-16 23:36:28 +03:00

40 lines
771 B
Dart

const _redacted = '***';
const _sensitiveSubstrings = ['password', 'token', 'phone', 'secret'];
const _sensitiveExact = {
'code',
'verifycode',
'smscode',
'otp',
'hint',
'pin',
'qrlink',
'text',
'msisdn',
};
bool _isSensitiveKey(Object? key) {
if (key is! String) return false;
final k = key.toLowerCase();
if (_sensitiveExact.contains(k)) return true;
for (final s in _sensitiveSubstrings) {
if (k.contains(s)) return true;
}
return false;
}
dynamic redactForLog(dynamic value) {
if (value is Map) {
final out = {};
value.forEach((k, v) {
out[k] = _isSensitiveKey(k) ? _redacted : redactForLog(v);
});
return out;
}
if (value is List) {
return value.map(redactForLog).toList();
}
return value;
}