Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Keep debug artifacts in a private log folder and clear them with typing history - #913

Draft
FuJacob wants to merge 1 commit into
mainfrom
security/debug-artifacts
Draft

FuJacob wants to merge 1 commit into
mainfrom
security/debug-artifacts

Conversation

@FuJacob

@FuJacob FuJacob commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

-cotabby-debug stays available in release builds, since it is how users collect diagnostics for bug reports. But what it wrote was too exposed. The AX dump and the screenshot/OCR captures went to the Desktop, which iCloud often syncs. Every file got the default 0644/0755 modes. The AX dump copied secure-field values before any secure check ran. A defaults key, with no indicator and no cap, could make the shipped app save caret-line captures. And Delete All in typing history left all of these copies of the user's typing on disk. This PR keeps the feature and narrows what it exposes.

  • New CotabbyDebugArtifacts (Support/Logging) owns the whole layout: one directory, ~/Library/Logs/<CFBundleName>/ (Cotabby or Cotabby Dev), created 0700, with every file 0600. Directories and logs that earlier builds left behind are tightened when they are next opened.
  • The merged JSONLFileWriter (both .events and .llmIO), the AX dump (ax-dump.txt), the visual-context captures (screenshots/<app>/) and the calibration strips (strips/, now written only by HostPixelCapture.dump) take their paths from that type. Nothing is written to the Desktop any more.
  • AXTreeDumpWriter checks each node with SecureFieldDetector. For a secure node, and every node inside one, it never reads the value, and it leaves out the selection and caret, because those reveal the length. The formatting is in a pure AXDumpValuePreview helper with its own tests.
  • Only DEBUG and COTABBY_DEV builds honor cotabbyDumpCalibrationStrips; HostPixelCapture.dumpsCaptures now forwards to that gate. The folder keeps the newest 200 captures, evicting by name stem so each PNG/JSON pair is kept or removed together. The screenshot folder's existing 20-per-app cap uses the same helper.
  • A release build launched with -cotabby-debug shows a "Debug logging is on" line under the menu bar panel's header, with a tooltip that explains how to turn it off.
  • Typing history's Delete All now also removes cotabby.jsonl, llm-io.jsonl, their .1 rotations, the AX dump, the screenshots and the strips, then reopens the live JSONLFileWriters. cotabby.jsonl is included because the suggestion debug logger writes full prompt blocks into it, and its typed-mismatch lines record the typed characters. The confirmation text mentions this.
  • Docs (AGENTS.md, which .claude/CLAUDE.md imports, plus ARCHITECTURE.md, CONTRIBUTING.md and SOURCE_LAYOUT.md) describe the new layout.

Validation

  • Not built or run locally (no disk space on the authoring machine); CI build and tests are the compile check.
  • swiftlint lint --quiet on every touched file: no new warnings. The only warnings are four existing line-length warnings in TypingHistoryStoreTests.swift, which are on main too.
  • Rebased onto main at c14b1700 (after Remove dead and test-only production code and fix the comments that described it #928–Revise maintainer details in README.md #955). xcodegen generate run after adding the four new files. The committed project.pbxproj diff is only those additions. On clean main, the same command produced no drift.
  • New or updated tests, still to be run by CI:
    • CotabbyDebugArtifactsTests: layout, 0700/0600 modes including tightening an existing 0755 root or 0644 file, capture eviction, and a Delete All sweep that leaves unrelated files alone.
    • AXDumpValuePreviewTests.
    • Owner-only and reopen() cases for JSONLFileWriter in FileLogHandlerTests. Both sinks share this writer since Merge duplicated log writers and tap plumbing, and drop dead members in services #931.
    • showsDebugModeNotice in CotabbyDebugOptionsTests.
    • Delete All calling the artifact cleaner, also when the Keychain deletion fails, in TypingHistoryStoreTests.

Linked issues

None filed. Addresses M3 and the Delete All part of L10 from a static security review of 8cdbea2.

Risk / rollout notes

  • Paths moved. ~/Desktop/cotabby-ax-dump.txt is now ~/Library/Logs/<app>/ax-dump.txt, and ~/Desktop/cotabby-debug-screenshots/ is now ~/Library/Logs/<app>/screenshots/. Anyone with scripts or wiki pages that point at the Desktop paths needs to update them.
  • Old Desktop files are not cleaned up. Checking ~/Desktop would trigger a macOS privacy prompt for every user who presses Delete All, including users who never turned on debug mode. Users who ran an earlier build with -cotabby-debug should delete the old Desktop files by hand. This could go in the release notes.
  • The strips switch also works in COTABBY_DEV, not only DEBUG. The dev identity's Release configuration is the documented way to check placement against real pixels, and that build never ships. If you want DEBUG only, it is a one-line change in CotabbyDebugArtifacts.dumpsCalibrationStrips.
  • The debug notice does not appear in DEBUG builds, because the Xcode scheme always passes the flag.
  • Same-user processes are not stopped. The 0700/0600 modes keep other accounts out, but a process running as the same user can still relaunch the app with the flag and read the logs. The menu notice makes that visible; it does not prevent it.
  • Delete All is still disabled when no history is stored, so a user with debug files but no history cannot use it to clear them.
  • The unified log (Console) still receives the .debug prompt lines while the flag is on, and Delete All cannot remove those.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

…ng history

-cotabby-debug keeps working in release builds, but everything it writes now
lands owner-only under ~/Library/Logs/<app>/ instead of partly on the Desktop.
The AX dump no longer prints secure-field values, the calibration-strip switch
only works in developer builds and is capped, a release build says when debug
logging is on, and typing history's Delete All removes the debug copies too.
@FuJacob
FuJacob force-pushed the security/debug-artifacts branch from e313c47 to 415eee1 Compare November 23, 2026 04:11

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant