Skip to main content

GitShield โ€” The Developer Guardian That Watches Your Code. Real-time secret detection, intelligent pre-commit checks, repo health scoring, and developer behavior intelligence.

Project description

GitShield

๐Ÿ›ก๏ธ GitShield

The Developer Guardian That Watches Your Code โ€” So You Don't Have To

Python License Tests VS Code PyPI


Prevents mistakes BEFORE they happen ยท Guides you DURING actions ยท Fixes issues AFTER mistakes ยท Learns your behavior


๐Ÿš€ Quick Start ยท โœจ Features ยท ๐Ÿ’ป CLI Reference ยท ๐Ÿ–ฅ๏ธ VS Code Extension ยท ๐Ÿ—๏ธ Architecture ยท ๐Ÿงช Testing


๐ŸŽฏ What is GitShield?

GitShield is a production-ready, end-to-end developer protection system that integrates seamlessly with your Git workflow. It combines real-time security scanning, intelligent rules enforcement, smart mentoring, and behavioral analysis into a single tool.

Think of it as a security-first pair programmer that sits between your code and your repository โ€” catching secrets before they leak, enforcing quality standards, and continuously learning how you work to give better advice.

๐Ÿ”‘ Why GitShield?

Problem GitShield Solution
๐Ÿ”“ Accidentally committed API keys 30+ secret detection patterns catch them before commit
๐Ÿ’ฌ Vague commit messages like "fix stuff" Smart Mentor scores messages and suggests improvements
๐Ÿ“ฆ Monster commits with 80+ files Rule Engine warns about oversized commits
๐ŸŒฟ Pushing directly to main Branch protection blocks direct commits to protected branches
๐Ÿ˜ฐ "How do I undo my last commit?" Recovery Engine provides step-by-step guided fixes
๐Ÿ“‰ Repository entropy building up Health Analyzer scores repo quality with actionable insights

โœจ Core Features

๐Ÿ”’ Security Scanner โ€” 30+ Secret Detection Patterns

Detects leaked credentials from AWS, Google Cloud, GitHub, Stripe, Slack, Twilio, SendGrid, Firebase, Discord, Shopify, Heroku, and more. Includes Shannon entropy analysis for catching unknown token formats.

$ gitshield scan

  GitShield v1.0.0
  Developer Guardian & Git Intelligence

๐Ÿ”’ Security Scan Findings
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Severity โ”‚ File        โ”‚ Line โ”‚ Pattern      โ”‚ Description          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ ๐Ÿ”ด CRIT  โ”‚ config.py   โ”‚  12  โ”‚ AWS Key      โ”‚ AWS Access Key ID    โ”‚
โ”‚ ๐ŸŸ  HIGH  โ”‚ .env        โ”‚   3  โ”‚ Generic Key  โ”‚ API key assignment   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  โ›” COMMIT BLOCKED โ€” Fix issues before proceeding.
๐Ÿ“‹ Full List of Detected Secret Types (30+)
Provider Patterns Detected
AWS Access Key ID, Secret Access Key, MWS Token
Google API Key, OAuth Client ID, Service Account Key
GitHub Personal Access Token, OAuth Token, App Token, Fine-Grained PAT
Stripe Secret Key, Publishable Key, Restricted Key
Slack Bot Token, User Token, Webhook URL
Firebase Database URL, Web API Key
Twilio API Key, Auth Token
SendGrid API Key
Discord Bot Token, Webhook
NPM Access Token
Shopify Access Token, Shared Secret
Square Access Token, OAuth Secret
Mailgun API Key
Heroku API Key
Generic API keys, passwords, tokens, JWTs, private keys, DB connection strings

๐Ÿ“‹ Pre-Commit Rule Engine โ€” SAFE โœ… / WARNING โš ๏ธ / BLOCK โŒ

$ gitshield check -m "feat(auth): add JWT validation"

๐Ÿ“‹ Pre-Commit Rules
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  โœ… Protected Branch: Working on branch 'feature/auth' (not protected)
  โœ… Staged File Count: 3 file(s) staged for commit
  โœ… File Size: All staged files are within size limits
  โš ๏ธ Debug Markers: Found 2 TODO/FIXME markers in staged files
  โŒ Conflict Markers: Unresolved merge conflict in utils.py

โœ๏ธ Commit Message Analysis
  Score: ๐ŸŸข 92/100

๐Ÿง  Mentor Suggestions
  ๐ŸŒฟ Branch follows conventions โ€” good job!
  โœ๏ธ Consider adding a body to explain the implementation approach

Rules checked on every commit:

  • โœ… Protected branch detection (main, master, production)
  • โœ… Staged file count limits (configurable, default 50)
  • โœ… File size limits (configurable, default 5MB)
  • โœ… Binary file detection (.exe, .dll, .so, .sqlite)
  • โœ… TODO/FIXME/HACK marker warnings
  • โœ… Merge conflict marker blocking
  • โœ… Conventional commit message format validation
  • โœ… Commit message length enforcement

๐Ÿ“Š Repository Health Score

$ gitshield health

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ ๐Ÿ“Š Repository Health Report  โ”‚
โ”‚                              โ”‚
โ”‚  Grade: B โ€” 74/100           โ”‚
โ”‚  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 74%    โ”‚
โ”‚                              โ”‚
โ”‚  ๐Ÿ“ Structure:     90/100    โ”‚
โ”‚  ๐Ÿ“„ Essentials:    85/100    โ”‚
โ”‚  ๐Ÿ“Š File Quality:  70/100    โ”‚
โ”‚  ๐Ÿ”€ Git Hygiene:   55/100    โ”‚
โ”‚  ๐Ÿ“ฆ Dependencies:  80/100    โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โš ๏ธ Issues Found
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  ๐ŸŸก 5/10 recent commits have poor messages
     ๐Ÿ’ก Write descriptive commit messages using conventional format
  ๐Ÿ”ต No lock file for requirements.txt
     ๐Ÿ’ก Consider generating a lock file for reproducible builds

๐Ÿ”ง Mistake Recovery Assistant

10+ guided recovery plans for common Git mistakes โ€” each with step-by-step instructions, risk levels, and destructive operation warnings.

$ gitshield fix

๐Ÿ”ง Available Recovery Operations
โ”Œโ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ # โ”‚ ID                       โ”‚ Description                            โ”‚ Risk     โ”‚
โ”œโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1 โ”‚ undo_last_commit         โ”‚ Undo the most recent commit            โ”‚ LOW      โ”‚
โ”‚ 2 โ”‚ remove_file_from_history โ”‚ Remove a file from all git history     โ”‚ CRITICAL โ”‚
โ”‚ 3 โ”‚ unstage_all              โ”‚ Remove all files from staging          โ”‚ LOW      โ”‚
โ”‚ 4 โ”‚ recover_deleted_branch   โ”‚ Recover a recently deleted branch      โ”‚ LOW      โ”‚
โ”‚ 5 โ”‚ abort_merge              โ”‚ Abort a failed merge operation         โ”‚ MEDIUM   โ”‚
โ”‚ 6 โ”‚ reset_to_remote          โ”‚ Reset local branch to match remote     โ”‚ HIGH     โ”‚
โ”‚ 7 โ”‚ fix_detached_head        โ”‚ Fix a detached HEAD state              โ”‚ LOW      โ”‚
โ”‚ 8 โ”‚ squash_commits           โ”‚ Squash recent commits together         โ”‚ MEDIUM   โ”‚
โ”‚ 9 โ”‚ cherry_pick_commit       โ”‚ Apply a specific commit to this branch โ”‚ LOW      โ”‚
โ”‚10 โ”‚ clean_untracked          โ”‚ Remove all untracked files             โ”‚ HIGH     โ”‚
โ””โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

$ gitshield fix --plan remove_file_from_history --file .env
  Step 1: Backup Repository โ€” cp -r .git .git-backup
  Step 2: Add to .gitignore โ€” echo ".env" >> .gitignore
  Step 3: Remove from History โ€” git filter-branch ...
  Step 4: Force Push โ€” git push origin --force --all โš ๏ธ (DESTRUCTIVE)
  Step 5: ROTATE SECRETS โ€” Revoke and regenerate any exposed keys

๐Ÿง  Behavior Intelligence & Smart Mentoring

Tracks your development patterns locally using SQLite and provides personalized insights:

$ gitshield learn

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ ๐Ÿง  Behavior Intelligence     โ”‚
โ”‚                              โ”‚
โ”‚  ๐Ÿ“ Total Commits: 127       โ”‚
โ”‚  ๐Ÿ” Total Scans: 89          โ”‚
โ”‚  ๐Ÿ”’ Secrets Found: 3         โ”‚
โ”‚  ๐Ÿ›ก๏ธ Secrets Prevented: 3    โ”‚
โ”‚  ๐Ÿ“ฆ Avg Files/Commit: 4.2    โ”‚
โ”‚  ๐Ÿ”ฅ Current Streak: 12 days  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

๐Ÿ’ก Insights
  โœจ Great Commit Discipline โ€” avg 4 files/commit
  ๐Ÿ”’ Security Awareness โ€” 100% prevention rate
  ๐Ÿ”ฅ Hot Streak! โ€” 12 days of continuous coding

๐Ÿš€ Quick Start

1. Install via pip

pip install gitshield

2. Or install from source

git clone https://github.com/kamrankausher/Git_Shield.git
cd GitShield
pip install -e .

3. Start protecting your repository

cd your-project

# Scan for secrets
gitshield scan

# Run pre-commit checks
gitshield check

# Analyze repo health
gitshield health

# Install automatic git hooks
gitshield init

Windows Installation

cd GitShield
.\scripts\install.ps1

macOS / Linux

cd GitShield
chmod +x scripts/install.sh
./scripts/install.sh

๐Ÿ’ป CLI Reference

Command Description
gitshield Show status dashboard and quick start guide
gitshield scan ๐Ÿ”’ Scan entire repository for secrets
gitshield scan --staged ๐Ÿ”’ Scan only staged files
gitshield scan --strict ๐Ÿ”’ Enable Shannon entropy analysis
gitshield check ๐Ÿ“‹ Run all pre-commit validation rules
gitshield check -m "message" ๐Ÿ“‹ Also validate commit message
gitshield health ๐Ÿ“Š Generate repository health report
gitshield fix ๐Ÿ”ง List all recovery operations
gitshield fix --plan <id> ๐Ÿ”ง Show detailed recovery plan
gitshield fix --execute <id> ๐Ÿ”ง Execute a safe recovery operation
gitshield learn ๐Ÿง  View behavior insights and suggestions
gitshield init ๐Ÿ”— Install pre-commit & pre-push git hooks
gitshield server ๐Ÿ–ฅ๏ธ Start Flask backend for VS Code extension
gitshield status ๐Ÿ“ Show git context and active risks

๐Ÿ–ฅ๏ธ VS Code Extension

GitShield includes a premium VS Code extension with a glassmorphic dashboard sidebar.

Features

Feature Description
Sidebar Dashboard Real-time scan results, health gauges, and suggestions
Status Bar Always-visible protection status indicator
Command Palette Access all features via Ctrl+Shift+P โ†’ "GitShield"
Auto-Start Server Automatically starts the Python backend on activation
Scan on Save Optionally scan for secrets every time you save a file

Installation

Option 1 โ€” From VSIX (local):

cd vscode-extension
npm install
npm run compile
npx vsce package
# Then install the .vsix file via VS Code Extensions panel

Option 2 โ€” Development mode:

  1. Open the vscode-extension/ folder in VS Code
  2. Press F5 to launch the Extension Development Host
  3. The extension will activate in the new window

Setup

  1. Install the Python CLI: pip install gitshield
  2. Install the VS Code extension
  3. Start the backend server: gitshield server (or let auto-start handle it)

๐Ÿ—๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚       VS Code Extension (TS)         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚Sidebar  โ”‚ โ”‚Statusโ”‚ โ”‚ Commands โ”‚  โ”‚
โ”‚  โ”‚Dashboardโ”‚ โ”‚ Bar  โ”‚ โ”‚ Palette  โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”ฌโ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ”‚
โ”‚                  โ”‚                   โ”‚
โ”‚           HTTP REST API              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚       Flask Backend Server           โ”‚
โ”‚    /api/scan  /api/check  /api/healthโ”‚
โ”‚  /api/risks  /api/behavior  /api/fix โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚        Core Engine (Orchestrator)    โ”‚
โ”‚                                      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”‚
โ”‚  โ”‚ Security โ”‚  โ”‚  Rule    โ”‚         โ”‚
โ”‚  โ”‚ Scanner  โ”‚  โ”‚  Engine  โ”‚         โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”‚
โ”‚  โ”‚  Smart   โ”‚  โ”‚ Behavior โ”‚         โ”‚
โ”‚  โ”‚  Mentor  โ”‚  โ”‚ Tracker  โ”‚         โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”‚
โ”‚  โ”‚  Health  โ”‚  โ”‚ Recovery โ”‚         โ”‚
โ”‚  โ”‚ Analyzer โ”‚  โ”‚  Engine  โ”‚         โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”‚
โ”‚  โ”‚   Git    โ”‚  โ”‚ Pattern  โ”‚         โ”‚
โ”‚  โ”‚  Intel   โ”‚  โ”‚    DB    โ”‚         โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Data & Storage Layer         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚ SQLite โ”‚ โ”‚ YAML โ”‚ โ”‚    Git     โ”‚ โ”‚
โ”‚  โ”‚(.devflowโ”‚ โ”‚Configโ”‚ โ”‚ subprocess โ”‚ โ”‚
โ”‚  โ”‚  /db)  โ”‚ โ”‚      โ”‚ โ”‚            โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Technology Stack

Layer Technology Purpose
CLI Python 3.8+ ยท Click ยท Rich Terminal interface with colorized output
Server Flask ยท Flask-CORS REST API backend for VS Code
Core Python standard library Security scanning, rules, mentoring, behavior, recovery
Storage SQLite Local behavior tracking and scan history
Git subprocess Git operations (branch, diff, log, stash)
Config PyYAML User-configurable .devflow.yml files
Extension TypeScript ยท VS Code API Sidebar UI, status bar, file watchers
Testing pytest (46 tests) Unit tests for scanner, rules, health, CLI

๐Ÿ“ Project Structure

GitShield/
โ”œโ”€โ”€ pyproject.toml                  # Package configuration & metadata
โ”œโ”€โ”€ README.md                       # This documentation
โ”œโ”€โ”€ LICENSE                         # MIT License
โ”œโ”€โ”€ requirements.txt                # Python dependencies
โ”œโ”€โ”€ setup.py                        # Legacy setup script
โ”œโ”€โ”€ .gitignore                      # Git ignore rules
โ”‚
โ”œโ”€โ”€ src/devflow/                    # Python package (src-layout)
โ”‚   โ”œโ”€โ”€ __init__.py                 # Package version & metadata
โ”‚   โ”œโ”€โ”€ cli.py                      # Click CLI โ€” 8 commands
โ”‚   โ”œโ”€โ”€ server.py                   # Flask REST API โ€” 12 endpoints
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ core/                       # Core engine modules
โ”‚   โ”‚   โ”œโ”€โ”€ engine.py               # Central orchestrator
โ”‚   โ”‚   โ”œโ”€โ”€ scanner.py              # Security scanner (30+ patterns)
โ”‚   โ”‚   โ”œโ”€โ”€ patterns.py             # Secret regex pattern database
โ”‚   โ”‚   โ”œโ”€โ”€ rules.py                # Rule engine (SAFE/WARN/BLOCK)
โ”‚   โ”‚   โ”œโ”€โ”€ ai_mentor.py            # Smart suggestion engine
โ”‚   โ”‚   โ”œโ”€โ”€ behavior.py             # Developer behavior tracker
โ”‚   โ”‚   โ”œโ”€โ”€ health.py               # Repository health analyzer
โ”‚   โ”‚   โ”œโ”€โ”€ recovery.py             # Mistake recovery assistant
โ”‚   โ”‚   โ””โ”€โ”€ git_intel.py            # Git context intelligence
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ hooks/                      # Git hook integration
โ”‚   โ”‚   โ””โ”€โ”€ installer.py            # Hook installer (Unix + Windows)
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ db/                         # Data persistence
โ”‚   โ”‚   โ””โ”€โ”€ store.py                # SQLite storage layer
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ utils/                      # Shared utilities
โ”‚       โ”œโ”€โ”€ git.py                  # Git operation wrappers
โ”‚       โ”œโ”€โ”€ formatters.py           # Rich terminal formatters
โ”‚       โ””โ”€โ”€ config.py               # YAML config management
โ”‚
โ”œโ”€โ”€ vscode-extension/               # VS Code Extension
โ”‚   โ”œโ”€โ”€ package.json                # Extension manifest
โ”‚   โ”œโ”€โ”€ tsconfig.json               # TypeScript config
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ extension.ts            # Activation & command registration
โ”‚       โ”œโ”€โ”€ sidebarProvider.ts      # Webview dashboard (glassmorphic UI)
โ”‚       โ”œโ”€โ”€ devflowClient.ts        # HTTP client for Flask backend
โ”‚       โ””โ”€โ”€ statusBar.ts            # Status bar indicator
โ”‚
โ”œโ”€โ”€ tests/                          # Test suite (46 tests)
โ”‚   โ”œโ”€โ”€ test_scanner.py             # Scanner & pattern tests
โ”‚   โ”œโ”€โ”€ test_rules.py               # Rule engine tests
โ”‚   โ”œโ”€โ”€ test_health.py              # Health analyzer tests
โ”‚   โ””โ”€โ”€ test_cli.py                 # CLI integration tests
โ”‚
โ””โ”€โ”€ scripts/                        # Installation scripts
    โ”œโ”€โ”€ install.sh                  # Unix installer
    โ””โ”€โ”€ install.ps1                 # Windows PowerShell installer

๐Ÿ”ง Configuration

Create a .devflow.yml in your project root to customize behavior:

# GitShield Configuration
# Place this file in your project root as .devflow.yml

security:
  scan_on_commit: true        # Auto-scan on pre-commit hook
  scan_on_push: true          # Auto-scan on pre-push hook
  block_on_critical: true     # Block commits with CRITICAL findings
  block_on_high: true         # Block commits with HIGH findings
  entropy_analysis: false     # Shannon entropy for unknown patterns
  custom_patterns: []         # Add your own regex patterns

rules:
  max_file_size_mb: 5         # Max file size allowed (MB)
  max_files_per_commit: 50    # Max files per commit
  protected_branches:         # Branches that trigger warnings
    - main
    - master
    - production
  require_conventional_commits: true
  min_commit_message_length: 10
  max_commit_message_length: 200
  block_binary_files: true
  allowed_branch_prefixes:
    - feature/
    - fix/
    - bugfix/
    - hotfix/
    - release/
    - chore/
    - docs/
    - refactor/
    - test/
    - ci/

behavior:
  track_actions: true         # Log actions to SQLite
  track_secrets: true         # Log secret detections
  show_insights: true         # Display personalized insights

mentor:
  enabled: true
  show_on_commit: true
  max_suggestions: 5

server:
  host: 127.0.0.1
  port: 9876
  auto_start: true

๐Ÿงช Testing

# Run all 46 tests
pytest tests/ -v

# Run with coverage
pytest tests/ -v --cov=devflow

# Run specific test modules
pytest tests/test_scanner.py -v    # 17 scanner tests
pytest tests/test_rules.py -v      # 9 rule engine tests
pytest tests/test_health.py -v     # 4 health analyzer tests
pytest tests/test_cli.py -v        # 10 CLI integration tests

Current test status: โœ… 46/46 tests passing


๐Ÿง‘โ€๐Ÿ’ป Development

Setup Development Environment

git clone https://github.com/kamrankausher/Git_Shield.git
cd GitShield

# Create virtual environment
python -m venv venv
source venv/bin/activate        # Linux/macOS
# venv\Scripts\activate         # Windows

# Install in editable mode with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

Build & Publish to PyPI

pip install build twine
python -m build
twine upload dist/*

Build VS Code Extension

cd vscode-extension
npm install
npm run compile
npx vsce package             # Creates .vsix file
npx vsce publish             # Publish to Marketplace (requires token)

๐Ÿ” Privacy & Security

  • 100% Local โ€” All data is stored locally in .devflow/ inside your repository
  • No Cloud โ€” No data is ever sent to external servers
  • No Telemetry โ€” Zero tracking, zero analytics, zero network calls
  • SQLite Storage โ€” Behavior data stored in local SQLite database
  • Git-Ignored โ€” .devflow/ is automatically added to .gitignore

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Write tests for your changes
  4. Ensure all tests pass: pytest tests/ -v
  5. Commit with conventional format: git commit -m "feat(scanner): add new pattern"
  6. Push and open a Pull Request

๐Ÿ“„ License

MIT License โ€” see LICENSE for details.


Built with โค๏ธ for developers who take code quality and security seriously.

๐Ÿ›ก๏ธ GitShield โ€” Your code deserves a guardian.

GitHub Stars

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

gitshield_cli-1.0.0.tar.gz (62.2 kB view details)

Uploaded Source

Built Distribution

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

gitshield_cli-1.0.0-py3-none-any.whl (56.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gitshield_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2fa0e228dc424167ee3b09a1473411b0a5ed26bd086b569ba1a7f5aa967fb860
MD5 ad432b39083c62075678354f6f207c08
BLAKE2b-256 889807f226c75d5cc24438903435c83045b74103141821fd2f5d617a8b032867

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gitshield_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 56.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for gitshield_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94e0de9995840e81df07257dde58c8aa878d93a7e2dacf1f86bd05d7fabed910
MD5 232045225ab78b86a1f74be39ab62002
BLAKE2b-256 206250bde4b9295fd924991293383a011163b0212c24fc986a34b472658a53bf

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