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-0.0.1.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-0.0.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: git-guardian-cli-0.0.1.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-0.0.1.tar.gz
Algorithm Hash digest
SHA256 dbc469e090682b6629274b0c662eae4327f8c7d95d3d7fca5153753f88d62201
MD5 26fd110ba027ab2417f42c21f27b2938
BLAKE2b-256 141d84c2e4bcdbfe968f5554ae13bff131ebb24b72ad6acabdd38d8438fe9f63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for git_guardian_cli-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6215f744110ab7e01e2a92a9585f4e829486b0f36a84f65df20d876085149eab
MD5 cc4d4ff82c841eb95911661e5329a2b8
BLAKE2b-256 376051f44a50f6f44034f277593db0ee5db1a981dc58470212704adb66b520e0

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