#include <ScanPage.hpp>
Public Member Functions | |
| ScanPage (Gtk::Window &parent) | |
| ~ScanPage () override | |
Private Member Functions | |
| void | enqueueLog (const std::string &msg) |
| void | flushLog () |
| void | saveCloudConfig () |
| void | loadCloudConfig () |
| void | onApiKeySaveClicked () |
| void | showCloudPrivacyDisclaimer () |
| void | onToggleApiKeyVisibility () |
| void | onChooseFolder () |
| void | onChooseFile () |
| void | onStartScan () |
| void | readOutput (const Glib::RefPtr< Gio::AsyncResult > &result) |
| void | addFileToList (const std::string &filepath) |
| void | saveConfig () |
| void | loadConfig () |
| std::vector< std::string > | detectBrowserDownloadDirs () |
| std::vector< std::string > | getXdgUserDirs () |
| bool | isOutsideKnownDownloadDirs (const std::string &path) |
| void | addInotifyRecursive (const std::string &path) |
| bool | onInotifyEvent (Glib::IOCondition cond) |
| void | handleInotifyFileEvent (const std::string &path, uint32_t mask) |
| void | enableAutoScanDownloads () |
| void | enableGlobalDownloadMonitor () |
| void | disableAllMonitors () |
| void | onChooseFolderFinish (const Glib::RefPtr< Gio::AsyncResult > &result, Glib::RefPtr< Gtk::FileDialog > dialog) |
| void | onChooseFileFinish (const Glib::RefPtr< Gio::AsyncResult > &result, Glib::RefPtr< Gtk::FileDialog > dialog) |
| void | scanFileAutomatically (const std::string &filepath) |
| bool | isInterestingDownload (const std::string &path) |
| std::string | resolveFinalDownloadedFile (const std::string &path) |
| void | onAurPkgbuildDetected (const std::string &path) |
| void | scanAurAuto (const std::string &path) |
| void | cloudCheckMalwareBazaar (const std::string &filepath) |
| void | cloudCheckMalwareBazaarWorker (const std::string &filepath) |
| void | handleInfectedFile (const std::string &filepath) |
| void | handleInfectedFiles (const std::vector< std::string > &files) |
| void | handleInfectedFileWithName (const std::string &filepath, const std::string &virusName) |
| void | showAlertWindow (const std::string &file, const std::string &family) |
| void | logMessage (const std::string &msg) |
| bool | safeExists (const std::string &p) noexcept |
Private Attributes | |
| Gtk::Window & | parentWindow |
| Gtk::Box | buttonBox {Gtk::Orientation::HORIZONTAL, 5} |
| Gtk::Button | btnChooseFolder {_("Seleziona cartella")} |
| Gtk::Button | btnChooseFile {_("Seleziona file")} |
| Gtk::Button | btnScan {_("Scansiona")} |
| Gtk::Box | autoScanBox {Gtk::Orientation::HORIZONTAL, 6} |
| Gtk::Label | autoScanLabel |
| Gtk::Switch | autoScanSwitch |
| bool | autoScanEnabled = true |
| Gtk::TextView | textView |
| Glib::RefPtr< Gtk::TextBuffer > | textBuffer |
| Gtk::ListBox | fileListBox |
| Gtk::Box | apiKeyActionsBox {Gtk::Orientation::HORIZONTAL, 6} |
| Glib::RefPtr< Gtk::SizeGroup > | apiKeySizeGroup |
| Glib::RefPtr< Gio::Subprocess > | subprocess |
| Glib::RefPtr< Gio::InputStream > | stdoutStream |
| Glib::RefPtr< Gio::DataInputStream > | dataStream |
| Gtk::Box | apiKeyBox {Gtk::Orientation::HORIZONTAL, 6} |
| Gtk::Entry | apiKeyEntry |
| Gtk::Button | btnShowApiKey |
| Gtk::Button | btnApiKeySave {"Salva"} |
| Gtk::Button | btnPrivacy |
| bool | apiKeyVisible = false |
| std::string | malwareBazaarApiKey |
| std::mutex | logMutex |
| std::vector< std::string > | pendingLog |
| bool | logFlushScheduled = false |
| std::string | selectedPath |
| std::vector< std::string > | infectedFilesBuffer |
| bool | scanInProgress = false |
| std::vector< std::string > | knownDownloadDirs |
| int | inotifyFd = -1 |
| Glib::RefPtr< Glib::IOSource > | inotifySource |
| std::unordered_map< int, std::string > | watchMap |
| std::unordered_set< std::string > | alreadyWatched |
| BastionGuard::AliveFlag | alive_ = BastionGuard::make_alive_flag() |
Definition at line 37 of file ScanPage.hpp.
|
explicit |
Definition at line 131 of file ScanPage.cpp.
References _, apiKeyActionsBox, apiKeyBox, apiKeyEntry, apiKeySizeGroup, autoScanBox, autoScanEnabled, autoScanLabel, autoScanSwitch, btnApiKeySave, btnChooseFile, btnChooseFolder, btnPrivacy, btnScan, btnShowApiKey, buttonBox, detectBrowserDownloadDirs(), disableAllMonitors(), enableAutoScanDownloads(), enableGlobalDownloadMonitor(), enqueueLog(), fileListBox, inotifyFd, inotifySource, knownDownloadDirs, loadCloudApiKeys(), loadCloudConfig(), loadConfig(), onApiKeySaveClicked(), onChooseFile(), onChooseFolder(), onInotifyEvent(), onStartScan(), onToggleApiKeyVisibility(), parentWindow, saveConfig(), showCloudPrivacyDisclaimer(), textBuffer, and textView.
|
override |
|
private |
Definition at line 878 of file ScanPage.cpp.
References fileListBox.
Referenced by readOutput().
|
private |
Definition at line 335 of file ScanPage.cpp.
References _, addInotifyRecursive(), alreadyWatched, enqueueLog(), inotifyFd, isInBuildDir(), normalizePath(), and watchMap.
Referenced by addInotifyRecursive(), enableAutoScanDownloads(), and enableGlobalDownloadMonitor().
|
private |
Definition at line 1216 of file ScanPage.cpp.
References _, activeCloudChecks, alive_, cloudCheckMalwareBazaarWorker(), enqueueLog(), and BastionGuard::if_alive().
Referenced by resolveFinalDownloadedFile(), and scanFileAutomatically().
|
private |
Definition at line 1154 of file ScanPage.cpp.
References _, alive_, enqueueLog(), BastionGuard::if_alive(), MalwareBazaar::lookupHash(), parentWindow, MalwareBazaar::sha256_file(), and Utils::show_message().
Referenced by cloudCheckMalwareBazaar(), and resolveFinalDownloadedFile().
|
private |
Definition at line 895 of file ScanPage.cpp.
Referenced by enableAutoScanDownloads(), and ScanPage().
|
private |
Definition at line 638 of file ScanPage.cpp.
References _, alreadyWatched, enqueueLog(), inotifyFd, and watchMap.
Referenced by ScanPage().
|
private |
Definition at line 979 of file ScanPage.cpp.
References _, addInotifyRecursive(), detectBrowserDownloadDirs(), enqueueLog(), knownDownloadDirs, and normalizePath().
Referenced by ScanPage().
|
private |
Definition at line 1023 of file ScanPage.cpp.
References _, addInotifyRecursive(), enqueueLog(), getXdgUserDirs(), and normalizePath().
Referenced by ScanPage().
|
private |
Definition at line 286 of file ScanPage.cpp.
References flushLog(), logFlushScheduled, logMutex, and pendingLog.
Referenced by addInotifyRecursive(), cloudCheckMalwareBazaar(), cloudCheckMalwareBazaarWorker(), disableAllMonitors(), enableAutoScanDownloads(), enableGlobalDownloadMonitor(), handleInfectedFiles(), handleInfectedFileWithName(), handleInotifyFileEvent(), loadCloudConfig(), onAurPkgbuildDetected(), onChooseFileFinish(), onChooseFolderFinish(), onStartScan(), saveCloudConfig(), scanAurAuto(), scanFileAutomatically(), and ScanPage().
|
private |
Definition at line 297 of file ScanPage.cpp.
References logFlushScheduled, logMutex, pendingLog, and textBuffer.
Referenced by enqueueLog().
|
private |
Definition at line 992 of file ScanPage.cpp.
Referenced by enableGlobalDownloadMonitor().
|
private |
Definition at line 1253 of file ScanPage.cpp.
References handleInfectedFileWithName().
Referenced by resolveFinalDownloadedFile().
|
private |
Definition at line 1259 of file ScanPage.cpp.
References _, enqueueLog(), parentWindow, and Utils::show_message().
Referenced by resolveFinalDownloadedFile().
|
private |
Definition at line 1292 of file ScanPage.cpp.
References _, enqueueLog(), parentWindow, and Utils::show_message().
Referenced by handleInfectedFile(), onAurPkgbuildDetected(), readOutput(), resolveFinalDownloadedFile(), scanAurAuto(), and scanFileAutomatically().
|
private |
Definition at line 558 of file ScanPage.cpp.
References _, autoScanEnabled, ends_with(), enqueueLog(), g_burstWindowStartMs, g_recentEventCount, g_throttleUntilMs, isBuildArtifactExt(), isInBuildDir(), kBurstThreshold, kBurstWindowMs, kThrottleHoldMs, nowMs(), recentlyScanned, and scanFileAutomatically().
Referenced by onInotifyEvent().
|
private |
|
private |
Definition at line 970 of file ScanPage.cpp.
References knownDownloadDirs.
|
private |
Definition at line 494 of file ScanPage.cpp.
References _, apiKeyEntry, enqueueLog(), globalMalwareBazaarApiKey, malwareBazaarApiKey, and trim().
Referenced by ScanPage().
|
private |
Definition at line 324 of file ScanPage.cpp.
References autoScanEnabled, autoScanSwitch, and getConfigPath().
Referenced by ScanPage().
|
private |
Definition at line 1057 of file ScanPage.cpp.
References textBuffer.
Referenced by resolveFinalDownloadedFile().
|
private |
Definition at line 551 of file ScanPage.cpp.
References apiKeyEntry, malwareBazaarApiKey, and saveCloudConfig().
Referenced by ScanPage().
|
private |
Definition at line 1063 of file ScanPage.cpp.
References _, enqueueLog(), handleInfectedFileWithName(), scanAurAuto(), and AurScan::scanPKGBUILD().
Referenced by resolveFinalDownloadedFile().
|
private |
Definition at line 463 of file ScanPage.cpp.
References _, onChooseFileFinish(), and parentWindow.
Referenced by ScanPage().
|
private |
Definition at line 478 of file ScanPage.cpp.
References _, enqueueLog(), and selectedPath.
Referenced by onChooseFile().
|
private |
Definition at line 431 of file ScanPage.cpp.
References _, onChooseFolderFinish(), and parentWindow.
Referenced by ScanPage().
|
private |
Definition at line 446 of file ScanPage.cpp.
References _, enqueueLog(), and selectedPath.
Referenced by onChooseFolder().
|
private |
Definition at line 399 of file ScanPage.cpp.
References handleInotifyFileEvent(), inotifyFd, and watchMap.
Referenced by ScanPage().
|
private |
Definition at line 651 of file ScanPage.cpp.
References _, dataStream, enqueueLog(), fileListBox, infectedFilesBuffer, readOutput(), scanInProgress, selectedPath, stdoutStream, subprocess, textBuffer, and trim().
Referenced by ScanPage().
|
private |
Definition at line 1435 of file ScanPage.cpp.
References apiKeyEntry, apiKeyVisible, and btnShowApiKey.
Referenced by ScanPage().
|
private |
Definition at line 704 of file ScanPage.cpp.
References _, addFileToList(), alive_, dataStream, handleInfectedFileWithName(), BastionGuard::if_alive(), infectedFilesBuffer, readOutput(), scanInProgress, and textBuffer.
Referenced by onStartScan(), and readOutput().
|
private |
|
privatenoexcept |
Definition at line 1334 of file ScanPage.cpp.
Referenced by resolveFinalDownloadedFile().
|
private |
Definition at line 532 of file ScanPage.cpp.
References _, enqueueLog(), globalMalwareBazaarApiKey, and malwareBazaarApiKey.
Referenced by onApiKeySaveClicked().
|
private |
Definition at line 314 of file ScanPage.cpp.
References autoScanEnabled, and getConfigPath().
Referenced by ScanPage().
|
private |
Definition at line 1082 of file ScanPage.cpp.
References _, alive_, enqueueLog(), handleInfectedFileWithName(), and BastionGuard::if_alive().
Referenced by onAurPkgbuildDetected(), and resolveFinalDownloadedFile().
|
private |
Definition at line 760 of file ScanPage.cpp.
References _, alive_, autoScanEnabled, cloudCheckMalwareBazaar(), enqueueLog(), handleInfectedFileWithName(), BastionGuard::if_alive(), and recentlyScanned.
Referenced by handleInotifyFileEvent().
|
private |
Definition at line 1324 of file ScanPage.cpp.
References _, parentWindow, and Utils::show_message().
Referenced by resolveFinalDownloadedFile().
|
private |
Definition at line 1346 of file ScanPage.cpp.
References _, and resource().
Referenced by ScanPage().
|
private |
Definition at line 166 of file ScanPage.hpp.
Referenced by cloudCheckMalwareBazaar(), cloudCheckMalwareBazaarWorker(), readOutput(), scanAurAuto(), scanFileAutomatically(), and ~ScanPage().
|
private |
Definition at line 123 of file ScanPage.hpp.
Referenced by addInotifyRecursive(), and disableAllMonitors().
|
private |
Definition at line 60 of file ScanPage.hpp.
Referenced by ScanPage().
|
private |
Definition at line 68 of file ScanPage.hpp.
Referenced by ScanPage().
|
private |
Definition at line 69 of file ScanPage.hpp.
Referenced by loadCloudConfig(), onApiKeySaveClicked(), onToggleApiKeyVisibility(), and ScanPage().
|
private |
Definition at line 61 of file ScanPage.hpp.
Referenced by ScanPage().
|
private |
Definition at line 74 of file ScanPage.hpp.
Referenced by onToggleApiKeyVisibility().
|
private |
Definition at line 51 of file ScanPage.hpp.
Referenced by ScanPage().
|
private |
Definition at line 54 of file ScanPage.hpp.
Referenced by handleInotifyFileEvent(), loadConfig(), saveConfig(), scanFileAutomatically(), and ScanPage().
|
private |
Definition at line 52 of file ScanPage.hpp.
Referenced by ScanPage().
|
private |
Definition at line 53 of file ScanPage.hpp.
Referenced by loadConfig(), and ScanPage().
|
private |
Definition at line 71 of file ScanPage.hpp.
Referenced by ScanPage().
|
private |
Definition at line 48 of file ScanPage.hpp.
Referenced by ScanPage().
|
private |
Definition at line 47 of file ScanPage.hpp.
Referenced by ScanPage().
|
private |
Definition at line 72 of file ScanPage.hpp.
Referenced by ScanPage().
|
private |
Definition at line 49 of file ScanPage.hpp.
Referenced by ScanPage().
|
private |
Definition at line 70 of file ScanPage.hpp.
Referenced by onToggleApiKeyVisibility(), and ScanPage().
|
private |
Definition at line 46 of file ScanPage.hpp.
Referenced by ScanPage().
|
private |
Definition at line 65 of file ScanPage.hpp.
Referenced by onStartScan(), and readOutput().
|
private |
Definition at line 59 of file ScanPage.hpp.
Referenced by addFileToList(), onStartScan(), and ScanPage().
|
private |
Definition at line 96 of file ScanPage.hpp.
Referenced by onStartScan(), and readOutput().
|
private |
Definition at line 116 of file ScanPage.hpp.
Referenced by addInotifyRecursive(), disableAllMonitors(), onInotifyEvent(), and ScanPage().
|
private |
Definition at line 117 of file ScanPage.hpp.
Referenced by ScanPage().
|
private |
Definition at line 110 of file ScanPage.hpp.
Referenced by enableAutoScanDownloads(), isOutsideKnownDownloadDirs(), and ScanPage().
|
private |
Definition at line 81 of file ScanPage.hpp.
Referenced by enqueueLog(), and flushLog().
|
private |
Definition at line 79 of file ScanPage.hpp.
Referenced by enqueueLog(), and flushLog().
|
private |
Definition at line 75 of file ScanPage.hpp.
Referenced by loadCloudConfig(), onApiKeySaveClicked(), and saveCloudConfig().
|
private |
Definition at line 43 of file ScanPage.hpp.
Referenced by cloudCheckMalwareBazaarWorker(), handleInfectedFiles(), handleInfectedFileWithName(), onChooseFile(), onChooseFolder(), ScanPage(), and showAlertWindow().
|
private |
Definition at line 80 of file ScanPage.hpp.
Referenced by enqueueLog(), and flushLog().
|
private |
Definition at line 97 of file ScanPage.hpp.
Referenced by onStartScan(), and readOutput().
|
private |
Definition at line 95 of file ScanPage.hpp.
Referenced by onChooseFileFinish(), onChooseFolderFinish(), and onStartScan().
|
private |
Definition at line 64 of file ScanPage.hpp.
Referenced by onStartScan().
|
private |
Definition at line 63 of file ScanPage.hpp.
Referenced by onStartScan().
|
private |
Definition at line 57 of file ScanPage.hpp.
Referenced by flushLog(), logMessage(), onStartScan(), readOutput(), and ScanPage().
|
private |
Definition at line 56 of file ScanPage.hpp.
Referenced by ScanPage().
|
private |
Definition at line 120 of file ScanPage.hpp.
Referenced by addInotifyRecursive(), disableAllMonitors(), and onInotifyEvent().