Don't leak user names or positions into logs

pull/28/head
geeksville 2020-04-12 10:21:31 -07:00
rodzic 1348d897c5
commit 83c491078d
1 zmienionych plików z 16 dodań i 0 usunięć

Wyświetl plik

@ -6,6 +6,14 @@ import com.geeksville.mesh.ui.bearing
import com.geeksville.mesh.ui.latLongToMeter
/**
* When printing strings to logs sometimes we want to print useful debugging information about users
* or positions. But we don't want to leak things like usernames or locations. So this function
* if given a string, will return a string which is a maximum of three characters long, taken from the tail
* of the string. Which should effectively hide real usernames and locations, but still let us see if values were zero or empty.
*/
val Any.anonymized: String get() = this.toString().takeLast(3) + "..."
// model objects that directly map to the corresponding protobufs
data class MeshUser(val id: String, val longName: String, val shortName: String) :
Parcelable {
@ -35,6 +43,10 @@ data class MeshUser(val id: String, val longName: String, val shortName: String)
return arrayOfNulls(size)
}
}
override fun toString(): String {
return "MeshUser(id=${id.anonymized}, longName=${longName.anonymized}, shortName=${shortName.anonymized})"
}
}
data class Position(
@ -78,6 +90,10 @@ data class Position(
return arrayOfNulls(size)
}
}
override fun toString(): String {
return "Position(lat=${latitude.anonymized}, lon=${longitude.anonymized}, alt=${altitude.anonymized}, time=${time})"
}
}