Skip to content
API Documentation
BastionGuard™
ArchiveInspector.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 "ArchiveInspector.hpp"
22#include "ArchiveSandbox.hpp"
23
24#include <algorithm>
25#include <cctype>
26
27ArchiveInspector::ArchiveInspector(std::string worker_path, int sandbox_timeout_seconds)
28 : worker_path_(std::move(worker_path)),
29 timeout_seconds_(sandbox_timeout_seconds) {}
30
31bool ArchiveInspector::looks_like_zip_path(const std::string& path) {
32 if (path.size() < 4) {
33 return false;
34 }
35
36 std::string lower = path;
37 std::transform(lower.begin(), lower.end(), lower.begin(),
38 [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
39
40 return lower.size() >= 4 && lower.substr(lower.size() - 4) == ".zip";
41}
42
43ArchiveInspectionResult ArchiveInspector::inspect(const std::string& input_path) const {
45}
ArchiveInspectionResult analyze_archive_in_sandbox(const std::string &worker_path, const std::string &input_path, int timeout_seconds)
ArchiveInspectionResult inspect(const std::string &input_path) const
ArchiveInspector(std::string worker_path, int sandbox_timeout_seconds=10)
static bool looks_like_zip_path(const std::string &path)