Monitorex.URLRedactor (monitorex v0.3.0)

Copy Markdown

Redacts sensitive query parameters from URLs to prevent accidental leakage of tokens, keys, and credentials in stored/displayed outbound URLs.

Sensitive param values are replaced with [REDACTED] before the URL is written to storage.

Summary

Functions

Redacts sensitive query parameters from the given URL.

Functions

redact(url)

@spec redact(url :: String.t() | nil) :: String.t() | nil

Redacts sensitive query parameters from the given URL.

Uses the application config key :sensitive_query_params to determine which parameters to redact (defaults to a built-in denylist).

Examples

iex> Monitorex.URLRedactor.redact("https://api.stripe.com/v1/charges?key=sk_live_xxx")
"https://api.stripe.com/v1/charges?key=%5BREDACTED%5D"

iex> Monitorex.URLRedactor.redact("https://api.example.com/users/123?page=1&per_page=20")
"https://api.example.com/users/123?page=1&per_page=20"

iex> Monitorex.URLRedactor.redact("https://api.example.com/health")
"https://api.example.com/health"

iex> Monitorex.URLRedactor.redact(nil)
nil

iex> Monitorex.URLRedactor.redact("")
""