feat: SOFT sensitive-content / PII scanner for sessions#33
Open
jakduch wants to merge 1 commit into
Open
Conversation
a482f22 to
43f74d4
Compare
Adds a local, informational-only scanner that flags sessions whose project name or git branch contains common secret/credential markers (secret, credential, password, api_key, token, .env, .ssh/, etc). - Patterns are configurable via ~/.claude/pii-patterns.json (a JSON list of regex strings). Falls back to a sensible built-in list when the override file is missing or malformed. - get_dashboard_data attaches a 'sensitive_match' field to every session in the JSON payload — empty list = clean. - The dashboard renders a small warning chip next to flagged sessions with a tooltip listing the matched markers. - Nothing ever leaves the machine; this is a SOFT warning only and never blocks anything. 12 new unit tests cover defaults, override loading, match behaviour, malformed-file resilience, end-to-end JSON wiring, and the JS render helper being present in the bundled HTML.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this add and why do you believe it belongs in this dashboard?
Adds a SOFT, informational-only sensitive-content / PII scanner for sessions. It warns when a session's project name or git branch matches user-configurable regex patterns — out of the box it flags common credential markers like
secret,credential,password,api_key,token,.env,.aws/credentials,SSN,private_key,.ssh/. Patterns can be tuned (or replaced wholesale — credit-card numbers, email addresses, anything you want flagged) via~/.claude/pii-patterns.json.This belongs in a personal Claude Code usage dashboard precisely because the dashboard is what you tend to share. People screenshot it, paste session IDs into bug reports, screen-share it on calls. Local logs accumulate work from sketchy-named branches (
fix/leaked-token,spike/aws-creds) and a quick visual nudge — a small warning chip on the relevant row — is enough to make the user pause before exposing it.The feature is strictly opt-in in spirit and never blocks anything: the scan runs locally on already-local data, nothing leaves the machine, no session is hidden or rate-limited, and turning it off is one empty JSON file away.
Checklist
Code correctness
calcCost()calls pass 6 arguments:(model, inp, out, cache_read, cache_creation, cache_1h)`), not escaped ones (\`)Tests
python3 -m unittest discover -s tests -v— all passingpython3 -m unittest tests.test_browser -v— all passingScope
dashboard.py,scanner.py,cli.py,pricing.py,cowork.py,tests/) — or I've explained below why a new file is neededTouches
dashboard.py(scanner helpers + JS badge) and addstests/test_pii.py(12 unit tests covering built-in defaults, user-override loading, malformed-file resilience, case-insensitive matching, bad-regex skipping, end-to-endget_dashboard_dataattachment, and the JS render helper being bundled intoHTML_TEMPLATE).Test status