prabhuat commited on
Commit
2cd65d1
·
1 Parent(s): 0c5728b

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +136 -0
README.md ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ tags:
6
+ - vulnerabilities
7
+ - vdb
8
+ - sca
9
+ - osv
10
+ - nvd
11
+ - ghsa
12
+ - vers
13
+ - purl
14
+ ---
15
+
16
+ This dataset comprises application and OS vulnerabilities aggregated from multiple sources, including OSV, GitHub, NVD, and Linux vendor feeds, in the form of SQLite data files (.vdb6).
17
+
18
+ ## Vulnerability Data sources
19
+
20
+ - Linux [vuln-list](https://github.com/appthreat/vuln-list) (Forked from AquaSecurity)
21
+ - OSV (1)
22
+ - NVD
23
+ - GitHub
24
+
25
+ 1 - We exclude Linux and oss-fuzz feeds by default. Set the environment variable `OSV_INCLUDE_FUZZ=true` to include them.
26
+ 2 - Malware feeds are included by default, thus increasing the db size slightly. Set the environment variable `OSV_EXCLUDE_MALWARE=true` to exclude them.
27
+
28
+ ## Linux distros
29
+
30
+ - AlmaLinux
31
+ - Debian
32
+ - Alpine
33
+ - Amazon Linux
34
+ - Arch Linux
35
+ - RHEL/CentOS
36
+ - Rocky Linux
37
+ - Ubuntu
38
+ - OpenSUSE
39
+ - Photon
40
+ - Chainguard
41
+ - Wolfi OS
42
+
43
+ ## Database files
44
+
45
+ The vulnerability database comprises two SQLite database files.
46
+
47
+ - data.index.vdb6 - A smaller index database optimized for quick purl or cpe string searches and vers-based range comparisons.
48
+
49
+ ![Index schema](./docs/vdb-index-schema.png)
50
+
51
+ - data.vdb6 - Full CVE source database containing normalized data in CVE 5.1 specification formation and purl prefix.
52
+
53
+ ![Data schema](./docs/vdb-schema.png)
54
+
55
+ ## Folders
56
+
57
+ - app - Application only vulnerabilities from 2018
58
+ - app-10y - Application only vulnerabilities from 2014
59
+ - app-os - Application and OS vulnerabilities from 2018
60
+ - app-os-10y - Application and OS vulnerabilities from 2014
61
+
62
+ Download data.vdb6 and data.index.vdb6 files from a single folder of your choice.
63
+
64
+ ## Searching for CVEs
65
+
66
+ Use the smaller index database for all search operations.
67
+
68
+ ### Searching by purl
69
+
70
+ Given a purl string (`purl_str`), perform the following steps to convert this into a suitable purl prefix (`purl_prefix`) string:
71
+
72
+ In most cases, a purl prefix is a substring at index 0 after a split by "@". Eg: `purl_prefix = purl_str.split("@")[0]`.
73
+
74
+ A more robust approach:
75
+
76
+ - Parse and validate the string using a suitable [library](https://github.com/package-url/). Retain the parsed purl object (`purl_obj`)
77
+ - Construct a purl prefix string with the following logic:
78
+ - Set the value for `purl_prefix` to `"pkg:" + purl_obj["type"]`
79
+ - If there is a namespace, append it to purl_prefix after the slash character. Eg: `purl_prefix = purl_prefix + "/" + purl_obj['namespace']`
80
+ - Optional for Linux distros: If there is a qualifier string with the name `distro_name`, append it to the purl_prefix after the slash character. Eg: `purl_prefix = purl_prefix + "/" + purl_obj['qualifiers']['distro_name']`
81
+ - Append the name after the slash character. Eg: `purl_prefix = purl_prefix + "/" + purl_obj['name']`
82
+
83
+ Use the below SQL query to search by purl_prefix:
84
+
85
+ ```
86
+ SELECT DISTINCT cve_id, type, namespace, name, vers, purl_prefix FROM cve_index where purl_prefix = ?;
87
+ ```
88
+
89
+ ### Searching by cpe
90
+
91
+ Parse the cpe string to extract the vendor, product, and version. The regex for python is shown below:
92
+
93
+ ```python
94
+ import re
95
+
96
+ CPE_FULL_REGEX = re.compile(
97
+ "cpe:?:[^:]+:(?P<cve_type>[^:]+):(?P<vendor>[^:]+):(?P<package>[^:]+):(?P<version>[^:]+):(?P<update>[^:]+):(?P<edition>[^:]+):(?P<lang>[^:]+):(?P<sw_edition>[^:]+):(?P<target_sw>[^:]+):(?P<target_hw>[^:]+):(?P<other>[^:]+)"
98
+ )
99
+ ```
100
+
101
+ In the `cve_index` table, vendor maps to namespace and package maps to name. The SQL query is below:
102
+
103
+ ```sql
104
+ SELECT DISTINCT cve_id, type, namespace, name, vers, purl_prefix FROM cve_index where namespace = ? AND name = ?;
105
+ ```
106
+
107
+ ### Comparing version ranges using vers
108
+
109
+ Refer to the vers [documentation](https://github.com/package-url/purl-spec/blob/version-range-spec/VERSION-RANGE-SPEC.rst) for information regarding vers and a logic to parse and check if a version is within a range. To simplify the logic, a value from the vers column in `cve_index` would contain only a maximum of two constraints (one greater than and one lesser than).
110
+
111
+ ## Combining data
112
+
113
+ Search the `cve_index` table in the index database first to retrieve any matching cve_id and purl_prefix values. Use these two column values to retrieve the full CVE source information from the `cve_data` table. An example query is shown below:
114
+
115
+ ```sql
116
+ SELECT DISTINCT cve_id, type, namespace, name, source_data_hash, json(source_data), json(override_data), purl_prefix FROM cve_data
117
+ WHERE cve_id = ? AND purl_prefix = ?
118
+ GROUP BY purl_prefix
119
+ ORDER BY cve_id DESC;
120
+ ```
121
+
122
+ Use the `source_data_hash` values to filter out any duplicate results for the same CVE. Duplicate results are possible when multiple vers match the same CVE and purl prefixes.
123
+
124
+ ## Citation
125
+
126
+ Use the below citation in your research.
127
+
128
+ ```text
129
+ @misc{vdb,
130
+ author = {Team AppThreat},
131
+ month = Feb,
132
+ title = {{AppThreat vulnerability-db}},
133
+ howpublished = {{https://huggingface.co/datasets/AppThreat/vdb}},
134
+ year = {2025}
135
+ }
136
+ ```