๐งญ Cleansh โ Sanitize Your Terminal Output, Securely.
A high-trust, single-purpose CLI tool that sanitizes terminal output for safe sharing. Secure by default. Zero config required. Extendable when needed. It is still in active development; while the latest
v0.1.2release addresses critical output formatting and stability, we value your feedback, so please do report any issues you encounter.
๐ Table of Contents
- โจ Overview
- โ Core Capabilities โ Current Version (v0.1.2)
- ๐ Usage Examples
- โ ๏ธ Known Issues
- ๐งฑ Project Structure
- โ Configuration Strategy
- ๐ Clipboard Support
- ๐ง Sanitizer Engine Design
- ๐ Logging and Error Handling
- ๐งช Testing and Validations
- ๐ Packaging & Distribution
- ๐ Metadata & License
- ๐ Security by Default Principles
- ๐ Future-Proofing (Post v1.0 Aspirations)
- ๐งต Summary of Technology Stack
โจ Overview
cleansh is a powerful and reliable command-line utility designed to help you quickly and securely redact sensitive information from your terminal output. Whether you're debugging, collaborating, or sharing logs, cleansh ensures that confidential data like IP addresses, email addresses, and access tokens never leave your local environment unmasked. Piped directly from stdin or loaded from files, cleansh provides a robust, pre-configured solution for data sanitization, with flexible options for custom rules and output formats.
Sanitize your terminal output. One tool. One purpose.
โ Core Capabilities โ Current Version (v0.1.2) - Stability & Output Refinement
This version of cleansh focuses on providing essential sanitization features with a strong emphasis on security and ease of use, building upon the "Precision View" of v0.1.1. Based on our rigorously passing test suite, you can trust cleansh to accurately mask the following sensitive data types and handle output reliably:
๐ฏ Primary Redaction Categories:
- Emails: Common email address formats (e.g.,
user@example.com). - IP Addresses: Both IPv4 addresses (e.g.,
192.168.1.1). - Tokens & Secrets: Generic tokens, JSON Web Tokens (JWTs), AWS keys, GCP keys, SSH keys, and common hex secrets.
- Absolute Paths: Currently,
cleanshredacts Linux paths (e.g.,/home/user/documents/report.pdfare transformed to~/home/user/...) and macOS paths (e.g.,/Users/admin/logs/app.logare transformed to~/Users/admin/...).
๐ก Optional Features (with flags):
cleansh provides command-line flags to customize its behavior, all thoroughly tested:
- Copy to Clipboard: Use
--clipboard(-c) to automatically copy the sanitized output to your system's clipboard. - Show Diff View: Use
--diff(-d) to display a clear, line-by-line colored diff between the original and sanitized content, highlighting all redactions, powered by thediffycrate. - Load Custom Config: Use
--config <path/to/config.yaml>to apply your own custom redaction rules, which can augment or override the powerful built-in defaults. - Output to File: Use
--out <path/to/result.txt>to write the sanitized output directly to a specified file.
๐ Usage Examples
Basic Sanitization (Piping from stdin)
echo "My email is test@example.com and my IP is 192.168.1.1." | cleansh
Cleaning docker logs before sharing
|
Sanitizing kubectl logs output
|
Copying to Clipboard (-c or --clipboard)
|
Showing a Diff View (-d or --diff)
|
Loading Custom Redaction Rules (--config <path>)
|
Outputting to a File (-o <path>)
|
Reading Input from a File
Combining Flags
|
โ ๏ธ Known Issues
1. Windows Absolute Path Redaction
- Severity: Medium
- Impact: Windows paths like
C:\Users\Alex\...are not currently redacted. - Workaround: Use a custom YAML rule.
2. Partial Custom Rule Interaction
- Severity: Low
- Impact: Custom rules may be partially overridden by built-in generic token rules.
- Workaround: Make custom patterns highly specific to avoid overlap.
๐งฑ Project Structure
cleansh/
โโโ src/
โ โโโ main.rs
โ โโโ commands/
โ โโโ tools/
โ โโโ config/
โ โโโ ui/
โ โโโ tests/
โโโ config/
โ โโโ default_rules.yaml
โโโ .env
โโโ .gitignore
โโโ Cargo.toml
โโโ README.md
โโโ LICENSE (MIT)
โ Configuration Strategy
1. Runtime Settings (from .env)
Example:
LOG_LEVEL=info
CLIPBOARD_ENABLED=true
DEFAULT_CONFIG=./config/default_rules.yaml
2. User Rule Configuration (via --config)
rules:
- name: my_company_id
pattern: 'EMP-\d{5}'
replace_with: '[EMPLOYEE_ID_REDACTED]'
description: "Redacts company employee IDs."
multiline: false
dot_matches_new_line: false
๐ Clipboard Support
macOS & Windows: Fully supported.
Linux: Requires xclip, xsel, or wl-clipboard.
๐ง Sanitizer Engine Design (in src/tools/sanitize_shell.rs)
Internal Pipeline:
- Input Acquisition
- Path Normalization
- Built-in Rule Application
- User Rule Application
- Output (stdout, file, clipboard, or diff view)
Engine Architecture:
regex::RegexSetstrip-ansi-escapes- Compile-time embedded rules
๐ Logging and Error Handling
Logging:
- Powered by
log+env_logger - Configurable via
.envor--debug
Error Handling:
anyhow+thiserror- Fail-safe, graceful recovery on non-blocking issues
๐งช Testing and Validations
Unit Tests:
- Regex Accuracy
- Path Redaction
- YAML Parsing
Integration Tests:
- Stdin Piping
- Clipboard Mocks
- File Output
- Diff Accuracy
- No Redaction Grace Case
๐ Packaging & Distribution
Installation
Prebuilt Binaries: GitHub Releases
Recommended One-liner (Linux/macOS):
|
โ ๏ธ Ensure the installer script adds
cleanshto yourPATH. This script currently assumes local install and does not requiresudo.
Rust Users (via crates.io):
Building from Source
Distribution Automation
๐ Metadata & License
Metadata (in Cargo.toml)
[]
= "cleansh"
= "0.1.2"
= "2024"
= "MIT"
= "https://github.com/KarmaYama/cleansh"
= "https://github.com/KarmaYama/cleansh"
= ["Cleansh Technologies LLC"]
= "README.md"
= "https://crates.io/crates/cleansh"
= "1.88.0"
= ["command-line-utilities"]
= ["cli", "security", "redact", "sanitize", "clipboard"]
= "Sanitize your terminal output. One tool. One purpose."
License
This project is licensed under the MIT License.
๐ Security by Default Principles
| Feature | Principle |
|---|---|
| No runtime eval | Regex-only logic โ no execution of external inputs. |
| Local-only | No cloud or telemetry. |
| Immutable defaults | Redaction rules are compiled in, not loaded dynamically. |
| Path redaction | File system details are sanitized by default. |
| YAML sandboxed | Config is declarative only. |
| Clipboard opt-in | Requires -c flag โ avoids silent clipboard actions. |
๐ Future-Proofing (Post v1.0 Aspirations)
- Plugin system for redaction logic
- VS Code extension or web GUI
- WASM/browser version
- Git hook integration
- Advanced enterprise-focused redaction tiers
๐งต Summary of Technology Stack
| Area | Stack/Choice |
|---|---|
| Language | Rust |
| Config Format | .env + YAML |
| CLI Parsing | clap |
| Regex Engine | regex |
| ANSI Stripping | strip-ansi-escapes |
| Diff Generation | diffy |
| Clipboard | arboard |
| Logging | log, env_logger |
| Error Handling | anyhow, thiserror |
| Installation | cargo-dist, curl, cargo install |
| License | MIT |
๐ If you use
cleansh, share your logs safely and confidently. ๐ฏ Precision redaction. Local-only trust. Built for devs.