Skip to content

Commit

Permalink
Merge pull request #2318 from greenbone/GEA-627_Fill_table_scap_affec…
Browse files Browse the repository at this point in the history
…ted_products_for_new_json_feed

Add: The table scap.affected_products is filled for the new JSON feed.
  • Loading branch information
a-h-abdelsalam authored Nov 11, 2024
2 parents a72ba1d + b3ff0ab commit 1db428c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -20511,7 +20511,7 @@ init_cpe_match_nodes_iterator (iterator_t* iterator, const char *criteria)
" JOIN scap.cpe_nodes_match_criteria c"
" ON n.id = c.node_id"
" JOIN scap.cpe_match_strings r"
" ON c.match_criteria = r.match_criteria_id"
" ON c.match_criteria_id = r.match_criteria_id"
" WHERE criteria like '%s%%';",
quoted_criteria);
g_free (quoted_criteria);
Expand Down
26 changes: 26 additions & 0 deletions src/manage_sql_secinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -4043,6 +4043,27 @@ update_scap_cves ()
return 0;
}

/**
* @brief Update SCAP affected products.
*
* Assume that the databases are attached.
*/
static void
update_scap_affected_products ()
{
g_info ("Updating affected products");

sql ("INSERT INTO scap2.affected_products"
" SELECT DISTINCT scap2.cpe_match_nodes.cve_id, scap2.cpes.id"
" FROM scap2.cpe_match_nodes, scap2.cpe_nodes_match_criteria,"
" scap2.cpe_matches, scap2.cpes"
" WHERE scap2.cpe_match_nodes.id = scap2.cpe_nodes_match_criteria.node_id"
" AND scap2.cpe_nodes_match_criteria.vulnerable = 1"
" AND scap2.cpe_nodes_match_criteria.match_criteria_id ="
" scap2.cpe_matches.match_criteria_id"
" AND scap2.cpe_matches.cpe_name_id = scap2.cpes.cpe_name_id;");
}

/**
* @brief Insert a SCAP CPE match string from JSON.
*
Expand Down Expand Up @@ -5606,6 +5627,11 @@ update_scap (gboolean reset_scap_db)
return -1;
}

g_debug ("%s: update affected_products", __func__);
setproctitle ("Syncing SCAP: Updating affected products");

update_scap_affected_products ();

g_debug ("%s: updating user defined data", __func__);

g_debug ("%s: update epss", __func__);
Expand Down

0 comments on commit 1db428c

Please sign in to comment.