Skip to content

feat(analyzer): Add configurable offline mode to EmailRecognizer to prevent external PSL network calls #2447

Open

Description

@theharuun

Is your feature request related to a problem? Please describe.
In strictly offline, air-gapped, or firewalled enterprise environments, EmailRecognizer can trigger unexpected outbound HTTP calls or socket timeouts during validation because tldextract.extract() attempts to fetch/update the latest Public Suffix List (PSL) from publicsuffix.org. (Historically discussed in #1205).

Describe the solution you'd like
Introduce an opt-in offline: bool = False parameter to EmailRecognizer and its YAML configuration schema (EmailRecognizerConfig):

  • offline=False (default): Preserves 100% backward compatibility using standard tldextract.extract.
  • offline=True: Instantiates tldextract.TLDExtract(suffix_list_urls=()), which strictly uses the snapshot bundled inside the package wheel, completely disabling all external network access.

Describe alternatives you've considered
Overriding validate_result via subclasses or pre-populating container cache directories manually, but having a native, loader-compatible offline: true flag in Presidio provides a clean, zero-workaround solution for air-gapped deployments.

Additional context
I have implemented and tested this locally:

  • Unit tests verifying email detection with offline=True.
  • Monkeypatch test asserting suffix_list_urls=() is passed to TLDExtract.
  • Full YAML validation via EmailRecognizerConfig registered in CONFIG_MODEL_MAP.
  • End-to-end RecognizerRegistryProvider test verifying both offline: true and supported_entities mapping/analysis.

I can submit a Pull Request right away if this approach looks good!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions