This is a secure git hooks installer that automates commit logging and documentation while maintaining comprehensive security guarantees. It implements User Story-driven requirements and requires manual review via pull requests.
The secure git hooks installer provides automated commit logging with safety-first approach:
- Security-first: Comprehensive validation and secure subprocess operations
- PR-only workflow: Never auto-merges, always requires manual review
- File tracking: Only commits installer-created files, never user secrets
- Repository validation: Pre-flight checks ensure repository is ready
- User Story driven: Implements business requirements (US-001 through US-005)
- ✅ Never commits user files or secrets
- ✅ Always requires PR review (no auto-merge)
- ✅ Validates repository state before operations
- ✅ Tracks only installer-created files
- ✅ Fails safely with clear error messages
-
Main Installer (
git-hooks-installer.py)- Security-first implementation with comprehensive safety checks
- Creates timestamped feature branches:
feat/safe-githooks-installation-<timestamp> - Implements User Story-driven requirements (US-001 through US-005)
-
Security Package (
security/)secure_git_wrapper.py: Secure subprocess wrapper with command whitelistingfile_tracker.py: Tracks installer-created files for safe commitsrepository_validator.py: Pre-flight safety validations__init__.py: Clean package imports
-
Utilities Package (
utils/)commit_file.py: Commit processing utilitiesdebug_commit_log.py: Debug and logging helpersmanage_gitignore.py: Gitignore management utilities
-
Archived Components (
archived/)- Legacy installer versions for reference
- Do not use: These are kept for historical reference only
# Install git hooks with security validation and PR workflow
python git-hooks-installer.py /path/to/target/repo
# Or with source directory specified
python git-hooks-installer.py --source /path/to/source /path/to/target/repo# Manual setup for developers (no PR required)
python developer-setup/setup_githooks.pyThe installer follows Python packaging standards:
# Package-level imports (recommended)
from security import SecureGitWrapper, SafeFileTracker, RepositoryValidator
# Individual module imports
from security.secure_git_wrapper import SecureGitWrapper, SecureGitError
from security.file_tracker import SafeFileTracker
from security.repository_validator import RepositoryValidator# Run comprehensive security tests across multiple OS
./run_docker-tests.sh
# Run User Story validation tests
docker-compose -f tests/docker/docker-compose.user-story-tests.yml up --build --abort-on-container-exitThe installer validates against 5 key User Stories:
- US-001: Safe installation for developers with secrets
- US-002: Team lead code quality control via PR workflow
- US-003: Developer work-in-progress protection
- US-004: Cross-platform developer setup
- US-005: Repository administrator branch protection
- Command whitelisting: Only approved Git commands allowed
- Argument validation: Each command has whitelisted allowed arguments
- Path sanitization: Prevents path traversal attacks
- Branch name validation: Prevents injection via malicious branch names
- Timeout protection: 30-second timeout prevents hanging operations
- Explicit tracking: Only installer-created files are committed
- Staging validation: Ensures only tracked files are staged
- Manifest generation: Complete audit trail for all operations
- Safety checks: Pre-commit validation of file contents
- Working tree checks: Ensures clean repository state
- Branch validation: Prevents conflicts with existing branches
- Remote validation: Checks for proper remote configuration
- Pre-flight safety: Comprehensive validation before any operations
- Pre-flight Checks: Validates repository state and requirements
- Feature Branch: Creates timestamped branch for installation
- Safe Installation: Installs components with comprehensive tracking
- Commit & Push: Commits only tracked files with detailed messages
- PR Generation: Provides instructions for manual review process
- Automatically detects GitHub Actions / GitLab CI
- Installs appropriate workflow files
- Maintains compatibility across platforms
- Linux/macOS: Shell wrapper scripts (
setup-githooks.sh) - Windows: PowerShell scripts (
setup-githooks.ps1) - Docker: Multi-OS testing (Ubuntu, AlmaLinux 9/10)
- Security Implementation: See
SECURITY-ENHANCEMENTS.mdfor complete security details - Framework Guide:
docs/SECURITY-IMPLEMENTATION-FRAMEWORK.mdfor reusable patterns - Project Memory:
../CLAUDE.mdfor development context
- Follow Conventional Commits standard for all commits
- Use the safe installer for any hook-related changes
- All changes require PR review (no direct commits to main)
- Run tests before submitting:
./run_docker-tests.sh
<type>(scope): <description>
Examples:
feat(security): add path validation to SecureGitWrapper
fix(installer): resolve branch creation issue
docs(readme): update installation instructions
- Johan Sörell
- GitHub: J-SirL
- LinkedIn: Johan Sörell
This secure git hooks installer is part of the development-toolbox ecosystem.