View Source LeakCheck.Filter (LeakCheck v0.3.0)
Provides filtering functions for leak entries.
This module allows you to filter leak entries based on properties found in their "source"
maps.
It includes functions to:
Filter entries by the recency of their breach date (provided in
"YYYY-MM"
format). The recency is computed by subtracting a specified number of years from the current UTC date. By default, a 2-year threshold is used, but you can customize it using the:years
option.Filter entries based on whether they contain a password update. In this context, a
"passwordless"
field with a value of0
indicates that the leak includes a password update.
Summary
Functions
Filters a list of leak entries to retain only those that include a password update.
Filters a list of leak entries to include only those with a valid "source"
map
containing a "breach_date"
(formatted as "YYYY-MM"
) that is within the allowed recency.
Functions
Filters a list of leak entries to retain only those that include a password update.
Within each leak entry, a "passwordless"
value of 0
(inside the "source"
map)
signifies that the leak includes a password update. Any other value (or absence of the field)
indicates that the leak does not have this characteristic.
Examples
iex> # Given a list of entries, only those with a "passwordless" value of 0 are retained:
iex> LeakCheck.Filter.filter_passwordless(entries)
# Returns entries that have "passwordless" equal to 0 in their "source" map.
Filters a list of leak entries to include only those with a valid "source"
map
containing a "breach_date"
(formatted as "YYYY-MM"
) that is within the allowed recency.
The recency is determined by subtracting a number of years (from the current UTC date) as specified
via the :years
option. If no option is provided, a default of 2 years is used.
Options
:years
- The number of years (relative to the current UTC date) that define the allowed recency. Defaults to2
.
Examples
iex> # Using the default threshold of 2 years:
iex> LeakCheck.Filter.filter_recent(entries)
# Returns entries filtered with a 2-year threshold
iex> # Overriding the default threshold to 3 years:
iex> LeakCheck.Filter.filter_recent(entries, years: 3)
# Returns entries filtered with a 3-year threshold
For these examples, ensure that entries
is a list of leak entries where each entry's "source"
map includes a "breach_date"
in the "YYYY-MM"
format.