Comprehensive validation tooling for SecuBox module generation and git workflow. New Tools: ----------- 1. validate-module-generation.sh - Deep validation of single module during/after generation - Checks 9 categories: Makefile, RPCD, ACL, Menu, JS Views, UCI, Permissions, Security, Docs - Validates RPCD naming (luci.* prefix) vs JavaScript ubus objects - Validates menu paths vs actual view file locations - Cross-checks RPC methods between JavaScript and RPCD - Security scans for hardcoded credentials and dangerous commands - Exit codes: 0=pass, 1=critical errors 2. pre-push-validation.sh - Git pre-push hook that blocks push if critical errors found - Validates all modules before allowing remote push - Detects modified modules and runs comprehensive checks - Prevents deployment of broken modules - Can be bypassed with --no-verify (not recommended) 3. install-git-hooks.sh - One-command installation of git hooks - Creates symlink from .git/hooks/pre-push to pre-push-validation.sh - Enables automatic validation before every push Documentation: -------------- 4. VALIDATION-GUIDE.md - Complete guide to validation workflow - Critical naming convention rules with examples - Module generation checklist (5 phases) - Common validation errors and fixes - Best practices and troubleshooting - CI/CD integration examples Updated: -------- 5. secubox-tools/README.md - Added descriptions for new validation tools - Added recommended workflows for module generation and modification - Organized tools into categories (Validation, Maintenance) Key Validation Rules Enforced: ------------------------------- ✓ RPCD script name MUST match ubus object name (exact match with luci. prefix) Example: object: 'luci.cdn-cache' → file: luci.cdn-cache ✓ Menu paths MUST match view file locations (prevent HTTP 404) Example: "path": "cdn-cache/overview" → view/cdn-cache/overview.js ✓ All ubus objects MUST use luci.* prefix ✅ 'luci.cdn-cache' ❌ 'cdn-cache' ✓ ACL permissions MUST cover all RPCD methods ✓ JavaScript RPC method calls MUST exist in RPCD implementation ✓ RPCD scripts MUST be executable (chmod +x) ✓ All JSON files MUST have valid syntax ✓ Security: No hardcoded credentials or dangerous commands Benefits: --------- - Prevents RPC errors (-32000: Object not found) - Prevents HTTP 404 errors (view files not found) - Catches naming mismatches before deployment - Ensures ACL permissions are complete - Enforces consistent naming conventions - Blocks broken modules from being pushed - Provides detailed error messages with fix suggestions Usage: ------ # Validate new/modified module: ./secubox-tools/validate-module-generation.sh luci-app-cdn-cache # Install git hooks (one-time): ./secubox-tools/install-git-hooks.sh # After installation, validation runs automatically: git push # Pre-push validation blocks if errors found # Manual pre-push validation: ./secubox-tools/pre-push-validation.sh See VALIDATION-GUIDE.md for complete documentation and workflows. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
36 lines
924 B
Bash
Executable File
36 lines
924 B
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# install-git-hooks.sh
|
|
# ====================
|
|
# Installs SecuBox validation git hooks
|
|
#
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
GIT_HOOKS_DIR="$REPO_ROOT/.git/hooks"
|
|
|
|
echo "Installing SecuBox git hooks..."
|
|
|
|
# Create hooks directory if it doesn't exist
|
|
mkdir -p "$GIT_HOOKS_DIR"
|
|
|
|
# Install pre-push hook
|
|
if [ -f "$SCRIPT_DIR/pre-push-validation.sh" ]; then
|
|
ln -sf ../../secubox-tools/pre-push-validation.sh "$GIT_HOOKS_DIR/pre-push"
|
|
chmod +x "$SCRIPT_DIR/pre-push-validation.sh"
|
|
echo "✓ Installed pre-push hook"
|
|
else
|
|
echo "✗ pre-push-validation.sh not found"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "Git hooks installed successfully!"
|
|
echo ""
|
|
echo "The pre-push hook will run automatically before every 'git push'"
|
|
echo "to validate your modules."
|
|
echo ""
|
|
echo "To bypass validation (NOT RECOMMENDED):"
|
|
echo " git push --no-verify"
|
|
echo ""
|