mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
chore: anonymize ConfigProtos.Config logs
This commit is contained in:
parent
8c07532995
commit
2f7502d5ad
1 changed files with 8 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ package com.geeksville.mesh.util
|
|||
|
||||
import android.widget.EditText
|
||||
import com.geeksville.mesh.BuildConfig
|
||||
import com.geeksville.mesh.ConfigProtos
|
||||
|
||||
/**
|
||||
* When printing strings to logs sometimes we want to print useful debugging information about users
|
||||
|
|
@ -22,6 +23,13 @@ fun Any?.anonymize(maxLen: Int = 3) =
|
|||
/// A toString that makes sure all newlines are removed (for nice logging).
|
||||
fun Any.toOneLineString() = this.toString().replace('\n', ' ')
|
||||
|
||||
fun ConfigProtos.Config.toOneLineString(): String {
|
||||
val redactedFields = """(wifi_psk:|public_key:|private_key:|admin_key:)\s*".*"""
|
||||
return this.toString()
|
||||
.replace(redactedFields.toRegex()) { "${it.groupValues[1]} \"[REDACTED]\"" }
|
||||
.replace('\n', ' ')
|
||||
}
|
||||
|
||||
/// Return a one line string version of an object (but if a release build, just say 'might be PII)
|
||||
fun Any.toPIIString() =
|
||||
if (!BuildConfig.DEBUG)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue