tracecloak 0.1.0
tracecloak: ^0.1.0 copied to clipboard
Masks API keys, tokens and passwords in Dart and Flutter print() output, logs, Dio HTTP logs, crash reports and AI prompts. Zero custody, off in release builds by default.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.1.0 - 2026-11-22 #
Initial release of tracecloak. It replaces vibeshield_flutter (the same code, briefly published under the old project name): change the dependency to tracecloak, imports to package:tracecloak/tracecloak.dart, and VibeShield to TraceCloak.
Added #
- Zone interception (
TraceCloak.run): masks secrets in everyprint()executed inside the zone, including async code, timers and microtasks. Uncaught errors are passed toonError(or the parent zone) as aRedactedErrorwith redacted text and a redacted stack trace;RedactedError.originalkeeps the real exception for type checks. - Release builds: with
enableInRelease: false(default)run()callsbody()directly with no zone, and structured log output is skipped.mode,exactSecretsandonRedactionEventare applied in every build mode, so explicitredact()/aiSafe()calls keep masking registered secrets in production. - Three masking modes:
MaskMode.partial: keeps known provider prefixes (sk_live_****7890) and reveals at most a third of other secrets (****under 16 chars).MaskMode.full: shape-preserving mask with no content character kept (letters →a/b, digits →0/1, symbols and non-ASCII →*, separators kept).MaskMode.off: raw pass-through.
- Detection rules (patterns adapted from gitleaks, MIT): Stripe live/test/restricted keys, AWS access key IDs and secret access keys, Google
AIzakeys, OpenAI and Anthropic keys, GitHubghp_/gho_/ghu_/ghs_/ghr_/github_pat_, Slackxox*-tokens, JWTs, PEM private key blocks, database URLs with credentials. Log-only heuristics:user:password@in URLs, sensitive query parameters, Bearer/Basic/Digest credentials, and keyword assignments of any length (password=…,"token": "…",secret_key: …). - Shannon entropy fallback for unknown tokens, ignoring UUIDs, isolated hash digests and code identifiers.
- Exact-match secrets (
exactSecrets,addExactMatches) and custom rules (addRules,DartSecretRulewithconfidence). - Key-aware sanitisation (
sanitize,sanitizeHeaders): values under sensitive names (Authorization,Cookie,X-Api-Key,password,token,secret, …) are always masked, custom objects are redacted viatoString(), cycles and deep nesting are handled. - Structured logging:
TraceCloak.info/warn/error/debug/printandTraceCloak.log(...).tag(...).data(...).send(), formatted as[LEVEL] [tag] message | metadata: {...}. - Dio interceptor (
TraceCloakDioInterceptor,TraceCloak.dioInterceptor()): logs a sanitised copy of requests, responses and errors while the real request is untouched; supportsoverrideModeandenableInRelease. - Error helpers:
sanitizeError,sanitizeStackTrace,wrapDebugPrintfor Flutter'sdebugPrint. - AI protection:
SecureKeywrapper (toString()/toJson()masked,exposeRaw()for the real call),TraceCloak.aiSafe/String.aiSafefor LLM prompts, andprotectFromAi()/dart run tracecloak --shield-aiwhich creates or refreshes a managed block in.aiignore,.aiexclude,.cursorignore,.copilotignoreand.claudeignore. - String extensions:
.redacted,.masked,.halfMasked,.fullMasked,.maskWith(mode),.aiSafe. - Audit hook:
TraceCloak.onRedactedreceives non-custodialRedactionEvents (rule, category, masked preview); exceptions thrown by the hook are swallowed. - CLI scanner (
dart run tracecloak): reports hard-coded credentials with file, line, column, variable name and masked preview;--json,--path=,--fail-on-warning; exits with code 1 on confirmed leaks in both text and JSON mode; lines containingtracecloak-ignoreare skipped. - Testing support:
TraceCloak.reset()andTraceCloak.customPrinter. SecureLogalias forTraceCloak.- Runs on Android, iOS, Web (JS and WASM), macOS, Windows, Linux and the Dart VM;
protectFromAi()needsdart:ioand throwsUnsupportedErroron the web.