ExDaytona.Redact (ex_daytona v0.3.0)

Copy Markdown View Source

Credential redaction for inspection and diagnostics.

Every generated model, plus the credential-bearing facade structs (ExDaytona.Client, ExDaytona.Error, SSH/preview/storage results), renders through here for inspect/1 — fields whose names indicate credentials come out as "[REDACTED]" while nonsecret fields stay visible for debugging. deep/1 sanitizes arbitrary nested values (for error details and logging).

A field is considered sensitive when its name contains any of: api_key/apikey, authorization, token, secret, password, credential, access_key/accesskey. Matching is case-insensitive and underscore-insensitive, so camelCase model fields (sessionToken, accessKey) are covered. value fields on secret-typed models (CreateSecret, UpdateSecret, resolved secret bindings) are also redacted.

Note: this intentionally over-redacts some non-credentials (e.g. pagination nextToken cursors) — a safe default.

Summary

Functions

Deep-sanitize a value: maps and keyword/tuple lists have sensitive keys' values replaced (string keys matched case-insensitively), recursively. Structs are converted to sanitized maps tagged with their module.

Inspect implementation body for structs: renders like the default struct inspect but with sensitive fields redacted. Used by every generated model's Inspect impl and the facade's credential-bearing structs.

The stable replacement marker.

Scrub signed/credential query parameters from URLs embedded in a message string.

Whether a field name indicates a credential.

Functions

deep(struct)

@spec deep(term()) :: term()

Deep-sanitize a value: maps and keyword/tuple lists have sensitive keys' values replaced (string keys matched case-insensitively), recursively. Structs are converted to sanitized maps tagged with their module.

inspect_struct(struct, opts, extra_sensitive \\ [])

@spec inspect_struct(struct(), Inspect.Opts.t(), [atom()]) :: Inspect.Algebra.t()

Inspect implementation body for structs: renders like the default struct inspect but with sensitive fields redacted. Used by every generated model's Inspect impl and the facade's credential-bearing structs.

extra_sensitive names additional fields to redact regardless of their name (e.g. :value on secret models).

marker()

The stable replacement marker.

scrub_message(message)

@spec scrub_message(binary() | nil) :: binary() | nil

Scrub signed/credential query parameters from URLs embedded in a message string.

sensitive_key?(key)

@spec sensitive_key?(atom() | binary()) :: boolean()

Whether a field name indicates a credential.