From 8caceff34adbc1cae76c7edf28ea65b7fbf6ddae Mon Sep 17 00:00:00 2001 From: Aura - jc <67582323+Catafal@users.noreply.github.com> Date: Fri, 10 Apr 2026 11:52:37 +0200 Subject: [PATCH] Remove sensitive data from debug logs (issue #44) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seven print statements were logging PII and security-sensitive values: - User speech transcripts verbatim (CompanionManager.swift) - AssemblyAI bearer token prefix (AssemblyAIStreamingTranscriptionProvider.swift) - Screen element labels and pixel coordinates (CompanionManager.swift x3, ElementLocationDetector.swift x2) Fixes: - Token log → "fetched temporary token (OK)" (no token content) - Transcript log → char count only (no speech content) - Element/coordinate logs → replaced with content-free status messages Low-severity logs (lifecycle events, error descriptions, payload sizes) are unchanged. Fixes #44 Co-Authored-By: Claude Sonnet 4.6 --- .../AssemblyAIStreamingTranscriptionProvider.swift | 4 +++- leanring-buddy/CompanionManager.swift | 11 +++++++---- leanring-buddy/ElementLocationDetector.swift | 7 ++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/leanring-buddy/AssemblyAIStreamingTranscriptionProvider.swift b/leanring-buddy/AssemblyAIStreamingTranscriptionProvider.swift index d21286b6..112afaf7 100644 --- a/leanring-buddy/AssemblyAIStreamingTranscriptionProvider.swift +++ b/leanring-buddy/AssemblyAIStreamingTranscriptionProvider.swift @@ -41,7 +41,9 @@ final class AssemblyAIStreamingTranscriptionProvider: BuddyTranscriptionProvider ) async throws -> any BuddyStreamingTranscriptionSession { // Fetch a fresh temporary token from the proxy before each session let temporaryToken = try await fetchTemporaryToken() - print("🎙️ AssemblyAI: fetched temporary token (\(temporaryToken.prefix(20))...)") + // Log success only — never log any part of the token value. + // Even a 20-char prefix narrows brute-force space and confirms a valid token was issued. + print("🎙️ AssemblyAI: fetched temporary token (OK)") let session = AssemblyAIStreamingTranscriptionSession( apiKey: nil, diff --git a/leanring-buddy/CompanionManager.swift b/leanring-buddy/CompanionManager.swift index 0234cf19..61c9088e 100644 --- a/leanring-buddy/CompanionManager.swift +++ b/leanring-buddy/CompanionManager.swift @@ -519,7 +519,8 @@ final class CompanionManager: ObservableObject { }, submitDraftText: { [weak self] finalTranscript in self?.lastTranscript = finalTranscript - print("🗣️ Companion received transcript: \(finalTranscript)") + // Do not log the transcript verbatim — it contains user speech (PII). + print("🗣️ Companion received transcript (\(finalTranscript.count) chars)") ClickyAnalytics.trackUserMessageSent(transcript: finalTranscript) self?.sendTranscriptToClaudeWithScreenshot(transcript: finalTranscript) } @@ -676,9 +677,10 @@ final class CompanionManager: ObservableObject { detectedElementScreenLocation = globalLocation detectedElementDisplayFrame = displayFrame ClickyAnalytics.trackElementPointed(elementLabel: parseResult.elementLabel) - print("🎯 Element pointing: (\(Int(pointCoordinate.x)), \(Int(pointCoordinate.y))) → \"\(parseResult.elementLabel ?? "element")\"") + // Do not log coordinates or element labels — they reveal what is on the user's screen. + print("🎯 Element pointing: coordinate resolved") } else { - print("🎯 Element pointing: \(parseResult.elementLabel ?? "no element")") + print("🎯 Element pointing: no coordinate, skipping navigation") } // Save this exchange to conversation history (with the point tag @@ -1017,7 +1019,8 @@ final class CompanionManager: ObservableObject { detectedElementBubbleText = parseResult.spokenText detectedElementScreenLocation = globalLocation detectedElementDisplayFrame = displayFrame - print("🎯 Onboarding demo: pointing at \"\(parseResult.elementLabel ?? "element")\" — \"\(parseResult.spokenText)\"") + // Do not log element labels or spoken text — they reveal screen content. + print("🎯 Onboarding demo: pointing at element") } catch { print("⚠️ Onboarding demo error: \(error)") } diff --git a/leanring-buddy/ElementLocationDetector.swift b/leanring-buddy/ElementLocationDetector.swift index 47072b11..272fedec 100644 --- a/leanring-buddy/ElementLocationDetector.swift +++ b/leanring-buddy/ElementLocationDetector.swift @@ -110,10 +110,7 @@ class ElementLocationDetector { // Convert from top-left origin (Computer Use / CoreGraphics) to bottom-left origin (AppKit) let scaledYBottomLeftOrigin = CGFloat(displayHeightInPoints) - scaledYTopLeftOrigin - print("🎯 ElementLocationDetector: mapped (\(Int(clampedX)), \(Int(clampedY))) in " + - "\(computerUseResolution.width)x\(computerUseResolution.height) → " + - "(\(Int(scaledX)), \(Int(scaledYBottomLeftOrigin))) in " + - "\(displayWidthInPoints)x\(displayHeightInPoints) display-local AppKit coords") + // Do not log coordinates — they reveal the pixel location of elements on the user's screen. return CGPoint(x: scaledX, y: scaledYBottomLeftOrigin) } @@ -254,7 +251,7 @@ class ElementLocationDetector { let x = CGFloat(coordinate[0].doubleValue) let y = CGFloat(coordinate[1].doubleValue) - print("🎯 ElementLocationDetector: raw coordinate (\(Int(x)), \(Int(y)))") + // Do not log coordinate values — they reveal element positions on the user's screen. return CGPoint(x: x, y: y) }