Skip to main content

A Python library for detecting hardcoded secrets and API keys in code repositories

Project description

Secret Guardian

A Python library for detecting secrets and API keys

Development

This project uses Poetry for dependency management and 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

pip install secret-guardian

Usage

As a Python library

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

# 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..

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

secret_guardian-0.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

secret_guardian-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file secret_guardian-0.1.0.tar.gz.

File metadata

  • Download URL: secret_guardian-0.1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.13 Linux/6.11.0-1018-azure

File hashes

Hashes for secret_guardian-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ba7b2570c45661e6f2265a1ef5f61d06403c4df98a3efdb220ec1e75731e8937
MD5 89314a91d71e022a26bf46036943ed3c
BLAKE2b-256 e3a6cad6502c0a970ebac4d6af4279a3e9e284c429439f76923c4f8e4a37ea99

See more details on using hashes here.

File details

Details for the file secret_guardian-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: secret_guardian-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.13 Linux/6.11.0-1018-azure

File hashes

Hashes for secret_guardian-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8234343e52750cab79f519ecc504c65f0d680afa5b6751bf75e55d7fc144cbde
MD5 523bdce376006d4cc637f8172dd72d6b
BLAKE2b-256 b12649f25b32299a92bd44f21e509af7d7a8c6c6568c6fce37f91a1218a57a63

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