Skip to content

000xs/git-guardian-cli

Repository files navigation


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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages