Commit Verification Setup for Altus 4
This document outlines the comprehensive commit verification system implemented in Altus 4 to ensure code quality, security, and proper Git hygiene.
GPG Commit Signing
Setup GPG Signing
bash
# Interactive GPG key setup
npm run commit:setup-signing
# Configure Git to use the generated key
npm run commit:configure-signing
Manual GPG Setup
If you prefer manual setup:
Generate GPG Key (choose option 9 - ECC sign and encrypt)
bashgpg --full-generate-key
Configure Git
bash# Get your key ID gpg --list-secret-keys --keyid-format LONG # Configure Git git config --global user.signingkey YOUR_KEY_ID git config --global commit.gpgsign true git config --global tag.gpgsign true
Add to GitHub
bash# Export public key gpg --armor --export YOUR_KEY_ID # Copy output and add to GitHub Settings → SSH and GPG keys
Why ECC (Option 9)?
- Modern & Future-Proof: Industry standard with better performance
- Smaller Keys: 256-bit ECC ≈ 3072-bit RSA security
- GitHub Support: Fully supported with efficient handling
- NSA Suite B: Approved security standard
🪝 Git Hooks
Pre-Commit Hook
Runs comprehensive checks before allowing commits:
- Security Audit:
npm audit --audit-level=high
- Lint & Format:
lint-staged
with ESLint and Prettier - Type Checking: TypeScript compilation check
- Build Verification: Ensures project compiles
- Test Suite: Full test suite execution
- Package Integrity: Dependency consistency check
- Documentation: Markdown linting
- GPG Configuration: Verify signing setup
Commit Message Hook
Validates commit messages for:
- Conventional Commits format validation
- GPG Signing status check
- Sensitive Information detection
- Format Examples and helpful error messages
Post-Commit Hook
Verifies commit integrity:
- GPG Signature verification
- Commit Format validation
- Branch Protection warnings
- Commit Summary display
Pre-Push Hook
Prevents pushing problematic commits:
- GPG Signature verification for all commits being pushed
- Security Audit final check
- Interactive Prompts for unsigned commits or security issues
- Protected Branch detection (main/master)
Available Commands
Verification Commands
bash
# Test all Git hooks
npm run hooks:test
# Verify recent commits (default: last 10)
npm run commit:verify
# Verify specific number of commits
./bin/verify-commits.sh 20
# Security audit
npm run security:audit
# Fix security issues
npm run security:fix
GPG Commands
bash
# Set up GPG signing (interactive)
npm run commit:setup-signing
# Configure Git for GPG signing
npm run commit:configure-signing
# Manual script execution
./bin/setup-gpg.sh
./bin/setup-gpg.sh configure
Commit Message Format
We use Conventional Commits for consistency:
text
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
Valid Types
feat
: New featuresfix
: Bug fixesdocs
: Documentation changesstyle
: Code style changes (formatting, etc.)refactor
: Code refactoringperf
: Performance improvementstest
: Adding or updating testsbuild
: Build system changesci
: CI/CD changeschore
: Other changes
Examples
bash
feat: add API key authentication system
fix(api): resolve database connection timeout
docs: update README with new authentication flow
test: add unit tests for ApiKeyService
Verification Process
Before Each Commit
- Automated Checks: Pre-commit hook runs all quality checks
- Message Validation: Commit message format verification
- GPG Signing: Automatic signing if configured
- Post-Verification: Immediate verification of commit integrity
Before Each Push
- Commit Analysis: All commits in push are analyzed
- GPG Verification: Ensures all commits are signed
- Security Check: Final security audit
- Interactive Prompts: User confirmation for any issues
Manual Verification
bash
# Check recent commit history
npm run commit:verify
# Test hook configuration
npm run hooks:test
# Verify specific commit
git verify-commit <commit-hash>
🚨 Troubleshooting
GPG Issues
bash
# Restart GPG agent
gpgconf --kill gpg-agent
gpgconf --launch gpg-agent
# Check GPG keys
gpg --list-secret-keys
# Test GPG signing
git commit --allow-empty -m "test: verify GPG signing"
Hook Issues
bash
# Reinstall hooks
npm install
# Make hooks executable
chmod +x .husky/*
# Test individual hooks
./.husky/pre-commit
./.husky/commit-msg
Performance Issues
If hooks are too slow:
- Skip Hooks (emergency only):
git commit --no-verify
- Optimize Tests: Use
--bail
for faster failure - Cache Dependencies: Ensure node_modules is cached
Best Practices
For Developers
- Set up GPG signing immediately after cloning
- Use conventional commits for all commits
- Run verification before important pushes
- Keep commits small for faster hook execution
- Fix issues promptly rather than skipping verification
For Maintainers
- Enforce branch protection on main/master
- Require signed commits for sensitive operations
- Regular security audits using provided commands
- Monitor hook performance and optimize as needed
- Update verification tools regularly
Security Features
- GPG Commit Signing: Cryptographic verification of commit authorship
- Security Auditing: Automatic vulnerability detection
- Sensitive Data Detection: Prevents secrets in commit messages
- Interactive Prompts: User confirmation for security issues
- Branch Protection: Warnings for direct commits to protected branches
Metrics and Reporting
The verification system provides detailed reporting:
- Commit Analysis: Percentage of signed commits
- Format Compliance: Conventional commit adherence
- Security Status: Vulnerability counts and severity
- Performance Metrics: Hook execution times
- Compliance Reports: Detailed verification summaries
This comprehensive verification system ensures that all code committed to Altus 4 meets our high standards for quality, security, and maintainability.