Skip to main content

Overall Class Structure

Rules inherit from RuleBase and must implement the process method. They detect specific content and return a RuleOutput with confidence score and detected keywords.

RuleOutput Fields

The triggered_keywords list is important — it tells the action (e.g., replace_triggered_keywords or anonymize_triggered_keywords) which exact strings to transform.

Example Rule

Here’s a complete example of a custom rule that detects company-specific confidential terms:
When using regex patterns with capturing groups (...), use non-capturing groups (?:...) instead. Capturing groups cause re.findall to return only the captured group content (which may be empty), rather than the full match. This can lead to empty strings being passed to the action as triggered keywords.

Using LLM in Rules

For more intelligent detection, you can use LLM-powered content finding: