Cased.Sensitive.Handler behaviour (cased v1.0.0)

Behaviour used to identify sensitive data.

Implementing custom handlers only requires two functions:

See Cased.Sensitive.RegexHandler and tests for example implementations.

Link to this section Summary

Types

A tuple structure used to declare the options for a handler.

t()

Functions

Create a handler from a handler specification (commonly loaded from application config).

Callbacks

Create a handler with a given label and custom configuration.

Extract Cased.Sensitive.Range structs for a given value at key.

Link to this section Types

Link to this type

handler_module()

Specs

handler_module() :: module()

Specs

spec() :: {module :: handler_module(), label :: atom(), config :: any()}

A tuple structure used to declare the options for a handler.

Examples

Configuring a Cased.Sensitive.RegexHandler to detect @-prefixed usernames:

{Cased.Sensitive.RegexHandler, :username, ~r/@w+/}

For your own, custom defined handlers:

{MyApp.CustomHandler, :custom_label_for_handler, custom_configuration_for_handler}

Specs

t() :: %{
  :__struct__ => handler_module(),
  :label => atom(),
  optional(atom()) => any()
}

Link to this section Functions

Link to this function

from_spec(handler)

Specs

from_spec(raw_handler :: spec()) :: t()

Create a handler from a handler specification (commonly loaded from application config).

Examples

Creating a Cased.Sensitive.RegexHandler from the tuple specification:

iex> handler_spec = {Cased.Sensitive.RegexHandler, :username, ~r/@w+/}
iex> Cased.Sensitive.Handler.from_spec(handler)
%Cased.Sensitive.RegexHandler{label: :username, regex: ~r/@w+/}

Link to this section Callbacks

Link to this callback

new(label, config)

Specs

new(label :: atom(), config :: any()) :: t()

Create a handler with a given label and custom configuration.

Link to this callback

ranges(handler, audit_event, {})

Specs

ranges(
  handler :: t(),
  audit_event :: map(),
  {key :: Cased.Sensitive.Range.key(), value :: any()}
) :: [Cased.Sensitive.Range.t()]

Extract Cased.Sensitive.Range structs for a given value at key.

Note that value can be of any type; your implementation should return an empty list for any unsupported values.