Skip to main content

Never commit API keys again - Secret scanner for AI/ML projects

Project description

๐Ÿ›ก๏ธ EnvGuard

Never commit API keys again.

Secrets Security scanner for AI/ML projects. Detects exposed OpenAI, Anthropic, HuggingFace, AWS, and 10+ other API keys before they reach your repository.

How to Use

Install

pip install aisecretscanner

Scan

aisecretscanner

That's it. Zero configuration required.


๐ŸŽฏ Why AI Secret Scanner?

Every developer has done this at least once:

# โŒ Committed to GitHub
OPENAI_API_KEY = "sk-proj-abc123..."

One mistake = $10,000 bill from scrapers. This product prevents this.

The Problem

  • Exposed API keys cost developers $500M+ annually
  • AI API keys are particularly valuable (OpenAI, Anthropic, etc.)
  • Generic scanners miss AI-specific patterns
  • Detection happens after the damage is done

The Solution

$ aisecretscanner

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘     EnvGuard - AI API Key Security Scanner                โ•‘
โ•‘      Never commit API keys again                          โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ” Scanning project...

 Found 3 exposed secret(s)!

[CRITICAL] OpenAI API Key
File: app.py:5
Key: sk-pr...DEF
Fix: Move this key to .env file and add to .gitignore

Result: Keys secured in 30 seconds, Dollars saved.


Features

AI API Keys Detection

Catches 12+ AI/ML API key types that other scanners miss:

  • OpenAI - GPT-4, GPT-3.5, DALL-E
  • Anthropic - Claude (all models)
  • HuggingFace - Models & Datasets
  • AWS - Access keys & secrets
  • Azure - OpenAI Service keys
  • Google AI - Gemini, PaLM, Vertex
  • Replicate - Model deployment
  • Pinecone - Vector databases
  • Cohere - Text generation
  • GitHub - Personal access tokens
  • Slack - Bot tokens
  • ...and more to come soon

Lightning Fast

  • Scans 1,000 files in <1 second
  • Smart file filtering (ignores node_modules, venv, etc.)
  • Zero dependencies = instant startup

Result Output

  • Color-coded severity levels
  • Exact file locations
  • Redacted key previews (secure logging)
  • Actionable remediation steps
  • Summary statistics

Secure by Design

  • Never logs actual keys (shows only redacted previews)
  • Runs entirely locally (no data leaves your machine)
  • Read-only operations
  • No network calls
  • No telemetry

Installation Methods

Method 1: pip (Recommended)

pip install aisecretscanner

Method 2: Direct Download

curl -O https://raw.githubusercontent.com/faythashiedu/AI_Secret_Scanner/main/aiEnvGuard.py
python aiEnvGuard.py

Method 3: GitHub Action

# .github/workflows/security.yml
name: Security Scan

on: [push, pull_request]

jobs:
  envguard:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: faythashiedu/aisecretscanner@v1

Method 4: Pre-commit Hook

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/faythashiedu/AI_Secret_Scanner
    rev: v1.0.0
    hooks:
      - id: aisecretscanner

๐ŸŽฎ Usage

Basic Scan

# Scan current directory
aisecretscanner

# Scan specific path
aisecretscanner /path/to/project

# Exit code 0 = safe, 1 = secrets found

CI/CD Integration

# GitHub Actions, GitLab CI, etc.
aisecretscanner || exit 1  # Fail build if secrets found

Pre-commit Hook

# Install pre-commit
pip install pre-commit

# Add EnvGuard hook (see .pre-commit-config.yaml)
pre-commit install

# Now runs automatically on git commit

What It Detects

OpenAI Keys

# โŒ Will be detected
OPENAI_API_KEY = "sk-proj-abcd1234..."
openai.api_key = "sk-abc123..."

Safe Patterns

# Will NOT be flagged
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
load_dotenv() 
api_key = "your_api_key_here"  

CI/CD Examples

GitHub Actions

name: Security Scan
on: [push, pull_request]

jobs:
  security:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Run AI_Secret_Scanner
        run: |
          pip install aisecretscanner
          aisecretscanner

GitLab CI

security-scan:
  stage: test
  script:
    - pip install aisecretscanner
    - aisecretscanner
  only:
    - merge_requests
    - main

Pre-commit

repos:
  - repo: https://github.com/faythashiedu/AI_Secret_Scanner
    rev: v1.0.0
    hooks:
      - id: aiEnvGuard
        stages: [commit]

Adding New Patterns

Edit PATTERNS dict in aiEnvguard.py:

PATTERNS = {
    'your_service': {
        'pattern': r'your-regex-pattern',
        'name': 'Your Service API Key',
        'severity': Severity.HIGH,
        'docs': 'https://docs.yourservice.com/api-keys'
    }
}

๐Ÿ“„ License

MIT License - see LICENSE file for details.


โญ Star History

If EnvGuard saved you from a $10k OpenAI bill, consider giving it a star! โญ


EnvGuard - Because one leaked key is one too many. ๐Ÿ›ก๏ธ

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

aisecretscanner-1.0.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

aisecretscanner-1.0.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file aisecretscanner-1.0.0.tar.gz.

File metadata

  • Download URL: aisecretscanner-1.0.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for aisecretscanner-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b36447a6ea9609b7e3740d7866bb66784eff1716aa384d55c6f2d0fe275f70f0
MD5 e653602b916cd0d34289a4c25f03c658
BLAKE2b-256 e347817574ea29bad8a6a256f1a1f912f3d52441dd9d21466a09a5369daa310d

See more details on using hashes here.

File details

Details for the file aisecretscanner-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aisecretscanner-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5753b3078f86ccd3864ef628823c61e6edecea17dca3fe9fd7e84513739d445f
MD5 65f1adbfbd392e0db3ee7d9314c30d08
BLAKE2b-256 eeafca6a11e4feb76e4d8322f88046d1bde051002c7406459ffc922b4eb8826d

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