# `Faulty.Scrubber`
[🔗](https://github.com/Hermanverschooten/faulty/blob/main/lib/faulty/scrubber.ex#L1)

Redacts sensitive values from an error context before it is sent.

Faulty scrubs every context by default, before your `Faulty.Filter` runs. The
value under a sensitive key is replaced by `"[FILTERED]"`, whatever its type,
and maps and lists are scrubbed recursively.

A key is sensitive when, compared case-insensitively and ignoring everything
that is not a letter or a digit, it contains one of: `password`, `passwd`,
`pwd`, `secret`, `token`, `apikey`, `authorization`, `bearer`, `cookie`,
`creditcard`, `cardnumber`, `cardnum`, `cvv`, `cvc`, `ssn`, `socialsecurity`
or `privatekey`. So `Authorization`, `x-api-key` and `apiKey` all match.

Only keys are looked at: error reasons and other strings are left as they are.
Structs are left untouched.

It can be turned off with:

    config :faulty, scrub_pii: false

Your own `Faulty.Filter` runs afterwards, whether or not this is enabled.

# `scrub`

```elixir
@spec scrub(term()) :: term()
```

Scrubs a context, or any value found inside one.

## Examples

    iex> Faulty.Scrubber.scrub(%{"password" => "hunter2", "name" => "Herman"})
    %{"password" => "[FILTERED]", "name" => "Herman"}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
