Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.getbifrost.ai/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Custom Regex is a Bifrost Enterprise guardrail provider that evaluates request and response text against regex patterns you define. It is useful when you need a simple, local policy check without calling an external guardrail provider. Common uses include blocking organization-specific IDs, internal project names, environment-specific secrets, and PII-like text patterns.
Custom Regex runs in-process and uses Go’s RE2-compatible regexp engine. It does not support lookaheads, lookbehinds, or backreferences. Server-side RE2 validation is authoritative.

How It Works

  1. You create a guardrail provider with provider_name: "regex".
  2. You add one or more regex patterns.
  3. You attach that provider to a guardrail rule.
  4. The rule decides when to run the provider and whether to scan input, output, or both.
  5. If any pattern matches any evaluated text block, Bifrost returns GUARDRAIL_INTERVENED.
Custom Regex currently evaluates text content. It does not inspect image pixels or binary file contents.

Pattern Fields

FieldRequiredDescription
patternYesRE2-compatible regex pattern
descriptionNoHuman-readable label used in the intervention reason
flagsNoOptional flag or flag combination. Leave empty for no flag.
The Web UI exposes these flag choices:
FlagMeaning
NoneNo regex flag
iCase-insensitive matching
mMultiline mode
sDot matches newline
imCase-insensitive + multiline
isCase-insensitive + dot matches newline
msMultiline + dot matches newline
imsCase-insensitive + multiline + dot matches newline

PII Detection Template

The Web UI includes a PII Detection template under Add Pattern. It pre-fills a Custom Regex configuration with common PII-like patterns:
DescriptionFlags
Email addressi
US phone number-
US Social Security Number-
Credit-card-like number-
IPv4 address-
The exact template patterns are shown in the config.json and Helm examples below.
The PII Detection template is pattern-based. It is fast and transparent, but it is not semantic PII classification. Expect some false positives and false negatives, especially for international phone numbers and unformatted values. For national IDs outside the US, add your own Custom Regex patterns for the exact country and format you need to enforce.

Configuration

  1. Go to Guardrails > Providers.
  2. Select Custom Regex.
  3. Click Add Configuration.
  4. Set a descriptive Name, for example pii-detection.
  5. Click Add Pattern.
  6. Choose either Custom regexp or PII Detection.
  7. Enable the configuration and save it.
  8. Attach the configuration to a guardrail rule under Guardrails > Configuration.
PII Detection template selected from the Custom Regex pattern menu

When To Use Custom Regex

Use Custom Regex when:
  • You need transparent, deterministic matching.
  • You want to block a known organization-specific identifier or data format.
  • You want the built-in PII Detection template.
  • You need a local guardrail with no external service dependency.
Use Secrets Detection instead when you want broad credential and API key coverage from the built-in Gitleaks rules.