File Scanner 1.0.0
A high-performance C++ malicious file scanner.
|
The concrete, internal implementation of the IScanner interface. More...
#include <scanner.h>
Public Member Functions | |
Scanner (IHashDatabase &db, ILogger &logger, IFileHasher &hasher, std::size_t num_threads) | |
Constructs a Scanner instance with its dependencies. | |
ScanResult | Scan (const std::filesystem::path &scan_path) override |
Scans the specified directory. | |
![]() | |
virtual | ~IScanner ()=default |
Private Member Functions | |
void | ProducerTask (const std::filesystem::path &scan_path, ThreadPool &pool, std::promise< void > &producer_promise) |
The task executed by the producer thread. | |
void | ConsumerTask (const std::filesystem::path &path) |
The task executed by consumer threads in the pool. | |
Private Attributes | |
IHashDatabase & | db_ |
ILogger & | logger_ |
IFileHasher & | hasher_ |
std::size_t | num_threads_ |
std::atomic< std::uint64_t > | total_files_processed_ {0} |
std::atomic< std::uint64_t > | malicious_files_detected_ {0} |
std::atomic< std::uint64_t > | errors_ {0} |
The concrete, internal implementation of the IScanner interface.
This class is not exported and is only accessible via the CreateScanner factory function. It orchestrates the multithreaded scanning process.
|
explicit |
Constructs a Scanner instance with its dependencies.
db | A reference to a hash database implementation. |
logger | A reference to a logger implementation. |
hasher | A reference to a file hasher implementation. |
num_threads | The number of worker threads to use for scanning. |
|
private |
The task executed by consumer threads in the pool.
Processes a single file: hashes it, checks the hash against the database, and logs a detection if found. It also updates the atomic counters for scan statistics.
path | The path of the file to process. |
|
private |
The task executed by the producer thread.
Traverses the filesystem recursively from the given root path, enqueues a consumer task for each regular file found, and signals completion or error via a promise.
scan_path | The root directory to traverse. |
pool | The thread pool to enqueue tasks into. |
producer_promise | A promise to signal the outcome of the traversal. |
|
overridevirtual |
Scans the specified directory.
scan_path | The root directory for the scan. |
Implements scanner::IScanner.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |