Skip to content
API Documentation
BastionGuard™
MalwareBazaar.cpp File Reference

Go to the source code of this file.

Functions

void loadCloudApiKeys ()
static size_t write_callback (void *contents, size_t size, size_t nmemb, std::string *out)

Variables

std::string globalMalwareBazaarApiKey = ""

Function Documentation

◆ loadCloudApiKeys()

void loadCloudApiKeys ( )

Definition at line 38 of file MalwareBazaar.cpp.

39{
40 std::string path = Glib::get_home_dir() + "/.config/BastionGuard/cloud.conf";
41
42 std::ifstream f(path);
43 if (!f) {
44 std::cerr << _("[Cloud] Nessun file ") << path << _(" trovato.\n");
45 return;
46 }
47
48 std::string line;
49 while (std::getline(f, line)) {
50 line.erase(std::remove_if(line.begin(), line.end(), ::isspace), line.end());
51 if (line.rfind(_("malware_bazaar_api_key="), 0) == 0) {
52
54 line.substr(strlen(_("malware_bazaar_api_key=")));
55
56 if (!globalMalwareBazaarApiKey.empty())
57 std::cout << _("[Cloud] API key caricata correttamente.\n");
58 else
59 std::cerr << _("[Cloud] API key vuota.\n");
60 }
61 }
62}
#define _(s)
std::string globalMalwareBazaarApiKey

References _, globalMalwareBazaarApiKey, and loadCloudApiKeys().

Referenced by loadCloudApiKeys(), and ScanPage::ScanPage().

◆ write_callback()

size_t write_callback ( void * contents,
size_t size,
size_t nmemb,
std::string * out )
static

Definition at line 112 of file MalwareBazaar.cpp.

113{
114 size_t total = size * nmemb;
115 out->append(static_cast<char*>(contents), total);
116 return total;
117}

References write_callback().

Referenced by MalwareBazaar::lookupHash(), and write_callback().

Variable Documentation

◆ globalMalwareBazaarApiKey

std::string globalMalwareBazaarApiKey = ""