-
Notifications
You must be signed in to change notification settings - Fork 30
/
VulnerabilityLookup.h
87 lines (72 loc) · 1.53 KB
/
VulnerabilityLookup.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once
#include "Stdafx.h"
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <sqlite3.h>
/*!
* Represents a CPE dictionary entry.
*/
struct CveEntry
{
/*!
* CVE identifier of the entry.
*/
std::string cve;
/*!
* Vulnerability publication date.
*/
long date;
/*!
* Summary of the vulnerability.
*/
std::string descr;
/*!
* Severity of the vulnerability.
*/
float severity;
/*!
* Access vector of the vulnerability.
* Possible values are `l` for local, `a` for adjacent and `n` for network.
*/
std::string access;
};
/*!
* Implements the lookup of CPE names in the vulnerability database.
*/
class VulnerabilityLookup
{
public:
/*!
* Searches the vulnerability database for entries affecting the specified CPE name.
*
* \param cpe CPE name to lookup.
*
* \return Matching CVE entries.
*/
std::vector<CveEntry> Scan(const std::string& cpe);
/*!
* Searches the vulnerability database for entries affecting the specified CPE names.
*
* \param cpes CPE names to lookup.
*
* \return Matching CVE entries.
*/
std::unordered_map<std::string, std::vector<CveEntry>> Scan(const std::vector<std::string>& cpes);
/*!
* Frees up the resources allocated during the lifetime of this instance.
*/
~VulnerabilityLookup();
private:
/*!
* Database of CVE entries with their affected product list.
*/
sqlite3* db = nullptr;
/*!
* Opens the CVE database.
*
* \return true if it succeeds, false if it fails.
*/
bool openDatabase();
};