Repository navigation
feat: anonymous ai-scan usage ping (opt-out) + /api/telemetry - #369
Merged
Merged
Conversation
ai-scan runs on the user's machine and sent nothing home, so there was no way
to count how often the scanner is used. Each ai-scan / ai-scan-run now sends
one count to ${THREATCRUSH_API_URL}/api/telemetry: command, version, OS,
Node, CI flag, a random install id (~/.threatcrush/usage-ping.json), probes,
findings by severity, duration. Never the target, prompts, responses or
finding text. Off with THREATCRUSH_TELEMETRY=0 or DO_NOT_TRACK=1; the first
run prints a one-line notice. 2s timeout, never throws.
Server: POST /api/telemetry validates every field against a narrow shape
(lib/usage-ping.ts), drops the rest, stores no IP or user, rate-limited
30/min per IP. Table cli_usage_pings (RLS on, no anon/authenticated grants;
applied on dev2 by hand). Privacy policy, CLI README and SELF_HOSTING
updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| const res = await (opts.fetchImpl ?? fetch)(`${apiUrl()}/api/telemetry`, { | ||
| method: 'POST', | ||
| headers: { 'content-type': 'application/json' }, | ||
| body: JSON.stringify(pingBody(p, id, env)), |
ThreatCrush Security Scan22 finding(s) HIGH/CRITICAL: 1 | MEDIUM: 12 | LOW: 9
Snippets are redacted; ThreatCrush never prints matched credential material. |
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.
Anthony approved this on 2026-10-28 ("yes" to the ai-scan usage ping). ai-scan runs on the user's machine and sent nothing home, so the nightly report (profullstack/scripts#35) couldn't count it.
CLI (
apps/cli/src/core/usage-ping.ts): eachai-scanandai-scan-runsends one count to${THREATCRUSH_API_URL}/api/telemetry. The payload is the command, version, OS/arch, Node version, a CI flag, a random install id (~/.threatcrush/usage-ping.json), probes, findings by severity, duration and a failed flag. It never includes the target, headers, prompts, responses or finding text.THREATCRUSH_TELEMETRY=0|off|false|noorDO_NOT_TRACK=1. The first run prints a one-line notice on stderr.Web:
POST /api/telemetrychecks every field against a narrow shape (lib/usage-ping.ts) and drops everything else. No IP or user is stored, and a body over 4 KB gets a 400.cli_usage_pings: RLS on, no anon/authenticated grants. Already applied on dev2 by hand (no CI applies migrations), then the PostgREST schema was reloaded.Docs:
/privacyhas a new "CLI usage counts" entry (last updated Oct 28). The CLI README andSELF_HOSTING.mdnote that the ping goes toTHREATCRUSH_API_URL, so a self-hosted install sends it to its own server.Tests: new tests for the ping (opt-out, notice once, stable id, exact payload keys, network failure) and the route (stores only documented fields, rejects junk/oversize/unknown events, clamps, insert failure gives 500). CLI 678/678, web 890 pass, CLI tsc clean, pre-commit hook passed.
🤖 Generated with Claude Code