An implementation of IHashDatabase that loads signatures from a CSV file.
More...
#include <csv_hash_database.h>
|
std::size_t | Load (const std::filesystem::path &source_path) override |
| Loads malicious signatures from a specified CSV file.
|
|
std::optional< std::string > | FindHash (const std::string &hash) const override |
| Looks up a hash in the loaded database.
|
|
virtual | ~IHashDatabase ()=default |
|
|
std::unordered_map< std::string, std::string > | signatures_ |
|
An implementation of IHashDatabase that loads signatures from a CSV file.
This class parses a semicolon-separated CSV file where each line contains a hash and its corresponding verdict. It stores these signatures in an unordered_map for efficient lookups. This class is an internal, non-exported component of the scanner library.
◆ FindHash()
std::optional< std::string > scanner::CsvHashDatabase::FindHash |
( |
const std::string & |
hash | ) |
const |
|
overridevirtual |
Looks up a hash in the loaded database.
- Parameters
-
hash | The hash string to look up. |
- Returns
- An optional containing the verdict if the hash is found, otherwise std::nullopt.
Implements scanner::IHashDatabase.
◆ Load()
std::size_t scanner::CsvHashDatabase::Load |
( |
const std::filesystem::path & |
source_path | ) |
|
|
overridevirtual |
Loads malicious signatures from a specified CSV file.
Clears any existing data and reads the file line by line. Malformed lines are skipped, and a warning is printed to stderr.
- Parameters
-
source_path | The path to the CSV database file. |
- Returns
- The total number of signatures successfully loaded.
- Exceptions
-
std::runtime_error | if the file cannot be opened. |
Implements scanner::IHashDatabase.
◆ signatures_
std::unordered_map<std::string, std::string> scanner::CsvHashDatabase::signatures_ |
|
private |
The documentation for this class was generated from the following files: