← back to Goodquestion Ai
src/content/posts/2026-02-25-the-content-sanitizer-that-guards-every-channel.md
133 lines
---
title: '200+ Safety Patterns, 5 Channels, Zero Leaks: The Sanitizer That Guards Every Output'
description: "I built a content safety system with 200+ patterns across 5 channels. It catches leaks I'd never spot manually."
date: 2026-02-25
draft: false
tags: ["security", "automation", "ai", "infrastructure"]
---
When you build in public, every output channel is a potential leak. Blog posts, video titles, social media captions, even version control messages — any of them can accidentally expose internal data. So I built a sanitizer that sits between my content and the world.

## The Problem
I run a production system with hundreds of sensitive patterns: company names, supplier identifiers, database field names, API credentials, server addresses, internal pricing structures, and product counts that reveal business scale. These patterns exist across my entire stack — in dashboards, terminal output, config files, and the AI-generated content I publish daily.
The challenge is not catching one type of leak. It is catching all of them, across every output format, before anything goes live.
## Three Layers of Defense
### Layer 1 — The Sanitizer
The core is a function that takes raw text and runs it through 200+ pattern-matching rules. Each rule maps a sensitive term to a safe replacement.
The rules cover eight categories:
1. **Company and brand names** — anything that identifies the business
2. **Industry-specific terms** — words that reveal what vertical you operate in
3. **Supplier names** — 90+ partner identities
4. **Server addresses** — infrastructure details
5. **Credentials and tokens** — API keys, database connections, auth tokens
6. **Database schema** — internal field names and table structures
7. **Pricing data** — cost structures, margins, wholesale numbers
8. **Scale indicators** — product counts, record totals, process counts
Every piece of content — blog posts, video descriptions, social captions — passes through this function before it touches any public channel.
### Layer 2 — The Audit Gate
Sanitizing alone is not enough. You need to verify. The audit is a separate pass that does not replace anything — it only detects. If anything slips through sanitization (or was never sanitized), the audit catches it.
The audit checks things the sanitizer might miss:
- **Large numbers near business words** — a phrase like "thousands of products" might be fine, but a specific count reveals scale even if the company name is scrubbed
- **Internal field names** — column names like `internal_cost` or `profit_margin` leak your database schema
- **Service URLs** — internal addresses expose your architecture
- **Private code repositories** — links to repos that should not be public
- **Formatted large numbers** — catches counts that reveal data volume
If the audit flags a problem, the content does not publish. The system retries sanitization up to three times. If the audit still fails after three passes, the post is blocked entirely. I would rather publish nothing than publish a leak.
### Layer 3 — Version Control Hooks
The final layer runs every time code is saved to the repository. A pre-save hook scans every staged file against the same audit function. If any file contains a violation, the save is rejected.
This is the last line of defense. It catches things that bypass the application layer entirely — like a developer (or an AI agent) directly editing a file and committing without going through the content pipeline.
I learned the hard way that this hook is necessary. During one session, a script that captured dashboard data contained a server address. The hook blocked it. Without that layer, it would have been pushed to a public repository.
## Multi-Channel Coverage
The sanitizer guards every output channel:
- **Blog posts** — sanitized during generation, audited before publish, audited again at save
- **Video titles and descriptions** — scanned and cleaned via the same rule set
- **Social media posts** — captions pass through the sanitizer before posting
- **Screen recordings** — a separate pipeline extracts text from video frames and blurs anything that matches the pattern set
- **Code commits** — the pre-save hook blocks any staged file with violations
Each channel uses the same core functions. One pattern set, applied everywhere. When I add a new sensitive term, every channel is immediately protected.
## What I Learned Building This
**Overlapping replacements create artifacts.** When you have patterns that overlap (a supplier name that contains a word that is also an industry term), you can end up with garbled output. I added a cleanup pass that catches these compound replacements.
**The audit is stricter than the sanitizer — by design.** The sanitizer tries to fix things. The audit just flags them. Sometimes the sanitizer replaces a supplier name but the audit flags the replacement itself because it appears near a product count. That is intentional. The audit is paranoid. The sanitizer is practical.
**Three passes is the right number.** AI-generated content sometimes embeds sensitive terms in creative ways — inside analogies, as example names, or in code blocks. One pass catches the obvious terms. A second catches terms exposed by the first pass. A third catches edge cases. After three, if content is still failing, it needs human review.
## The Pipeline in Practice
Here is what happens when the system generates a new post:
1. AI generates raw content based on a topic prompt
2. The content runs through the sanitizer — first pass
3. The result runs through the audit — if violations found, back to step 2 (up to 3 times)
4. If clean, the post is saved to the website
5. The site rebuilds automatically
6. The post URL is distributed to social media channels
7. Those social posts also pass through the sanitizer before sending
8. On next code save, the pre-save hook validates the new file again
If any step fails, the pipeline stops. No partial publishes. The sanitizer is the gatekeeper, and it does not negotiate.
## Results
| Metric | Value |
|--------|-------|
| Active safety patterns | 200+ |
| Output channels covered | 5 |
| Categories of sensitive data | 8 |
| Sanitization passes per post | Up to 3 |
| Leaks caught post-deploy | 0 |
Since deploying this system, I have caught and blocked:
- Server addresses in dashboard capture scripts
- Internal field names in technical blog posts
- Product counts that reveal business scale in social media captions
- Platform names in video titles
- Supplier identifiers that AI hallucinated into "example" scenarios
The system has blocked content that I would not have caught manually. That is the point. When you are publishing across five channels daily, human review does not scale. Automated, multi-layer sanitization does.
## What This Means For Your Business
If you are building in public, creating content with AI, or running any system where internal data could leak into external channels — you need a content safety layer. Not a checklist. Not a "be careful" policy. An automated gate that blocks sensitive content before it reaches the outside world.
The investment is a few days of building pattern rules and integrating them into your publishing pipeline. The return is never having to explain to a client why their name appeared in your blog post, or to a partner why your pricing showed up on social media.
Prevention is not just cheaper than damage control. It is the only approach that scales.
---
## Ask Me Anything
Building content safety tools for public-facing AI systems? I would love to hear your approach.
- [YouTube — @AgentAbrams](https://www.youtube.com/@AgentAbrams)
- [X — @agentabrams](https://x.com/agentabrams)
- [Bluesky — @agentabrams](https://bsky.app/profile/agentabrams.bsky.social)
- [goodquestion.ai](https://goodquestion.ai)