Skip to content

Commit aedbb22

Browse files
committed
🚀 Initial release: Universal Backup System Template v1.0.0
✨ Features: - Framework-agnostic backup & checkpoint system - Cross-platform PowerShell compatibility (Windows, Linux, macOS) - AI safety protocol integration - Comprehensive security validation & pre-commit hooks - Performance monitoring & error tracking - Notification system (Slack, Discord, Email, Teams) - GitHub template repository support - CI/CD workflows for validation & releases 🎯 Supported Frameworks: - Frontend: React, Vue, Angular, SvelteKit, Next.js - Backend: Node.js, Python, Ruby, PHP - Mobile: React Native, Flutter - Desktop: Electron, Tauri - Static: Jekyll, Hugo, Gatsby 🛡️ Security Features: - Secret scanning & validation - Pre-commit security hooks - Dependency vulnerability scanning - File permission checks 📊 Monitoring & Analytics: - Build time tracking - Disk usage analysis - Git metrics & health checks - Structured error logging 🔔 Notifications: - Multi-platform webhook support - Alert thresholds & escalation - Team collaboration features Ready for production use as GitHub template repository!
0 parents  commit aedbb22

24 files changed

+4881
-0
lines changed

.env.templates

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
# Environment Configuration Templates
2+
# Copy these to your project root and customize for your environment
3+
4+
# ====================
5+
# .env.example
6+
# ====================
7+
8+
# Project Information
9+
PROJECT_NAME=my-awesome-project
10+
PROJECT_VERSION=1.0.0
11+
ENVIRONMENT=development
12+
13+
# Database Configuration
14+
DATABASE_URL=postgresql://user:password@localhost:5432/mydb
15+
DB_HOST=localhost
16+
DB_PORT=5432
17+
DB_NAME=mydb
18+
DB_USER=user
19+
DB_PASS=password
20+
21+
# API Configuration
22+
API_BASE_URL=http://localhost:3000
23+
API_VERSION=v1
24+
API_TIMEOUT=30000
25+
26+
# Authentication
27+
JWT_SECRET=your-super-secret-jwt-key-here
28+
SESSION_SECRET=your-session-secret-here
29+
COOKIE_SECRET=your-cookie-secret-here
30+
31+
# Third-Party Services
32+
STRIPE_PUBLIC_KEY=pk_test_your_stripe_public_key
33+
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key
34+
SENDGRID_API_KEY=SG.your_sendgrid_api_key
35+
AWS_ACCESS_KEY_ID=your_aws_access_key
36+
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
37+
AWS_REGION=us-east-1
38+
AWS_S3_BUCKET=your-s3-bucket
39+
40+
# External APIs
41+
GOOGLE_ANALYTICS_ID=UA-123456789-1
42+
SENTRY_DSN=https://[email protected]/project-id
43+
44+
# Development Tools
45+
DEBUG=true
46+
LOG_LEVEL=debug
47+
HOT_RELOAD=true
48+
49+
# Backup System Configuration
50+
BACKUP_ENABLED=true
51+
BACKUP_RETENTION_DAYS=30
52+
BACKUP_REMOTE_PUSH=true
53+
AI_SAFETY_ENABLED=true
54+
HEALTH_CHECK_INTERVAL=3600
55+
56+
# Notification Configuration
57+
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK
58+
EMAIL_ALERTS_ENABLED=false
59+
ALERT_THRESHOLD_ERRORS=10
60+
61+
# Security
62+
CORS_ORIGIN=http://localhost:3000
63+
RATE_LIMIT_WINDOW=900000
64+
RATE_LIMIT_MAX=100
65+
HELMET_ENABLED=true
66+
67+
# Performance
68+
CACHE_TTL=3600
69+
MAX_REQUEST_SIZE=10mb
70+
COMPRESSION_ENABLED=true
71+
72+
# ====================
73+
# .env.production.example
74+
# ====================
75+
76+
# Project Information
77+
PROJECT_NAME=my-awesome-project
78+
PROJECT_VERSION=1.0.0
79+
ENVIRONMENT=production
80+
81+
# Database Configuration (Production)
82+
DATABASE_URL=postgresql://prod_user:[email protected]:5432/prod_db
83+
DB_POOL_SIZE=20
84+
DB_SSL_MODE=require
85+
86+
# API Configuration (Production)
87+
API_BASE_URL=https://api.yourapp.com
88+
API_VERSION=v1
89+
API_TIMEOUT=10000
90+
91+
# Authentication (Production)
92+
JWT_SECRET=super-secure-production-jwt-secret-change-me
93+
JWT_EXPIRES_IN=24h
94+
SESSION_SECRET=super-secure-session-secret-change-me
95+
COOKIE_SECURE=true
96+
COOKIE_SAME_SITE=strict
97+
98+
# Third-Party Services (Production)
99+
STRIPE_PUBLIC_KEY=pk_live_your_stripe_live_public_key
100+
STRIPE_SECRET_KEY=sk_live_your_stripe_live_secret_key
101+
SENDGRID_API_KEY=SG.your_production_sendgrid_api_key
102+
AWS_ACCESS_KEY_ID=your_production_aws_access_key
103+
AWS_SECRET_ACCESS_KEY=your_production_aws_secret_key
104+
AWS_REGION=us-east-1
105+
AWS_S3_BUCKET=your-production-s3-bucket
106+
107+
# External APIs (Production)
108+
GOOGLE_ANALYTICS_ID=UA-123456789-1
109+
SENTRY_DSN=https://[email protected]/project-id
110+
SENTRY_ENVIRONMENT=production
111+
112+
# Production Settings
113+
DEBUG=false
114+
LOG_LEVEL=warn
115+
NODE_ENV=production
116+
HOT_RELOAD=false
117+
118+
# Backup System Configuration (Production)
119+
BACKUP_ENABLED=true
120+
BACKUP_RETENTION_DAYS=90
121+
BACKUP_REMOTE_PUSH=true
122+
BACKUP_ENCRYPTION_KEY=your-backup-encryption-key
123+
AI_SAFETY_ENABLED=true
124+
HEALTH_CHECK_INTERVAL=1800
125+
126+
# Notification Configuration (Production)
127+
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/PRODUCTION/WEBHOOK
128+
EMAIL_ALERTS_ENABLED=true
129+
ALERT_THRESHOLD_ERRORS=5
130+
CRITICAL_ALERT_PHONE=+1234567890
131+
132+
# Security (Production)
133+
CORS_ORIGIN=https://yourapp.com,https://www.yourapp.com
134+
RATE_LIMIT_WINDOW=300000
135+
RATE_LIMIT_MAX=50
136+
HELMET_ENABLED=true
137+
FORCE_HTTPS=true
138+
SECURITY_HEADERS=true
139+
140+
# Performance (Production)
141+
CACHE_TTL=7200
142+
MAX_REQUEST_SIZE=5mb
143+
COMPRESSION_ENABLED=true
144+
GZIP_LEVEL=6
145+
146+
# Monitoring
147+
HEALTH_CHECK_ENDPOINT=/health
148+
METRICS_ENABLED=true
149+
UPTIME_MONITORING=true
150+
151+
# ====================
152+
# .env.test.example
153+
# ====================
154+
155+
# Project Information
156+
PROJECT_NAME=my-awesome-project-test
157+
PROJECT_VERSION=1.0.0
158+
ENVIRONMENT=test
159+
160+
# Database Configuration (Test)
161+
DATABASE_URL=postgresql://test_user:test_password@localhost:5432/test_db
162+
DB_LOGGING=false
163+
164+
# API Configuration (Test)
165+
API_BASE_URL=http://localhost:3001
166+
API_VERSION=v1
167+
API_TIMEOUT=5000
168+
169+
# Authentication (Test)
170+
JWT_SECRET=test-jwt-secret-not-for-production
171+
JWT_EXPIRES_IN=1h
172+
SESSION_SECRET=test-session-secret
173+
174+
# Test Settings
175+
DEBUG=false
176+
LOG_LEVEL=error
177+
NODE_ENV=test
178+
SILENT_TESTS=true
179+
180+
# Backup System Configuration (Test)
181+
BACKUP_ENABLED=false
182+
BACKUP_RETENTION_DAYS=7
183+
BACKUP_REMOTE_PUSH=false
184+
AI_SAFETY_ENABLED=true
185+
HEALTH_CHECK_INTERVAL=60
186+
187+
# Notification Configuration (Test)
188+
SLACK_WEBHOOK_URL=
189+
EMAIL_ALERTS_ENABLED=false
190+
ALERT_THRESHOLD_ERRORS=100
191+
192+
# Security (Test)
193+
CORS_ORIGIN=*
194+
RATE_LIMIT_WINDOW=60000
195+
RATE_LIMIT_MAX=1000
196+
HELMET_ENABLED=false
197+
198+
# Performance (Test)
199+
CACHE_TTL=60
200+
MAX_REQUEST_SIZE=1mb
201+
COMPRESSION_ENABLED=false

.githooks/pre-commit

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
# Pre-commit hook for Universal Backup System
2+
# Runs security checks and validations before commits
3+
4+
# Enable strict mode
5+
Set-StrictMode -Version Latest
6+
$ErrorActionPreference = "Stop"
7+
8+
Write-Host "🔍 Running pre-commit security checks..." -ForegroundColor Cyan
9+
10+
# Function to check for sensitive files
11+
function Test-SensitiveFiles {
12+
$sensitivePatterns = @(
13+
"\.key$", "\.pem$", "\.p12$", "\.pfx$",
14+
"\.env$", "secrets\.", "credentials",
15+
"id_rsa", "\.crt$", "\.cer$"
16+
)
17+
18+
$stagedFiles = git diff --cached --name-only
19+
$sensitiveFIlesFound = @()
20+
21+
foreach ($file in $stagedFiles) {
22+
foreach ($pattern in $sensitivePatterns) {
23+
if ($file -match $pattern) {
24+
$sensitiveFIlesFound += $file
25+
}
26+
}
27+
}
28+
29+
if ($sensitiveFIlesFound.Count -gt 0) {
30+
Write-Host "🚨 SECURITY ALERT: Sensitive files detected in commit:" -ForegroundColor Red
31+
foreach ($file in $sensitiveFIlesFound) {
32+
Write-Host " - $file" -ForegroundColor Red
33+
}
34+
Write-Host "Please review and remove sensitive files before committing." -ForegroundColor Red
35+
return $false
36+
}
37+
38+
return $true
39+
}
40+
41+
# Function to check for hardcoded secrets
42+
function Test-HardcodedSecrets {
43+
$secretPatterns = @(
44+
"password\s*=\s*['\"].*['\"]",
45+
"api_key\s*=\s*['\"].*['\"]",
46+
"secret\s*=\s*['\"].*['\"]",
47+
"token\s*=\s*['\"].*['\"]",
48+
"AKIA[0-9A-Z]{16}", # AWS Access Key
49+
"ghp_[a-zA-Z0-9]{36}", # GitHub Token
50+
"xoxb-[0-9]{11}-[0-9]{12}-[a-zA-Z0-9]{24}" # Slack Token
51+
)
52+
53+
$stagedFiles = git diff --cached --name-only | Where-Object { $_ -match "\.(js|ts|py|rb|php|json|yaml|yml|env)$" }
54+
$secretsFound = @()
55+
56+
foreach ($file in $stagedFiles) {
57+
if (Test-Path $file) {
58+
$content = Get-Content $file -Raw
59+
foreach ($pattern in $secretPatterns) {
60+
if ($content -match $pattern) {
61+
$secretsFound += @{ File = $file; Pattern = $pattern }
62+
}
63+
}
64+
}
65+
}
66+
67+
if ($secretsFound.Count -gt 0) {
68+
Write-Host "🚨 SECURITY ALERT: Potential hardcoded secrets detected:" -ForegroundColor Red
69+
foreach ($secret in $secretsFound) {
70+
Write-Host " - File: $($secret.File)" -ForegroundColor Red
71+
Write-Host " Pattern: $($secret.Pattern)" -ForegroundColor Gray
72+
}
73+
Write-Host "Please remove hardcoded secrets and use environment variables instead." -ForegroundColor Red
74+
return $false
75+
}
76+
77+
return $true
78+
}
79+
80+
# Function to validate commit message
81+
function Test-CommitMessage {
82+
# Get the commit message file path
83+
$commitMsgFile = ".git/COMMIT_EDITMSG"
84+
85+
if (-not (Test-Path $commitMsgFile)) {
86+
return $true # No commit message file, skip validation
87+
}
88+
89+
$commitMsg = Get-Content $commitMsgFile -Raw
90+
91+
# Check for minimum length
92+
if ($commitMsg.Length -lt 10) {
93+
Write-Host "⚠️ WARNING: Commit message is very short. Consider adding more detail." -ForegroundColor Yellow
94+
}
95+
96+
# Check for security-related keywords that might indicate dangerous operations
97+
$dangerousKeywords = @("delete all", "remove everything", "drop database", "format", "destroy")
98+
foreach ($keyword in $dangerousKeywords) {
99+
if ($commitMsg -match $keyword) {
100+
Write-Host "🚨 WARNING: Potentially dangerous operation mentioned in commit message: '$keyword'" -ForegroundColor Yellow
101+
Write-Host "Please confirm this is intentional." -ForegroundColor Yellow
102+
}
103+
}
104+
105+
return $true
106+
}
107+
108+
# Function to run linting if available
109+
function Invoke-LintingCheck {
110+
Write-Host "📋 Running linting checks..." -ForegroundColor Cyan
111+
112+
# ESLint for JavaScript/TypeScript
113+
if (Test-Path "package.json") {
114+
$packageJson = Get-Content "package.json" | ConvertFrom-Json
115+
if ($packageJson.scripts.lint) {
116+
try {
117+
npm run lint 2>$null
118+
if ($LASTEXITCODE -eq 0) {
119+
Write-Host "✅ ESLint passed" -ForegroundColor Green
120+
} else {
121+
Write-Host "❌ ESLint failed - please fix linting errors" -ForegroundColor Red
122+
return $false
123+
}
124+
}
125+
catch {
126+
Write-Host "⚠️ Could not run ESLint" -ForegroundColor Yellow
127+
}
128+
}
129+
}
130+
131+
# Python linting
132+
if (Test-Path "requirements.txt" -or Test-Path "pyproject.toml") {
133+
try {
134+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics 2>$null
135+
if ($LASTEXITCODE -eq 0) {
136+
Write-Host "✅ Python linting passed" -ForegroundColor Green
137+
} else {
138+
Write-Host "⚠️ Python linting issues detected" -ForegroundColor Yellow
139+
}
140+
}
141+
catch {
142+
Write-Host "ℹ️ Python linting not available" -ForegroundColor Gray
143+
}
144+
}
145+
146+
return $true
147+
}
148+
149+
# Run all pre-commit checks
150+
$allChecksPassed = $true
151+
152+
# 1. Check for sensitive files
153+
if (-not (Test-SensitiveFiles)) {
154+
$allChecksPassed = $false
155+
}
156+
157+
# 2. Check for hardcoded secrets
158+
if (-not (Test-HardcodedSecrets)) {
159+
$allChecksPassed = $false
160+
}
161+
162+
# 3. Validate commit message
163+
Test-CommitMessage | Out-Null
164+
165+
# 4. Run linting checks
166+
if (-not (Invoke-LintingCheck)) {
167+
# Don't fail the commit for linting issues, just warn
168+
Write-Host "⚠️ Linting issues detected but allowing commit to proceed" -ForegroundColor Yellow
169+
}
170+
171+
# 5. Run backup system security validation
172+
$securityScript = Join-Path $PSScriptRoot "..\scripts\security-validation.ps1"
173+
if (Test-Path $securityScript) {
174+
try {
175+
& $securityScript
176+
if ($LASTEXITCODE -ne 0) {
177+
Write-Host "❌ Security validation failed" -ForegroundColor Red
178+
$allChecksPassed = $false
179+
}
180+
}
181+
catch {
182+
Write-Host "⚠️ Could not run security validation" -ForegroundColor Yellow
183+
}
184+
}
185+
186+
# Final result
187+
if ($allChecksPassed) {
188+
Write-Host "✅ All pre-commit checks passed!" -ForegroundColor Green
189+
exit 0
190+
} else {
191+
Write-Host "❌ Pre-commit checks failed. Please fix the issues above." -ForegroundColor Red
192+
Write-Host "To skip these checks (not recommended), use: git commit --no-verify" -ForegroundColor Gray
193+
exit 1
194+
}

0 commit comments

Comments
 (0)