Skip to content

Commit b9402c8

Browse files
timopollmeierbjoernricks
authored andcommitted
Fix: Use CPE v2.2 in new CVE scanner, add indexes
The new CVE scanner now uses CPEs in the v2.2 URI format which is still used for backward compatibility with the scanner. Also, indexes have been added to speed up the CVE scans.
1 parent 9d78094 commit b9402c8

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/manage.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -3284,16 +3284,16 @@ check_cpe_match_rule (long long int node, gboolean *match, gboolean *vulnerable,
32843284
while (next (&cpe_match_ranges))
32853285
{
32863286
iterator_t cpe_host_details_products;
3287-
gchar *range_fs_cpe;
3287+
gchar *range_uri_cpe;
32883288
gchar *range_uri_product;
32893289
gchar *vsi, *vse, *vei, *vee;
3290-
range_fs_cpe = vsi = vse = vei = vee = NULL;
3291-
range_fs_cpe = g_strdup (cpe_match_string_iterator_criteria (&cpe_match_ranges));
3290+
range_uri_cpe = vsi = vse = vei = vee = NULL;
3291+
range_uri_cpe = g_strdup (cpe_match_string_iterator_criteria (&cpe_match_ranges));
32923292
vsi = g_strdup (cpe_match_string_iterator_version_start_incl (&cpe_match_ranges));
32933293
vse = g_strdup (cpe_match_string_iterator_version_start_excl (&cpe_match_ranges));
32943294
vei = g_strdup (cpe_match_string_iterator_version_end_incl (&cpe_match_ranges));
32953295
vee = g_strdup (cpe_match_string_iterator_version_end_excl (&cpe_match_ranges));
3296-
range_uri_product = fs_cpe_to_uri_product (range_fs_cpe);
3296+
range_uri_product = uri_cpe_to_uri_product (range_uri_cpe);
32973297
init_host_details_cpe_product_iterator (&cpe_host_details_products, range_uri_product, report_host);
32983298
while (next (&cpe_host_details_products))
32993299
{
@@ -3303,7 +3303,7 @@ check_cpe_match_rule (long long int node, gboolean *match, gboolean *vulnerable,
33033303
host_details_cpe = host_details_cpe_product_iterator_value (&cpe_host_details_products);
33043304
cpe_struct_init (&source);
33053305
cpe_struct_init (&target);
3306-
fs_cpe_to_cpe_struct (range_fs_cpe, &source);
3306+
uri_cpe_to_cpe_struct (range_uri_cpe, &source);
33073307
uri_cpe_to_cpe_struct (host_details_cpe, &target);
33083308
matches = cpe_struct_match (&source, &target);
33093309
if (matches)
@@ -3321,15 +3321,15 @@ check_cpe_match_rule (long long int node, gboolean *match, gboolean *vulnerable,
33213321
cpe_struct_t source, target;
33223322
cpe_struct_init (&source);
33233323
cpe_struct_init (&target);
3324-
fs_cpe_to_cpe_struct (range_fs_cpe, &source);
3324+
uri_cpe_to_cpe_struct (range_uri_cpe, &source);
33253325
uri_cpe_to_cpe_struct (host_cpe, &target);
33263326
if (cpe_struct_match (&source, &target))
33273327
*vulnerable = TRUE;
33283328
cpe_struct_free (&source);
33293329
cpe_struct_free (&target);
33303330
}
33313331
g_free (range_uri_product);
3332-
g_free (range_fs_cpe);
3332+
g_free (range_uri_cpe);
33333333
g_free (vsi);
33343334
g_free (vse);
33353335
g_free (vei);
@@ -3375,7 +3375,7 @@ cve_scan_report_host_json (task_t task,
33753375
double severity;
33763376

33773377
host_cpe = host_details_cpe_iterator_cpe (&host_details_cpe);
3378-
cpe_product = uri_cpe_to_fs_product (host_cpe);
3378+
cpe_product = uri_cpe_to_uri_product (host_cpe);
33793379
init_cpe_match_nodes_iterator (&cpe_match_root_node, cpe_product);
33803380
while (next (&cpe_match_root_node))
33813381
{

src/manage_pg.c

+6
Original file line numberDiff line numberDiff line change
@@ -3784,6 +3784,12 @@ manage_db_init_indexes (const gchar *name)
37843784
sql ("CREATE INDEX cpes_by_cpe_name_id"
37853785
" ON scap2.cpes(cpe_name_id);");
37863786

3787+
sql ("CREATE INDEX cpe_match_nodes_by_root_id"
3788+
" ON scap2.cpe_match_nodes(root_id);");
3789+
3790+
sql ("CREATE INDEX cpe_nodes_match_criteria_by_node_id"
3791+
" ON scap2.cpe_nodes_match_criteria(node_id);");
3792+
37873793
sql ("CREATE INDEX afp_cpe_idx"
37883794
" ON scap2.affected_products (cpe);");
37893795
sql ("CREATE INDEX afp_cve_idx"

0 commit comments

Comments
 (0)