dtwo Policy Store

Detect Email PII (Allow with Reason)

A watch-only starter policy.

Direction
ingress
Rego package
onboarding.ingress.detect_email_allow
App
onboarding
Published
Minimum gateway
1.0.0b24
Schema version
1.0.0
Checksum
sha256:0df1b62128aadb82c9491c6fa8ce4776640b586a4cc4bf001240291b271b8617

onboardingpiiemailobservabilityingress

What this policy does

A watch-only starter policy. It looks for email addresses in what your agents send, and whenever it spots one it lets the request through but tags the decision with the note Email Detected. It never blocks anything.

This is a great first policy to turn on. You don't have to write any code to get value from it — attach it to a gateway and you'll start seeing real policy activity in your dashboard, so you can watch how often email addresses come up before deciding whether you want to do anything stricter.

What it does

Each time an agent calls a tool, this policy checks the request for anything that looks like an email address. If it finds one, the request still goes through, but the decision is labelled Email Detected so it stands out in your policy activity. If there's no email address, the request passes with no note.

Because it only watches and never blocks, it's safe to run from day one. When you're ready to actually act on email addresses, pair it with the companion policies that block them or hide them.

When to use it

Turn this on when you want visibility — to see whether, and how often, email addresses show up in your agents' activity — without changing what your agents are allowed to do.

Example

An agent tries to post the message "ping jane@example.com about the invoice". The request is allowed to continue, and the decision is tagged Email Detected so you can find it in your dashboard. A message with no email address is allowed with no note.

Policy source (Rego)

package onboarding.ingress.detect_email_allow

# Passive observability policy — always allows, but attaches an "Email Detected"
# reason when an email address appears anywhere in the request arguments.
default allow := true

# Matches an email address embedded anywhere in a string value.
email_pattern := `[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}`

# True when any (possibly nested) string value in the request args contains an email.
email_detected if {
    input.mode == "input"
    walk(object.get(input.payload, "args", {}), [_, value])
    is_string(value)
    regex.match(email_pattern, value)
}

# Allow-with-reason: the call is permitted, but the decision carries this reason
# so the detection is visible in the policy observability views.
reason := "Email Detected" if {
    email_detected
}

Canonical source: policy.md on GitHub · raw · raw on this site (.md)