LlmCore.Config.Redact (llm_core v0.9.7)

Copy Markdown View Source

Redacts secret values from configuration before it is printed or echoed.

By key

A key names a secret when it is, or ends in (after _ or -), one of: api_key, api_keys, apikey, apikeys, key, keys, token, secret, secrets, password, passwd, credential, credentials, auth, authorization or bearer; tokens counts only as the whole key. So openai_api_key, access_key, aws_secret_access_key, bot_token, client_secret, x-api-key and proxy-authorization are secret, while max_tokens, tokens_per_minute, secret_name and credential_state are not.

Keys are matched wherever they appear, so a table whose own NAME ends in one of these words (a provider called my_key, a routing task called auth) is shown with its values redacted. Name such tables otherwise if their values are needed in mix llm_core.config.show output.

A secret key holding a scalar is shown as "[redacted]". One holding a map or list (an auth table, a credentials map) is walked with every scalar inside it redacted, so its shape stays visible.

Keys ending in _env hold the NAME of an environment variable and are shown, but only while the value looks like one (OPENAI_API_KEY). A value that does not (for example a secret interpolated from ${VAR}) is redacted.

By value

Every string is also scrubbed, whatever its key: a token after Bearer (16 or more token characters, so prose such as "Bearer token support" is left alone) and the password in a URL's userinfo (https://user:password@host) are replaced with [redacted].

Summary

Functions

term with every secret value redacted (see the module documentation).

The redacted form of a value set under path (a dotted path or its segments).

Whether key names a secret value (an _env key names a variable, so it does not).

Functions

config(term)

@spec config(term()) :: term()

term with every secret value redacted (see the module documentation).

path_value(path, value)

@spec path_value([String.t()] | String.t(), term()) :: term()

The redacted form of a value set under path (a dotted path or its segments).

secret_key?(key)

@spec secret_key?(term()) :: boolean()

Whether key names a secret value (an _env key names a variable, so it does not).