add learned confidence classifier to cut generic-detector false positives#4
Merged
Merged
Conversation
…ives generic matchers like high_entropy also fire on benign high-entropy strings such as uuids, git shas, digests, object ids, and slugs. this adds an opt-in confidence refiner: when refineConfidence is set, a small logistic regression scores each match from a detector marked refine as a real secret versus a look-alike and nudges its confidence. pair it with minConfidence to drop the noise. checksum-validated detectors are never touched. the model is character-level logistic regression trained offline by scripts/train-confidence-model.mjs and shipped as fixed weights in src/confidence-model.ts, so the runtime stays zero-dependency, synchronous, and deterministic. secretProbability and the model are exported from the package root and the new flare-redact/ml subpath, and the cli gains --refine-confidence.
GravityHaxx
approved these changes
Jul 23, 2026
umudhasanli
pushed a commit
that referenced
this pull request
Jul 24, 2026
… transform tests (#5) * Release 1.2.0: learned confidence classifier, graph/vault benchmarks, transform tests - Ship the secret-confidence classifier (PR #4) as 1.2.0's headline: opt-in refineConfidence scoring for generic detectors, exported via the new flare-redact/ml subpath and --refine-confidence in the CLI. - Add bench/graph-vault.mjs (npm run benchmark:graph): redact() on flat strings and deep object graphs, and vault mint+restore round trips. - Add direct unit tests for pseudonymize/surrogate (Luhn-valid card surrogates, keyed determinism) and mapGraph traversal (URL, URLSearchParams, Error prototypes, shared refs, sparse arrays, symbol keys, Map/Set). 162 -> 170 tests. * Add national phone formats, GCP detectors, and official Bun/Deno smoke coverage - phone (opt-in) now matches formatted national numbers ((555) 123-4567, +90 532 123 45 67, trunk-0 forms) with digit-count validation and a date guard; bare digit runs still never match. - New default-on detectors: gcp_service_account (private_key_id in service-account JSON) and gcp_refresh_token (1// OAuth tokens). - CI now smoke-tests the dependency-free core on Bun and Deno via scripts/runtime-smoke.mjs; publish depends on both passing. - README: React/browser usage section. 170 -> 174 tests.
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
Adds an opt-in learned confidence refiner that cuts false positives from generic, format-agnostic detectors.
high_entropycatches unknown-format keys, but it also fires on benign high-entropy strings: UUIDs, git SHAs, digests, object ids, and slugs. This adds a small classifier that tells real secrets from look-alikes and nudges the confidence score. Paired withminConfidence, the noise drops out.how
src/ml.ts+src/confidence-model.ts— logistic regression over cheap character features (Shannon entropy, character-class mix, structure, and nearby labels likeapi_key=orcommit). Trained offline, shipped as fixed weights.scripts/train-confidence-model.mjs— the reproducible trainer (seeded PRNG). Re-running with--writereproducessrc/confidence-model.tsbyte for byte. Holdout: precision 99.05%, recall 98.55%, accuracy 98.80% (n=4000).refineare affected (currently justhigh_entropy); checksum-validated detectors (cards, IBANs, national ids) are never touched.refineConfidenceis off by default, so existing behavior is unchanged.secretProbability/extractFeaturesfrom the package root and the newflare-redact/mlsubpath, plus a--refine-confidenceCLI flag.scope / honesty
This is a linear model trained on synthetic data, not a silver bullet. It targets one concrete pain point (high-entropy noise) without pulling in an ML runtime, which keeps the zero-dependency guarantee intact.
tests
test/ml.test.mjs(9 cases) covers the model, the engine integration, the untouched checksum path, and the default-off behavior. Full suite: 162/162 passing. README and CHANGELOG updated.