How cado-security/masked-ai works
Project type and purpose
• From the README and file tree, we see that Masked-AI is a Python SDK plus a CLI wrapper. Its job is to “mask” sensitive data in user inputs, forward the redacted request to an LLM API (e.g., OpenAI), then “unmask” the API’s response so the user sees their original data. It’s not a microservice or web app; it’s a standalone CLI tool backed by a Python library.
File structure
• Top-level directories:
• masked_ai/ ← core library code
– core/masks.py ← mask definitions (IP, email, credit-card, etc.)
– masker.py ← orchestrates masking, API execution, unmasking
• tests/ ← unit tests for masks and CLI functionality
• ci/, .github/ ← CI linting, type checks, GitHub Actions (app-ci.yml, publish.yml)
• release/ ← scripts to build binaries and upload to PyPI
• setup.py, requirements.txt, setup.cfg ← packaging & dependencies
• No webserver, no database directories: this is a library + CLI that invokes an external API.
README for additional insights
• It calls out core classes (“MaskBase”, IPMask, EmailMask, etc.) and shows example usage of the Masker class.
a. Components:
1) CLI Frontend (“masker” executable)
2) Masker Library
– Mask Engine (core/masks.py)
– Masker Orchestrator (masked_ai/masker.py)
3) External LLM API (OpenAI/GPT-4/etc.)
4) Packaging & Distribution (PyPI, release scripts)
5) CI/CD Pipeline (GitHub Actions, flake8, mypy)
6) Tests (pytest)
b. Relationships / Data Flow:
• User types a command or invokes Python SDK →
• CLI Frontend calls Masker Orchestrator →
• Orchestrator runs each Mask class to transform raw input →
• Sends masked payload to External LLM API over HTTPS →
• Receives API JSON response →
• Orchestrator calls unmask routines to re-insert sensitive data →
• Returns final output to user
c. Architectural patterns / design principles:
• Strategy pattern for masks (MaskBase subclasses)
• Single responsibility: each mask handles only one data type
• Plug-in architecture: new masks auto-discovered by inheritance
• Thin orchestration layer – no persistent storage
• CLI + library co-exist in same package
d. Key technologies / libraries:
• Python 3.x
• re (regex) for mask detection
• Click or argparse (implicitly used in masker.py for CLI)
• HTTP client (curl or requests in examples)
• pytest for tests
• GitHub Actions for CI/CD
• PyPI packaging via setup.py / setup.cfg