FileScan is a robust Spring Boot backend service designed to enhance application security by scanning all uploaded files for viruses and malware before they are stored or processed by your system. It leverages the power of ClamAV, the industry-standard open-source antivirus engine, for highly effective file inspection.
- Upload & Scan: Provides a secure REST API endpoint to accept file uploads and initiate the scanning process.
- Asynchronous Scanning: Integrates with ClamAV to perform non-blocking, asynchronous file scans.
- Quarantine: Automatically blocks or quarantines infected files to prevent system contamination.
- Configurable: Easily configure the connection details for both PostgreSQL and the ClamAV daemon.
- Auditing: Logs all scan results to the database for security tracking and auditing purposes.
| Technology | Role |
|---|---|
| Java 17+ | Core programming language |
| Spring Boot 3.x | Backend framework |
| ClamAV | Antivirus and malware scanning engine |
| Spring Data JPA (Hibernate) | ORM for database interaction |
| PostgreSQL | Primary database for storing logs and metadata |
| Maven | Dependency management and build tool |
The service acts as a security gateway for file uploads:
- A user uploads a file via the dedicated REST API endpoint.
- The FileScan service connects to the ClamAV daemon over TCP (default port:
3310). - The file stream is passed to ClamAV and is scanned asynchronously.
- If the file is clean (
CLEAN): It is stored in the configured location (database or file system, depending on implementation detail). - If the file is infected (
FOUND): The file is immediately blocked and a record of the infection is logged.
Before you run the service, you must have the following running and accessible:
- Java 17+
- PostgreSQL database server
- ClamAV Daemon (
clamd)
It is crucial that the ClamAV daemon is running and accessible to the Spring Boot service.
# Update and install ClamAV and the daemon
sudo apt update
sudo apt install clamav clamav-daemon -y
# Stop the updater service
sudo systemctl stop clamav-freshclam
# Manually update the virus database (can take a few minutes)
sudo freshclam
# Start the ClamAV daemon
sudo systemctl start clamav-daemon
# Check the status
sudo systemctl status clamav-daemon