Repository navigation
feat(core): secret detection module for the privacy filter (#1464, part 1) - #1491
Merged
Merged
Conversation
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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
Part 1 of the privacy filter (#1464): the detection module only.
uteke_core::privacy::redact(text, allowlist)finds common secret shapes and masks the secret part, keeping the shape, and reports what it removed (a kind and a count, never the value):github-tokenghp_[REDACTED:github-token](alsogithub_pat_)aws-access-keyAKIA[REDACTED:aws-access-key]api-keysk-[REDACTED:api-key]bearer-tokenBearer [REDACTED:bearer-token]jwt[REDACTED:jwt]private-key[REDACTED:private-key]env-secretAPI_KEY=[REDACTED:env-secret], also"client_secret": "..."andauth_token: ...The generic
NAME=valuerule needs a secret-like name (key, token, secret, password, pwd), a value of at least 16 characters with Shannon entropy of at least 3.0, and a terminator that is not(or[. It ignores 40/64-digit hex hashes, UUIDs, paths, URLs,${VAR}references, placeholders (your,example,changeme, ...), identifier-like values (config.embedding.api_key,VAULT_API_KEY_NAME) and already-masked text.compile_allowlistturns the[privacy] allowlistregexes into a filter that keeps a matching value.redactis idempotent.regexbecomes a direct dependency ofuteke-core; it was already in the graph throughtokenizers(same 1.13.1).Nothing calls it yet. Part 2 wires it into
remember, room remember, import and update, behind[privacy] mode(defaultredact,strict,off), withmetadata.redacted, the audit event and theredactedresponse field. Part 2 waits for the cloud contract answer (uteke-cloud#218); part 3 is config reference and safety docs.Why
A secret pasted into one
rememberis persisted, embedded, indexed and returned by recall forever. Because the filter will run by default, this part is about precision: a pattern is only here when its shape rarely hits ordinary text.Testing
api_key: self.api_key.clone(),let key = self.make_key(...)), which is why a value must now end at a plain terminator and identifier-like values are ignored; the final version redacts nothing (the one hit was this file's own fixture, now built at run time).TOKEN=aaaaaaaaaaaaaaaaaaaaaaaa), and a GitHub pattern that never matches fails three tests.cargo clippy --workspace --all-targets -D warningsis clean; the slim build--no-default-features --features "onnx,vecq"compiles.