Skip to main content

A CLI tool to scan Git repositories for sensitive information

Project description


Git Guardian CLI

Git Guardian CLI is a security-focused command-line tool that scans Git repositories for sensitive information like API keys, passwords, and credentials. It helps prevent accidental exposure of secrets before pushing code to remote repositories.


Features

  • Secret Detection: Uses regex patterns to detect sensitive information in files.
  • Git Hook Integration: Automatically blocks commits containing exposed secrets.
  • Cross-Platform: Works on Windows, macOS, and Linux.
  • Custom Rules: Add your own regex patterns for secret detection.
  • Detailed Reports: Provides structured output of scan results.
  • Pre-Commit Hook: Prevents commits with exposed secrets.

Installation

Prerequisites

  • Python 3.7 or higher
  • Git

Install via pip

pip install git-guardian-cli

Install from Source

  1. Clone the repository:
    git clone https://github.com/yourusername/git-guardian-cli.git
    cd git-guardian-cli
    
  2. Install the package:
    pip install .
    

Usage

Scan a Repository

To scan a repository for secrets:

git-guardian scan /path/to/repo

Options

  • --output or -o: Output format (cli or json). Default: cli.
    git-guardian scan /path/to/repo --output json
    

Install Pre-Commit Hook

To install a pre-commit hook that blocks commits with exposed secrets:

git-guardian install-hook

Configuration

Custom Rules

You can add custom regex patterns for secret detection by creating a .gitguardianrc file in your repository:

{
  "custom_rules": [
    {
      "name": "Custom API Key",
      "pattern": "CUSTOM-[A-Z0-9]{20}"
    }
  ]
}

Ignored Directories

By default, the following directories are ignored during scanning:

  • .git
  • node_modules
  • venv

Examples

Scan a Repository

git-guardian scan .

Install Pre-Commit Hook

git-guardian install-hook

Scan with Custom Rules

  1. Create a .gitguardianrc file with your custom rules.
  2. Run the scan:
    git-guardian scan /path/to/repo
    

Development

Setup

  1. Clone the repository:
    git clone https://github.com/000xs/git-guardian-cli.git
    cd git-guardian-cli
    
  2. Install dependencies:
    pip install -r requirements.txt
    

Run Tests

python -m pytest tests/ -v

Build the Package

python setup.py sdist bdist_wheel

Contributing

We welcome contributions! Here’s how you can help:

  1. Report Issues: If you find a bug or have a feature request, open an issue on GitHub.
  2. Submit Pull Requests: Fork the repository, make your changes, and submit a pull request.
  3. Improve Documentation: Help us improve the documentation by submitting updates.

Please read our Contributing Guidelines for more details.


License

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


Why Git Guardian CLI?

  • Prevent Accidental Exposure: Catch sensitive information before it’s committed.
  • Easy to Use: Simple CLI commands with detailed reports.
  • Customizable: Add your own rules for secret detection.
  • Cross-Platform: Works on Windows, macOS, and Linux.

Support

If you have any questions or need help, please open an issue on GitHub.


Acknowledgments

  • Built with ❤️ by 000x.

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

git-guardian-cli-1.0.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

git_guardian_cli-1.0.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file git-guardian-cli-1.0.2.tar.gz.

File metadata

  • Download URL: git-guardian-cli-1.0.2.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for git-guardian-cli-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5798079834b35240eaaad940b8362334ac7edc192ad99091a6caec23f2a9a1af
MD5 82d4b4457169c80887a41af98abc36b4
BLAKE2b-256 b93e0285d1310b47e4eb0684242374e37cba3771e577ad22af6b815bcbcedb9c

See more details on using hashes here.

File details

Details for the file git_guardian_cli-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for git_guardian_cli-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3462cc1bee39b66dae5b128a29fc854860f73ff696fd71488269ea44aa7e1934
MD5 fab94c38a57645ca92724b822d9bada2
BLAKE2b-256 763aef97285edfb88e4e1b58fe683359ab80dee196ed52e4daeb38eae12f21e5

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