SecretPatterns
Library of credential-detection patterns used by org.llm4s.agent.guardrails.builtin.SecretLeakGuardrail and Redaction.
All regex matching is performed via SecretType instances. Each type knows its own pattern, human-readable name, and the placeholder text to use when redacting.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
SecretPatterns.type
Members list
Type members
Classlikes
A single regex match of a secret inside a larger string.
A single regex match of a secret inside a larger string.
Value parameters
- endIndex
-
Exclusive end position in the original string.
- secretType
-
The SecretType that produced this match.
- startIndex
-
Inclusive start position in the original string.
- value
-
The matched secret text (un-redacted).
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A single category of secret credential.
A single category of secret credential.
Each instance carries:
name– human-readable label used in error messagespattern– the scala.util.matching.Regex that recognises this credentialplaceholder– what to write in place of the secret when masking
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object AnthropicKeyobject AwsAccessKeyobject GoogleApiKeyobject JwtTokenobject LangfuseKeyobject OpenAIKeyobject PrivateKeyPemobject VoyageKeyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
SecretType.type
Value members
Concrete methods
Returns true if text contains at least one secret from types.
Returns true if text contains at least one secret from types.
Attributes
Find every secret in text using the supplied types (defaults to SecretType.default).
Replace each matched secret with its type-specific placeholder (e.g. sk-abc... → [REDACTED_OPENAI_KEY]).
Replace each matched secret with its type-specific placeholder (e.g. sk-abc... → [REDACTED_OPENAI_KEY]).
When multiple secrets of different types overlap, earlier matches in the type list take precedence (leftmost-longest wins within a type; types are applied left-to-right).
Attributes
Replace every matched secret with the supplied uniform placeholder string (e.g. "[REDACTED]").
Replace every matched secret with the supplied uniform placeholder string (e.g. "[REDACTED]").
Useful when callers want a single marker regardless of credential type.
Attributes
Count occurrences of each credential type in text.
Count occurrences of each credential type in text.
Attributes
- Returns
-
A map from SecretType.name to the number of matches found. Types with zero matches are omitted.