SecretType

org.llm4s.agent.guardrails.patterns.SecretPatterns.SecretType
See theSecretType companion object
class SecretType(val name: String, val pattern: Regex, val placeholder: String)

A single category of secret credential.

The built-in types are in the companion. The class is open: an application adds its own credential format with new SecretType("Acme token", """acme_[A-Za-z0-9]{32}""".r, "[REDACTED_ACME_TOKEN]") and passes it to SecretLeakGuardrail beside the built-in ones. A pattern runs on text a model or a user supplies, so write one that takes linear time: no nested quantifiers, and no scan to the end of a run from every position in it.

Value parameters

name

human-readable label used in error messages

pattern

the regex that recognises this credential. When it has a capturing group, group 1 is the secret and the rest of the match is context that is kept; otherwise the whole match is

placeholder

what to write in place of the secret when masking

Attributes

Companion
object
Source
SecretPatterns.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object AnthropicKey
object AwsAccessKey
object GoogleApiKey
object JwtToken
object LangfuseKey
object OpenAIKey
object PrivateKeyPem
object VoyageKey
Show all

Members list

Value members

Concrete methods

def findAll(text: String): Seq[SecretMatch]

Return all non-overlapping matches found in text. Results are ordered by start position.

Return all non-overlapping matches found in text. Results are ordered by start position.

Attributes

Source
SecretPatterns.scala
def redact(text: String): String

text with every match of this type replaced by placeholder.

text with every match of this type replaced by placeholder.

Attributes

Source
SecretPatterns.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
Source
SecretPatterns.scala

Concrete fields

val name: String

Attributes

Source
SecretPatterns.scala
val pattern: Regex

Attributes

Source
SecretPatterns.scala

Attributes

Source
SecretPatterns.scala