Skip to main content

PyGitGuard Logo

🛡️ PyGitGuard

PyGitGuard is a Git security scanner designed to prevent accidental commits of sensitive data by scanning for:

  • 🧪 Exposed credentials
  • 📁 Potentially sensitive files
  • 📄 Missing best practice files

📦 Version History

1.0.4

  • Standarize project to upload in pipy

1.0.3

  • Fix: "Do not block commits in cases of recommendations."
  • Adding context message after run
  • Docs: "Documenting some files to maintain consistency."

1.0.2

  • Refactor: Standarize a bit lines with black linter.

1.0.1

  • Fix: pip install support.
  • Fix: pre-commit support.
  • Fix: Improvements to config in .pre-commit-config.yaml.
  • Fix: Add pre-commit to requirements.txt.
  • Fix: Creating config files if they do not exist.
  • Fix: Remove interactive mode with input (not supported with pre-commit).

1.0.0 – Initial release with core features

✅ Features

  • 🚫 Detect sensitive content via regex (e.g., passwords, tokens, API keys)
  • 🔍 Scan for sensitive filenames like .env, .pem, id_rsa
  • 📏 Enforce maximum file size policies
  • 📚 Recommend best practice files (e.g., README.md, .gitignore, LICENSE)
  • 🔄 Auto-generate configuration files
  • 🪝 Pre-commit hook support

🚀 Quick Start Guide

1. Install PyGitGuard

pip install git+https://github.com/digo5ds/pygitguard.git

2. Install and Configure pre-commit

If you haven't already:

pip install pre-commit
pre-commit install

To manually run a scan:

pygitguard

To scan a specific path:

pygitguard --path <your_repository>

With pre-commit configured, the scan runs automatically before each commit.

Scan Report Example

To bypass a scan for a commit:

git commit -m "your message" --no-verify

⚙️ Configuration

On the first run, .pygitguard.yaml and .pre-commit-config.yaml is created (if not exists). This file allows customization of scan behavior.

📌 Using with .pre-commit-config.yaml

If you're already using pre-commit, add this to your config:

repos:
  - repo: https://github.com/digo5ds/pygitguard
    rev: 1.0.1  # Replace with the latest release
    hooks:
      - id: pygitguard-scan
        name: PyGitGuard Scan
        entry: pygitguard
        language: system
        types: [python]
        stages: [pre-commit]

Example .pygitguard.yaml

SENSITIVE_PATTERNS:
  - .*\.env.*$
  - .*\.pem.*$
  - .*\.key.*$
  - .*\.crt.*$
  - .*\.sqlite.*$
  - .*\.db.*$
  - .*secret.*$
  - .*credential.*$
  - .*id_rsa.*$
  - .*password.*$
  - .*token.*$
  - .*ACCESS_KEY.*$

SENSITIVE_CONTENT:
  - \b\w*password\w*\s*=\s*['"`].+['"`]
  - \b\w*token\w*\s*=\s*['"`].+['"`]
  - \b\w*api[_-]?key\w*\s*=\s*['"`].+['"`]
  - \b\w*user(name)?\w*\s*=\s*['"`].+['"`]
  - \b\w*ACCESS_KEY\w*\s*=\s*['"`].+['"`]

BEST_PRACTICES_FILES:
  - .gitignore
  - README.md
  - LICENSE
  - requirements.txt
  - pyproject.toml
  - Dockerfile: .dockerignore
  - docker-compose.yml: .dockerignore
  - __version__.py  # Recommended

MAX_FILE_SIZE_MB: 1

💡 Tips

  • Add __version__.py to BEST_PRACTICES_FILES to track versioning.
  • Customize MAX_FILE_SIZE_MB for your project's sensitivity.

🔧 Local Hook Example

To use as a local hook:

- repo: local
  hooks:
    - id: pygitguard
      name: pygitguard
      entry: pygitguard_cli
      language: system
      types: [python]

📄 License

MIT License


🤝 Contributing

Pull requests and issue reports are welcome!

📬 Contact

LinkedIn

Metadata

Release files for pygitguard 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygitguard 1.0.4
File Size Uploaded
pygitguard-1.0.4.tar.gz 11.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygitguard 1.0.4
File Interpreter ABI Platform
pygitguard-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 24.5 kB

Release files / pygitguard-1.0.4.tar.gz

Download URL pygitguard-1.0.4.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
bc0dadf09a3c24851c8711b3a5b5dbe3878dbecbd467acdff109d48ababbbd74
BLAKE2b-256 checksum
How to use checksums
348f644d29fcac723347f5cdcbec84c0f776f95cf583f7f6db2b4d327180faaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / pygitguard-1.0.4-py3-none-any.whl

Download URL pygitguard-1.0.4-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
37f8925c110d355d121a574ffe9adea6c858a54123aaa159c6feba14473ef99f
BLAKE2b-256 checksum
How to use checksums
d5d48e77875929a8140a969a64db0f605b073c1cf27b79d94fd12973bcf99e35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page