Skip to content
API Documentation
BastionGuard™
LeakCheckProvider.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 "LeakCheckProvider.hpp"
22#include "../net/HttpClient.hpp"
23#include <nlohmann/json.hpp>
24#include <glib/gi18n.h>
25
26using json = nlohmann::json;
27
28std::vector<LeakRecord>
29LeakCheckProvider::checkEmail(const std::string& email)
30{
31 std::vector<LeakRecord> results;
32
33 if (email.empty())
34 return results;
35
36 const std::string url =
37 "https://leakcheck.io/api/public?check=" +
39
40 HttpResponse resp = HttpClient::get(url, {}, 15);
41
42 if (resp.status != 200)
43 return results;
44
45 json root;
46 try {
47 root = json::parse(resp.body);
48 } catch (...) {
49 return results;
50 }
51
52 if (!root.value("found", false))
53 return results;
54
55 for (const auto& src : root["sources"]) {
56 LeakRecord rec;
57 rec.provider = "LeakCheck (public)";
58 rec.breachName = src.get<std::string>();
59 rec.breachDate = ""; // non disponibile
60 rec.description = _("Rilevato da LeakCheck Public API");
62 rec.dataClasses = { "Email address" };
63
64 results.push_back(std::move(rec));
65 }
66
67 return results;
68}
nlohmann::json json
Definition Backend.cpp:2908
#define _(s)
static HttpResponse get(const std::string &url, const std::map< std::string, std::string > &headers={}, long timeoutSeconds=20)
static std::string urlEncode(const std::string &value)
std::vector< LeakRecord > checkEmail(const std::string &email) override
std::string body
std::string breachDate
Severity severity
std::vector< std::string > dataClasses
std::string provider
std::string description
std::string breachName