Skip to contents

Looks at each field three ways: what it is called (its name, label or question text, matched on whole words), what it contains (email addresses, phone-like numbers, IP addresses, dates of birth, coordinates, person names) and how it behaves (free text, or text that is distinct on nearly every row). Each finding says which kind of evidence it rests on.

Usage

pii_scan(x, show_values = FALSE, sample = NULL, config = pii_config())

Arguments

x

Files or directories, a data frame, or fields from pii_read() or as_pii_fields().

show_values

If FALSE, the default, example values in the result are masked so the report does not itself leak.

sample

The most distinct values examined in one table column; 10,000 unless the configuration says otherwise. A column with more is judged from an evenly spaced subset, and n then counts matches within that subset. Use Inf to examine every value. Running text is always examined in full.

config

The project's configuration, from pii_config(): files to ignore, custom patterns and extra terms.

Value

A tibble with one row per finding: source, locator, name, label, type, evidence (name, value or structure), detector, n and share of matching values, examples and confidence. type is the kind of personal data: person_name, phone, email, address, date_of_birth, location, coordinates, government_id, financial_account, ip_address, online_id, device_id, uuid, free_text, unique_text, or a custom pattern's type. detector says which rule matched, such as idcheck:us_ssn.

Details

In a table column a value pattern must match at least 5 values and 5% of them; in free text and documents a single match is reported.

The scan works on the distinct values of each column and uses the column's type, so numeric, date and logical columns skip the text patterns and a coded column costs little however many rows it has.

The result is a list of things to review. An empty result does not show that the data are safe to share.

Examples

survey <- data.frame(
  q1 = paste0("person", 1:20, "@example.org"),
  reason = rep(c("work", "family"), 10)
)
pii_scan(survey)
#> # A tibble: 1 × 11
#>   source locator name  label type  evidence detector     n share examples 
#>   <chr>  <chr>   <chr> <chr> <chr> <chr>    <chr>    <int> <dbl> <list>   
#> 1 data   q1      q1    NA    email value    email       20     1 <chr [3]>
#> # ℹ 1 more variable: confidence <chr>