How adityapatadiya/file-integrity-monitor-fim works
Main Components
• CLI Frontend: Represented by CLI.py that handles user input and dispatches CLI commands.
• Monitoring Engine (FIM Module): Found in src/FIM/FIM.py and src/FIM/fim_utils.py; this is the core where file integrity checks occur.
• Authentication Module: Located in src/Authentication/Authentication.py, responsible for user sign-in and sign-up functionality.
• Utilities: A collection of helper scripts in src/utils:
• database.py – handles baseline data storage (likely interfacing with the JSON file in data/baselines/baseline.json).
• backup.py – handles directory backup operations.
• log_parser.py – processes log files from the logs folder.
• anomaly_detection.py – performs anomaly detection using machine learning (using data/models/anomaly_model.pkl and vectorizer.pkl).
• Data Storage Components:
• Baseline Data: Maintained in data/baselines.
• Model Files: Stored in data/models.
• Logs: A dedicated logs folder holds detailed logs.
• Configuration: The config directory contains logging_config.py which configures how logs are generated.
Relationships and Interactions
• The CLI frontend triggers various operations (monitoring, viewing/resetting baselines, log analysis, etc.) via command-line arguments. Each argument maps to specific modules.
• The FIM module works in close association with the utilities. For example, when monitoring is triggered, it will:
• Authenticate the user (via the Authentication module).
• Take backups (using backup.py) before starting the monitoring process.
• Use database.py to read/write baseline data.
• Log the file changes; those logs are then later parsed/analyzed by log_parser.py and anomaly_detection.py.
• The configuration file in config/logging_config.py sets up how the logging is handled across the application.
• External dependencies are illustrated with the use of machine learning models (anomaly_model.pkl and vectorizer.pkl) that are loaded during log analysis.
Architectural Patterns and Principles
• Modular Design: The project cleanly separates authentication, monitoring (FIM engine), logging, and utility functions into distinct modules.
• CLI-Driven Workflow: The control flow is command-driven; the CLI acts as the orchestrator between user commands and backend processes.
• Data-Driven Operation: The baseline data and logs reside in isolated directories to maintain persistence, while models support anomaly detection.
• Separation of Concerns: Different functionalities (authentication, backup, analysis) are placed in separate folders/files, ensuring maintainability.
Relevant Technologies and Frameworks
• Python is the underlying programming language.
• JSON is utilized for maintaining baseline data.
• Machine learning model files indicate a use of libraries (likely scikit-learn or similar) for anomaly detection.
• Logging is configured via a dedicated logging configuration, suggesting either the native Python logging module or a configured external service.
• That labels are clear and descriptive, including major actions like “Backup Initiation” and “Log Analysis.”