Metadata-Version: 2.1
Name: secret-guardian
Version: 0.1.0
Summary: A Python library for detecting hardcoded secrets and API keys in code repositories
Home-page: https://github.com/panyu1512/secret-guardian
License: MIT
Keywords: security,secrets,api-keys,code-scanning
Author: panyu1512
Author-email: kikeferreragius1997@gmail.com
Requires-Python: >=3.8.1,<4.0.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: click (>=8.1.7,<9.0.0)
Requires-Dist: gitpython (>=3.1.40,<4.0.0)
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
Project-URL: Repository, https://github.com/panyu1512/secret-guardian
Description-Content-Type: text/markdown

# Secret Guardian

A Python library for detecting secrets and API keys 

## Development

This project uses [Poetry](https://python-poetry.org/) for dependency management and [Ruff](https://docs.astral.sh/ruff/) as linter and formatter.

## Features

- **Automatic detection** of multiple types of secrets and API keys
- **Built-in patterns** for AWS, GitHub, Google, Slack, JWT and more
- **Protection verification** with `.env` and `.gitignore` files
- **Customizable patterns** for specific use cases
- **CLI interface** for CI/CD integration
- **Detailed reports** in text or JSON format
- **Smart filtering** of false positives
- **Hardcoded secret detection** anywhere in source code

## Installation

```bash
pip install secret-guardian
```

## Usage

### As a Python library

```python
from secret_guardian import SecretScanner, SecretFoundError

# Scan a repository
scanner = SecretScanner("./my-project")

try:
    # Scan and raise exception if secrets are found
    matches = scanner.scan(raise_on_secrets=True)
    print("No secrets found")
except SecretFoundError as e:
    print(f"Found {len(e.secrets_found)} secrets")
    
    # Generate report
    report = scanner.generate_report(e.secrets_found)
    print(report)
```

### Command line interface

```bash
# Scan current repository
secret-guardian scan .

# Scan with custom options
secret-guardian scan ./my-project --no-env-check --output json

# View statistics
secret-guardian stats .

# List available patterns
secret-guardian patterns
```

## Detected Patterns

- **AWS**: Access Keys, Secret Keys
- **GitHub**: Personal Access Tokens, Classic Tokens
- **Google**: API Keys
- **Slack**: Bot Tokens, User Tokens
- **JWT**: JSON Web Tokens
- **Database**: Connection URLs
- **Private keys**: RSA, SSH
- **Generic API Keys**
- **Passwords**

## License

MIT License. See `LICENSE` for more details..
