Skip to content

Repository files navigation

DocWasher

A local-first, pattern-driven text-file sanitizer that applies reusable regular expressions one line at a time, writes a cleaned result, separates rejected or affected content, and reports what happened.

Original concept

Christian Scheller is the Original Concept Creator, author of the initial Perl prototype, and a Co-Developer of DocWasher.

Christian originally described DocWasher as:

  • A “text file sanitizer”
  • “Inline-Regex bulk applied on a per-line level”
  • Including “basic statistics”
  • Useful for “Email cleaning”
  • Able to “leverage it with a dlp engine”
  • Able to load patterns “from a database based on source file type and content tags”

That is the product. The modern project expands the interfaces and safety controls without replacing that model.

The canonical DocWasher workflow

DocWasher takes four practical inputs or outputs:

  1. Source file: The text to inspect.
  2. Pattern source: Plain regex patterns or a reusable policy pack.
  3. Clean output: The content that remains after the selected rule behavior.
  4. Garbage or quarantine output: Rejected lines or original lines affected by sanitization.

It also produces processing statistics.

source file
   + patterns selected for the file type and tags
   + per-line regex processing
   ├── cleaned output
   ├── garbage/quarantine output
   └── statistics and audit report

Reconciliation of the original prototype and written instructions

Christian’s original material contains two related behaviors.

The Perl prototype

The Perl code joins all patterns into one regex and processes the source line by line:

  • A matching line is written to the destination file.
  • A nonmatching line is written to garbage.txt.
  • Counts are printed for both groups.

The modern equivalent is:

KeepMatchingLines

This legacy-compatible mode remains tested and preserved.

Christian’s how-to explanation

The accompanying instructions say to place regex in patterns.txt, remove matches from the input, and write the result to the new file.

The modern equivalent is:

RemoveMatchingText

This is the default modern sanitization mode because it matches Christian’s stated “text file sanitizer” intent.

DocWasher preserves both instead of pretending the original code and description said the same thing.

What DocWasher does now

Core processing modes

Mode Behavior Connection to Christian’s design
RemoveMatchingText Removes matching substrings and retains the rest of each line Matches the original how-to
KeepMatchingLines Keeps whole lines matching any pattern and sends other lines to garbage Reproduces the Perl prototype
RemoveMatchingLines Sends matching lines to quarantine and keeps nonmatching lines DLP and exclusion workflow
RedactMatchingText Replaces matches with a fixed marker Safe sharing and privacy
ReplaceMatchingText Applies ordered pattern/replacement rules Normalization and cleanup

Statistics

DocWasher reports:

  • Input, output, matched, and quarantined line counts
  • Total regex matches
  • Per-pattern match totals
  • Characters removed or replaced
  • Source and output sizes
  • Best-effort content type
  • Processing duration
  • Retained and discarded percentages
  • Case-sensitivity state
  • Processing timestamp

Reusable policy packs

Plain patterns.txt remains a first-class input.

The project now also supports .dwpack.json policy packs containing:

  • Pack name and version
  • Description and intended use
  • File extensions
  • Content types
  • Content tags
  • Processing mode
  • Replacement value when needed
  • Ordered regex patterns

Policy packs allow DocWasher to select rules based on source-file type and content tags, directly implementing Christian’s database-backed rule-selection idea in a portable, reviewable format.

Email cleaning

An email-cleaning policy pack can be selected for .eml, .txt, .csv, or exported mailbox content.

A local or explicitly configured AI can propose regex for:

  • Tracking parameters
  • Repeated disclaimer blocks
  • Known system banners
  • Identifiers requiring redaction
  • Noise that should be quarantined

AI-generated patterns are proposals. They must be reviewed before execution.

DLP integration

DocWasher includes a DLP wrapper suitable for scripts and pipelines.

It can:

  • Select a policy by file type and tags
  • Produce a cleaned file
  • Produce a quarantine file
  • Produce JSON statistics
  • Return a nonzero detection exit code when a policy matched content

DocWasher is an integration component, not a certified DLP or compliance product.

Quick start

Plain patterns

pwsh ./src/DocWasher.ps1 `
  -SourceFile ./samples/sample-input.txt `
  -PatternFile ./samples/patterns.txt `
  -OutputFile ./output/cleaned.txt `
  -DiscardedFile ./output/affected-original-lines.txt `
  -StatisticsFile ./output/statistics.json `
  -Mode RemoveMatchingText

Original Perl behavior

pwsh ./src/DocWasher.ps1 `
  -SourceFile ./tests/fixtures/legacy-input.txt `
  -PatternFile ./tests/fixtures/legacy-patterns.txt `
  -OutputFile ./output/kept.txt `
  -DiscardedFile ./output/garbage.txt `
  -StatisticsFile ./output/statistics.json `
  -Mode KeepMatchingLines

Policy-pack processing

pwsh ./src/Invoke-DocWasherPolicy.ps1 `
  -SourceFile ./samples/sample-email.txt `
  -PolicyPack ./policy-packs/email-cleaning.dwpack.json `
  -OutputFile ./output/cleaned-email.txt `
  -QuarantineFile ./output/email-quarantine.txt `
  -StatisticsFile ./output/email-statistics.json `
  -ContentTags email,external

DLP-style pipeline check

pwsh ./src/Invoke-DocWasherDlp.ps1 `
  -SourceFile ./samples/sample-input.txt `
  -PolicyDirectory ./policy-packs `
  -ContentTags pii,external `
  -OutputDirectory ./output

Exit code 2 means the selected policy matched content.

AI-assisted policy generation

Generate a reviewable AI prompt without uploading source content:

pwsh ./tools/New-DocWasherAiPolicyPrompt.ps1 `
  -Goal "Remove tracking IDs and redact email addresses" `
  -FileType ".eml" `
  -ContentTags email,external `
  -OutputFile ./output/policy-prompt.txt

The prompt asks the AI to return a valid .dwpack.json policy pack.

Source examples are excluded unless they are explicitly provided.

Local-first security model

  • Source text is processed locally.
  • No telemetry is enabled.
  • AI integration is optional.
  • Raw source content is not sent to an AI by default.
  • Regex operations use timeouts in the PowerShell engine.
  • Output should be reviewed before sharing or deleting the source.
  • Sensitive examples must not be posted in public issues.

Original source preservation

Christian’s original Perl prototype is preserved in:

legacy/docwasher.pl

The original usage and historical behavior are documented in:

legacy/howto-original.txt
ORIGIN.md

Project authorship

Christian Scheller

Original Concept Creator, Author of the Initial Perl Prototype, and Co-Developer

Christian defined the original product model, wrote the initial Perl implementation, and identified the email-cleaning, AI-generated-pattern, DLP, and database-backed policy directions.

Clinton Kosh

Co-Developer and Modernization/Public Project Lead

Clinton reconstructed the project as a tested, documented, local-first public tool; expanded the processing modes; added policy packs, automation, browser and CLI workflows; and led packaging and publication.

License

MIT License.

Copyright © 2026 Clinton Kosh and Christian Scheller.

About

Local-first regex text sanitizer created from Christian Scheller's original per-line DocWasher concept, with policy packs, AI-assisted rule design, DLP workflows, and audit statistics.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages