Skip to content
arissupriyPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

16 Commits

Folders and files

Repository files navigation

FIM Monitor

A Generic File Integrity Monitoring Platform with CMS-specific templates.

OJS Monitor is the first dedicated template. The platform is designed to support multiple CMS/systems (WordPress, Drupal, custom) via template plugins.

License Go Next.js


Platform Concept

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     FIM MONITOR PLATFORM                       β”‚
β”‚              (Generic File Integrity Monitoring)                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Core Engine (Platform-wide)                                   β”‚
β”‚  β”œβ”€β”€ File Scanner (Hash, Permission, Metadata)                 β”‚
β”‚  β”œβ”€β”€ FIM Watcher (fsnotify)                                β”‚
β”‚  β”œβ”€β”€ Background Worker (Job Queue)                             β”‚
β”‚  └── Database (SQLite - Platform Schema)                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Templates/Plugins (CMS-Specific Detection)                   β”‚
β”‚  β”œβ”€β”€ OJS Template       β†’ submission_files, users, journals   β”‚
β”‚  β”œβ”€β”€ WordPress Template β†’ wp_posts, wp_uploads (future)       β”‚
β”‚  └── Custom Template   β†’ (user-defined rules)                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Features

File Integrity Monitoring (FIM)

  • Baseline Scanning: Create initial file baseline with SHA-256 hashes
  • Change Detection: Detect added, modified, and deleted files
  • Permission Tracking: Monitor file mode, UID, GID changes
  • Real-time Monitoring: Using fsnotify for instant detection
  • Whitelist/Blacklist: Exclude specific paths or extensions

CMS-Specific Templates

  • OJS Template: Orphan detection, user metrics, journal statistics
  • Extensible: Add new CMS support via template interface
  • Generic Core: Scanner/watcher work without CMS templates

Async Job Processing

  • Background Worker: Non-blocking scan jobs
  • Progress Tracking: Real-time scan progress updates
  • Scheduled Scans: Daily integrity scans
  • Graceful Shutdown: Clean worker shutdown on signals

Security

  • JWT Authentication: Secure admin login
  • Audit Logging: Track all admin actions
  • Race Condition Protection: Database-level locking

Architecture

Clean Architecture

backend/
β”œβ”€β”€ cmd/                    # Entry points (source code)
β”‚   β”œβ”€β”€ manage/            # CLI tool
β”‚   β”œβ”€β”€ server/             # HTTP API server
β”‚   └── worker/             # Background worker
β”‚
β”œβ”€β”€ bin/                    # Compiled binaries
β”‚   β”œβ”€β”€ manage             # CLI tool
β”‚   β”œβ”€β”€ fim-server        # HTTP API server
β”‚   └── worker            # Background worker
β”‚
β”œβ”€β”€ pkg/                    # Shared packages
β”‚   └── response/          # HTTP response helpers
β”‚
└── internal/              # Application code
    β”œβ”€β”€ domain/            # Business rules (models, interfaces)
    β”œβ”€β”€ application/        # Use cases
    β”œβ”€β”€ infrastructure/     # Technology implementations
    β”‚   β”œβ”€β”€ database/      # SQLite/MySQL
    β”‚   β”œβ”€β”€ http/           # HTTP handlers
    β”‚   β”œβ”€β”€ scanner/        # File scanning
    β”‚   β”œβ”€β”€ watcher/        # FIM watcher
    β”‚   β”œβ”€β”€ worker/         # Background worker
    β”‚   └── templates/      # CMS templates
    └── wire/               # Dependency injection

System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend      │────▢│   Go Backend    │────▢│   SQLite DB     β”‚
β”‚   (Next.js)     β”‚     β”‚   (chi router)  β”‚     β”‚   (metadata)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ OJS Metricsβ”‚ CMS-specificβ”‚
                    β–Ό            β–Ό            β–Ό
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚   OJS    β”‚ β”‚WordPress β”‚ β”‚ Custom   β”‚
             β”‚ Template β”‚ β”‚ Template β”‚ β”‚ Template β”‚
             β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
                  β”‚             β”‚             β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
                      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                      β”‚ CMS MySQL   β”‚
                      β”‚ Databases   β”‚
                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack

Component Technology
Frontend Next.js 16 (Turbopack), React, Tailwind CSS
Backend Go 1.21+, chi router, bcrypt, jwt
Local DB SQLite (WAL mode)
Target DB MySQL 5.7+ (CMS databases)

Prerequisites

  • Go 1.21 or higher
  • Node.js 18 or higher
  • MySQL 5.7+ (for CMS database access)
  • Linux (for real-time monitoring with fsnotify)

Quick Start

1. Clone and Build

git clone https://github.com/your-repo/fim-monitor.git
cd fim-monitor
make build

2. Setup Database

# Run migrations
./bin/manage migrate

# Create admin user
./bin/manage add-admin admin secretpassword

# Or use default admin
./bin/manage seed  # admin / admin123

3. Start Services

# Daemon mode (recommended)
./bin/manage server:start

# Or separate terminals
./bin/fim-server   # Terminal 1: API Server
./bin/worker        # Terminal 2: Background Worker

4. Access


CLI Commands

# Database management
./bin/manage migrate                     # Run migrations
./bin/manage seed                      # Seed default admin
./bin/manage add-admin <username> <password>  # Create admin user
./bin/manage status                    # Show system status

# Server management (daemon mode)
./bin/manage server:start             # Start server + worker
./bin/manage server:stop              # Stop server + worker
./bin/manage server:restart           # Restart all services
./bin/manage server:status           # Show service status

# Manual mode (separate terminals)
./bin/fim-server                      # Start HTTP API server
./bin/worker                         # Start background worker

# Help
./bin/manage help                    # Show all commands

Server Management

The CLI manages server and worker processes using PID files:

Command Description
manage server:start Start server + worker (daemon)
manage server:stop Stop gracefully with SIGTERM
manage server:restart Restart all services
manage server:status Show running processes

PID files: .server.pid, .worker.pid


Project Setup

Create a New Project

  1. Login to the dashboard
  2. Click "Add Project"
  3. Configure:
    • Name: Project identifier
    • Template: OJS (or future templates)
    • App Path: Path to CMS installation
    • Files Path: Path to CMS uploads
    • Database: CMS MySQL connection

Start Baseline Scan

  1. Open the project
  2. Click "Start Scan"
  3. Monitor progress in Jobs tab

Template System

How Templates Work

Templates provide CMS-specific detection:

  • Orphan Detection: Files not in CMS database
  • User Metrics: New users, validated users, etc.
  • CMS Statistics: Journal counts, submission counts

Available Templates

Template Status Features
OJS βœ… Ready Full support
WordPress πŸ”œ Future Pending
Drupal πŸ”œ Future Pending
Custom πŸ”œ Future User-defined

Adding a Template

  1. Create internal/templates/<name>/
  2. Implement Template interface
  3. Register in application

Configuration

Environment Variables

Variable Default Description
PORT 8080 Backend server port
DB_PATH ./database/ SQLite database path

Permissions

For monitoring CMS paths, ensure:

  • Read access to application directories
  • Read access to upload directories
  • MySQL SELECT permissions on CMS database

API Endpoints

Method Endpoint Description
POST /api/login Admin login
GET /api/projects List projects
POST /api/projects Create project
GET /api/projects/:id Get project
PUT /api/projects/:id Update project
POST /api/projects/:id/scan Start baseline scan
GET /api/projects/:id/jobs Get scan jobs
GET /api/projects/:id/files Get files
GET /api/logs Get audit logs

Development

Makefile Targets

make build         # Build all binaries
make clean         # Remove binaries
make test          # Run tests
make test-race     # Run tests with race detector
make status        # Check system status
make migrate       # Run migrations

Project Structure

backend/
β”œβ”€β”€ cmd/                    # Binaries
β”‚   β”œβ”€β”€ manage/main.go     # CLI tool
β”‚   β”œβ”€β”€ server/main.go     # HTTP server
β”‚   └── worker/main.go     # Background worker
β”œβ”€β”€ pkg/                    # Shared
β”œβ”€β”€ internal/               # Application
β”‚   β”œβ”€β”€ domain/            # Business rules
β”‚   β”œβ”€β”€ application/        # Use cases
β”‚   └── infrastructure/    # Implementations
└── wire/                  # DI

Security

  1. Change default password after first login
  2. Use HTTPS in production
  3. Restrict paths - Read-only access to CMS directories
  4. MySQL permissions - Use minimal required permissions

Recommended MySQL Permissions

GRANT SELECT ON cms_database.* TO 'fim_monitor'@'%';
FLUSH PRIVILEGES;

Troubleshooting

"Connection timeout" when testing CMS database

  • Verify MySQL is running and accessible
  • Check firewall settings
  • Ensure MySQL allows remote connections

Scan stuck at "counting" status

  • Check if worker is running
  • Verify paths are correct and accessible
  • Check disk space

Files not detected

  • Ensure paths have correct permissions
  • Check whitelist/blacklist settings
  • Verify symlinks are not being skipped

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

MIT License - see LICENSE for details.


Build Output

Binaries are located in backend/bin/:

backend/bin/manage       # CLI tool
backend/bin/fim-server  # HTTP API server
backend/bin/worker      # Background worker

Build using Makefile:

make build

Or manually:

cd backend
go build -o bin/manage ./cmd/manage
go build -o bin/fim-server ./cmd/server
go build -o bin/worker ./cmd/worker

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages