diff --git a/kotlix/src/commonMain/kotlin/app/octocon/kotlix/Socket.kt b/kotlix/src/commonMain/kotlin/app/octocon/kotlix/Socket.kt index bf36fee..0781dfe 100644 --- a/kotlix/src/commonMain/kotlin/app/octocon/kotlix/Socket.kt +++ b/kotlix/src/commonMain/kotlin/app/octocon/kotlix/Socket.kt @@ -283,9 +283,14 @@ abstract class SocketCommon( return ref.toString() } - /** A nullable-aware wrapper around the [logger] lambda */ + /** A nullable-aware wrapper around the [logger] lambda that sanitizes sensitive data */ internal fun logItems(body: String) { - logger?.invoke(body) + var sanitized = body + // Redact system IDs: "system:123" -> "system:" + sanitized = sanitized.replace(Regex("""system:[^"]+"""), "system:") + // Redact token values in JSON: "token":"..." -> "token":"" + sanitized = sanitized.replace(Regex(""""token":"[^"]*"""), """"token":"""") + logger?.invoke(sanitized) } /** @@ -583,4 +588,4 @@ fun buildEndpointUrl( } return urlBuilder.build() -} \ No newline at end of file +}