PiiCatalog.ScanError exception (pii_catalog v0.1.0)

Copy Markdown View Source

Raised by PiiCatalog.scan/2 and PiiCatalog.find/2 when the regex engine stops before it has scanned the whole text, for example when a pattern reaches the engine's match limit (:match_limit) on a crafted input.

The scan reports no result for that text rather than the matches found before the engine stopped: a text that was not fully scanned is not reported as holding no identifier. What to do with the text, such as refusing it or redacting it whole, is the caller's choice.

The catalog's tests run its patterns on crafted inputs that make regexes backtrack, such as a keyword followed by thousands of spaces; a pattern of your own can still reach the limit.

  • patterns – the names of the patterns that were being scanned. For the shared pass (see PiiCatalog.Scanner) these are all the patterns in it.
  • reason – the error the regex engine returned, such as :match_limit or :match_limit_recursion.

Summary

Functions

The error as a sentence, naming the patterns and the engine's reason.

Types

t()

@type t() :: %PiiCatalog.ScanError{
  __exception__: true,
  patterns: [atom()],
  reason: term()
}

Functions

message(scan_error)

@spec message(t()) :: String.t()

The error as a sentence, naming the patterns and the engine's reason.