Skip to content
API Documentation
BastionGuard™
AboutPage.cpp
Go to the documentation of this file.
1/*
2 * BastionGuard™
3 * Copyright (C) 2025–2026 Calogero Scarnà
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *
17 * BastionGuard™ is a trademark of Calogero Scarnà.
18 * The BastionGuard™ name and branding are not licensed under the GPL.
19 */
20
21#include "Resource.hpp"
22#include "AboutPage.hpp"
23#include "DistroUtils.hpp"
24#include <giomm/file.h>
25#include <fstream>
26#include <sstream>
27#include <ctime>
28#include <iostream>
29#include <filesystem>
30#include <glib/gi18n.h>
31#include <glibmm/spawn.h>
32#include <cstdio>
33#include <cstdlib>
34#include <unistd.h>
35#include <glibmm/spawn.h>
36#include <glibmm/error.h>
37#include <exception>
38
39std::pair<std::string, std::string> AboutPage::load_version_build() {
40 namespace fs = std::filesystem;
41
42 std::string version = "?.?";
43 std::string build = "?";
44
45 const std::string path = "/usr/share/BastionGuard/data/version.bs";
46
47 if (!fs::exists(path))
48 return {version, build};
49
50 std::ifstream file(path);
51 if (!file.is_open())
52 return {version, build};
53
54 std::string line;
55 while (std::getline(file, line)) {
56 line.erase(0, line.find_first_not_of(" \t"));
57 line.erase(line.find_last_not_of(" \t") + 1);
58
59 if (line.starts_with("version="))
60 version = line.substr(8);
61 else if (line.starts_with("build="))
62 build = line.substr(6);
63 }
64
65 return {version, build};
66}
67
68
69
70AboutPage::AboutPage() : Gtk::Box(Gtk::Orientation::VERTICAL) {
71 set_margin(12);
72
73 // Notebook con i tab
74 append(notebook_);
75
76 // ===== Tab Programma =====
77 auto box_program = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 8);
78
79 // Icona
80 auto picture_icon = Gtk::make_managed<Gtk::Picture>();
81 try {
82 picture_icon->set_file(Gio::File::create_for_path(resource("logo.png")));
83 picture_icon->set_size_request(64, 64);
84 } catch (...) {
85 // fallback se l’icona non esiste
86 }
87 picture_icon->set_halign(Gtk::Align::CENTER);
88 box_program->append(*picture_icon);
89
90 // Nome programma
91 auto [version, build] = load_version_build();
92
93 auto label_name = Gtk::make_managed<Gtk::Label>();
94 label_name->set_use_markup(true);
95 label_name->set_halign(Gtk::Align::CENTER);
96
97 label_name->set_markup(
98 Glib::ustring::compose(
99 "<b>BastionGuard™ Endpoint</b> "
100 "<span size='medium'><i>%1 · build %2</i></span>",
101 version,
102 build
103 )
104 );
105
106
107 box_program->append(*label_name);
108
109 // Copyright
110 auto label_copy = Gtk::make_managed<Gtk::Label>();
111 label_copy->set_use_markup(true);
112 std::time_t t = std::time(nullptr);
113 std::tm tm{};
114 localtime_r(&t, &tm);
115
116 int year = tm.tm_year + 1900;
117 std::string year_str = std::to_string(year);
118 label_copy->set_markup(
119 Glib::ustring::compose(
120 _("© 2025-%1 Calogero Scarnà — BastionGuard™\n"
121 "BastionGuard è stato depositato il 16/12/2025 presso UIBM (Italia) con il numero 302025000196519.\n"
122 "Il motore anti-ransomware e anti-phishing è parte integrante della piattaforma di sicurezza.\n"
123 "Il sistema include la scansione delle periferiche USB,\n"
124 "scansione delle cartelle samba\n"
125 "e le funzionalità di blocco di microfono e webcam.\n"
126 "La protezione comprende la scansione in tempo reale con inotify.\n"
127 "ClamAV® è un marchio registrato da Cisco\n"
128 "%2\n"),
129 year_str,
130 "<a href='https://www.codelinsoft.it' title='Visita CodeLinSoft'>"
131 "Powered by <b>CodeLinSoft</b></a>"
132 )
133 );
134
135
136 label_copy->set_halign(Gtk::Align::CENTER);
137 label_copy->set_justify(Gtk::Justification::CENTER);
138 label_copy->set_wrap(true);
139 box_program->append(*label_copy);
140
141
142 notebook_.append_page(*box_program, _("Programma"));
143
144 // ===== Tab Terze Parti =====
145 auto box_thirdparty = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 8);
146 Glib::ustring thirdparty_text =
147 _("Questa applicazione utilizza:\n"
148 "- ClamAV Antivirus Engine\n"
149 "- GTK4 / gtkmm-4\n"
150 "- Image / libpng\n"
151 "- Rules / yara\n"
152 "- Udev\n"
153 "- Libudev\n"
154 "- Nginx\n"
155 "- php\n"
156 "- Sigc++\n"
157 "- Libsecret\n"
158 "- IDN2\n"
159 "- SQLITE3\n"
160 "- HYPERSCAN\n"
161 "- RE2\n"
162 "- Polkit\n"
163 "- Nlohmann_json\n"
164 "- DNSmasq /blocco pagine\n"
165 "- Antiphishing server/ libsoup\n");
167 thirdparty_text += _("- Sandbox bancario/ chromium sandbox (CEF)\n");
168 }
169 thirdparty_text += _("- MISP lista per le banche\n");
170
171 auto label_thirdparty = Gtk::make_managed<Gtk::Label>(thirdparty_text);
172 label_thirdparty->set_wrap(true);
173 box_thirdparty->append(*label_thirdparty);
174 notebook_.append_page(*box_thirdparty, _("Terze Parti"));
175
176 // ===== Tab Licenza =====
177 auto box_license = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 8);
178
179 auto sw = Gtk::make_managed<Gtk::ScrolledWindow>();
180 sw->set_expand(true);
181 sw->set_policy(Gtk::PolicyType::AUTOMATIC, Gtk::PolicyType::AUTOMATIC);
182
183 auto tv = Gtk::make_managed<Gtk::TextView>();
184 tv->set_editable(false);
185 tv->set_wrap_mode(Gtk::WrapMode::WORD);
186
187 auto buf = Gtk::TextBuffer::create();
188 buf->set_text(load_license_text());
189 tv->set_buffer(buf);
190
191 sw->set_child(*tv);
192 box_license->append(*sw);
193
194 notebook_.append_page(*box_license, _("Licenza"));
195
196 // ===== Tab Database =====
197 auto box_db = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 8);
198
199 auto swdb = Gtk::make_managed<Gtk::ScrolledWindow>();
200 swdb->set_expand(true);
201 swdb->set_policy(Gtk::PolicyType::AUTOMATIC, Gtk::PolicyType::AUTOMATIC);
202
203 auto tvdb = Gtk::make_managed<Gtk::TextView>();
204 tvdb->set_editable(false);
205 tvdb->set_wrap_mode(Gtk::WrapMode::WORD);
206
207 auto bufdb = Gtk::TextBuffer::create();
208 bufdb->set_text(load_database_info());
209 tvdb->set_buffer(bufdb);
210
211 swdb->set_child(*tvdb);
212 box_db->append(*swdb);
213
214 notebook_.append_page(*box_db, _("Database"));
215
216}
217
218
220 namespace fs = std::filesystem;
221
222 std::vector<std::string> candidates = {
223 "data/license/COPYING",
224 "/usr/share/BastionGuard/data/license/COPYING",
225 "COPYING",
226 "LICENSE",
227 "/usr/share/doc/BastionGuard/COPYING",
228 "/usr/share/common-licenses/GPL-3"
229 };
230
231 for (const auto& path : candidates) {
232 if (fs::exists(path)) {
233 std::ifstream f(path);
234 if (f.is_open()) {
235 std::stringstream buf;
236 buf << f.rdbuf();
237 return buf.str();
238 }
239 }
240 }
241
242 return _("GNU GPL v3 license text not found.\n"
243 "Assicurati che il file COPYING sia incluso nel progetto "
244 "o che la tua distribuzione fornisca /usr/share/common-licenses/GPL-3.");
245}
246
248 namespace fs = std::filesystem;
249 const std::string path = "/var/lib/clamav";
250
251 if (!fs::exists(path))
252 return _("Directory /var/lib/clamav non trovata.\n");
253
254 std::stringstream out;
255 out << _("📁 Database ClamAV trovati in /var/lib/clamav\n\n");
256
257 for (const auto& entry : fs::directory_iterator(path)) {
258 auto file = entry.path().filename().string();
259
260 if (file.ends_with(".hdb") || file.ends_with(".ndb") ||
261 file.ends_with(".ldb") || file.ends_with(".cdb") ||
262 file.ends_with(".hsb") || file.ends_with(".fp")) {
263
264 out << "✔ " << file << "\n";
265 }
266 else if (file.ends_with(".cld") || file.ends_with(".cvd")) {
267 out << "🔒 " << file << _(" (database ufficiale ClamAV)\n");
268 }
269 else {
270
271 out << "• " << file << "\n";
272 }
273 }
274
275
276 return out.str();
277}
#define _(s)
std::string load_license_text()
std::pair< std::string, std::string > load_version_build()
Definition AboutPage.cpp:39
Gtk::Notebook notebook_
Definition AboutPage.hpp:31
std::string load_database_info()
std::string resource(const std::string &rel)
Definition Resource.hpp:31