Repository navigation
CM-78366: Scan images attached to Claude Code, Codex and Cursor prompts for secrets #592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Altruistus
merged 6 commits into
main
from
CM-78366-block-secrets-in-images-claude-code
Nov 18, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4e16b96
CM-78366: Scan images attached to Claude Code prompts for secrets
Altruistus 022db17
CM-78366: Treat Windows as having no uid
Altruistus 74887d8
CM-78367: Scan images attached to Codex prompts for secrets (#593)
Altruistus b206337
CM-78367: Take only Codex pastes made since the last prompt that went…
Altruistus 8b1bfc4
CM-78367: Read the Codex transcript from the end
Altruistus 795c989
CM-78366: Share the agents' prompt-image helpers and split the Codex …
Altruistus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| """Shared transcript helpers for IDE integrations. | ||
|
|
||
| Agents keep a session's transcript as JSONL that grows with every turn, images included, so it is read from | ||
| the end. | ||
| """ | ||
|
|
||
| from collections.abc import Iterator | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| def reverse_readline(path: Path, buf_size: int = 8192) -> Iterator[str]: | ||
| """Yield lines of `path` from end to start without loading the file. | ||
|
|
||
| A transcript can be very large; reading from the tail keeps memory bounded | ||
| since only the most recent entries are wanted. | ||
| """ | ||
| with path.open('rb') as f: | ||
| f.seek(0, 2) | ||
| file_size = f.tell() | ||
| if file_size == 0: | ||
| return | ||
|
|
||
| remaining = file_size | ||
| buffer = b'' | ||
|
|
||
| while remaining > 0: | ||
| read_size = min(buf_size, remaining) | ||
| remaining -= read_size | ||
| f.seek(remaining) | ||
| chunk = f.read(read_size) | ||
| buffer = chunk + buffer | ||
|
|
||
| while b'\n' in buffer: | ||
| newline_pos = buffer.rfind(b'\n') | ||
| if newline_pos == len(buffer) - 1: | ||
| newline_pos = buffer.rfind(b'\n', 0, newline_pos) | ||
| if newline_pos == -1: | ||
| break | ||
| line = buffer[newline_pos + 1 :] | ||
| buffer = buffer[: newline_pos + 1] | ||
| if line.strip(): | ||
| yield line.decode('utf-8', errors='replace') | ||
|
|
||
| if buffer.strip(): | ||
| yield buffer.decode('utf-8', errors='replace') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| """Shared helpers for VS Code and its forks, such as Cursor: where they keep their data, and reading their databases.""" | ||
|
|
||
| import platform | ||
| import sqlite3 | ||
| from contextlib import closing | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| def vscode_user_data_dir(product_name: str = 'Code') -> Path: | ||
| """Per-platform user data directory of VS Code or a fork: 'Code', 'Code - Insiders' or 'Cursor'.""" | ||
| if platform.system() == 'Darwin': | ||
| return Path.home() / 'Library' / 'Application Support' / product_name | ||
| if platform.system() == 'Windows': | ||
| return Path.home() / 'AppData' / 'Roaming' / product_name | ||
| return Path.home() / '.config' / product_name | ||
|
|
||
|
|
||
| def read_only_query(db_path: Path, sql: str, params: tuple = ()) -> list[tuple]: | ||
| """The rows of a query on an app's SQLite database, opened read-only: the app keeps writing to the file.""" | ||
| with closing(sqlite3.connect(f'{db_path.resolve().as_uri()}?mode=ro', uri=True, timeout=1)) as connection: | ||
| return connection.execute(sql, params).fetchall() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.