From 18ab8656583f0fe3b62218947b0aad14d5762fed Mon Sep 17 00:00:00 2001 From: shellster <> Date: Tue, 10 Mar 2026 18:34:42 -0600 Subject: [PATCH 1/2] strip sensitive values from logging --- .../commonMain/kotlin/app/octocon/kotlix/Socket.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kotlix/src/commonMain/kotlin/app/octocon/kotlix/Socket.kt b/kotlix/src/commonMain/kotlin/app/octocon/kotlix/Socket.kt index bf36fee..93cbb84 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 +} From 39ef8545b9432b2829f0e96004b4de3aea4a220e Mon Sep 17 00:00:00 2001 From: shellster <> Date: Tue, 10 Mar 2026 18:52:42 -0600 Subject: [PATCH 2/2] clean-up comment --- kotlix/src/commonMain/kotlin/app/octocon/kotlix/Socket.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlix/src/commonMain/kotlin/app/octocon/kotlix/Socket.kt b/kotlix/src/commonMain/kotlin/app/octocon/kotlix/Socket.kt index 93cbb84..0781dfe 100644 --- a/kotlix/src/commonMain/kotlin/app/octocon/kotlix/Socket.kt +++ b/kotlix/src/commonMain/kotlin/app/octocon/kotlix/Socket.kt @@ -288,7 +288,7 @@ abstract class SocketCommon( var sanitized = body // Redact system IDs: "system:123" -> "system:" sanitized = sanitized.replace(Regex("""system:[^"]+"""), "system:") - // Redact token values in JSON: "token":"..." -> "token":"" + // Redact token values in JSON: "token":"..." -> "token":"" sanitized = sanitized.replace(Regex(""""token":"[^"]*"""), """"token":"""") logger?.invoke(sanitized) }