Skip to main content

A package to detect sensitive information in code and files

Project description

Sensitive Data Detector 🔍

A Python package that helps detect sensitive information in files and code. Protect your codebase from accidental exposure of API keys, passwords, tokens, and other sensitive data.

PyPI version Python Versions License: MIT Code style: black Imports: isort Made with Python

🚀 Features

  • 🔑 Detects API keys and tokens
  • 📧 Identifies email addresses
  • 🔐 Finds sensitive patterns in code
  • ⚙️ Configurable detection patterns
  • 📁 Works with any text-based file
  • 🛡️ Pre-commit hook support
  • 🧑‍💻 Now fully object-oriented for easier extension and testing!

📦 Installation

pip install sensitive_data_detector

🎯 Quick Start

from sensitive_data_detector import SensitiveChecker

checker = SensitiveChecker()  # Optionally pass a custom config path
result = checker.has_sensitive_info("path/to/your/file.txt")
if result:
    True #(sensitive info found in the file)
else:
    False #(no sensitive info found)

🔍 What It Detects

The package detects various types of sensitive information, including:

  • API Keys and Tokens
  • Email Addresses
  • Private Keys
  • Access Tokens
  • Passwords
  • And more configurable patterns

🛠️ Development Setup

# Clone the repository
git clone https://github.com/akashdv25/sensitive_info_detector.git
cd sensitive_info_detector

# Create and activate virtual environment (optional)
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run pre-commit hooks
pre-commit run --all-files

🔧 Configuration

The package uses a config.json file that defines patterns for sensitive information detection. You can customize these patterns for your specific needs.

Default patterns include:

{
    "sensitive_info": {
        "api_keys": "(?i)((api[_-]key|apikey|api_secret|api[_-]token|auth[_-]token|access[_-]token)['\"]?\\s*[:=]\\s*['\"]([\\w\\-._]+)['\"])",
        "emails": "\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b"
    }
}

🐍 Python Version Support

  • Python 3.9
  • Python 3.10
  • Python 3.11

🛠️ Built With

🆕 Changelog

v1.1.0 (new)

  • Refactored core modules to use object-oriented programming (OOP) principles.
  • Added SensitiveChecker, PatternLoader, FileReader, and ContentAnalyzer classes.
  • Improved type annotations and mypy compatibility.
  • Enhanced code maintainability and extensibility.

🤝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests (pytest)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

🔗 Project Links

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

📫 Contact

Akash Anandani


Made with ❤️ by Akash Anandani

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sensitive_data_detector-1.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sensitive_data_detector-1.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file sensitive_data_detector-1.1.0.tar.gz.

File metadata

  • Download URL: sensitive_data_detector-1.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for sensitive_data_detector-1.1.0.tar.gz
Algorithm Hash digest
SHA256 0f88c401bd774da34165635874ddd047668028e533cc22503012e078834258b9
MD5 3aafe0c322534f067968a483171db3a2
BLAKE2b-256 a99b8f04ee68a9af125747c2b435b53c60dd48e1691a7b68aa5c89a3121a5059

See more details on using hashes here.

File details

Details for the file sensitive_data_detector-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sensitive_data_detector-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15ba241eb48c55b9755f49efbee1d1479c7698e0d08910d5d82a38577192f9e3
MD5 dbee7a73c547233de9337e1713683e5f
BLAKE2b-256 80feb2b6584bf41ef418e09d3d4873df5a469ba0fea5baede17fea6ecccab5d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page