Skip to content

Commit

Permalink
Merge pull request #2320 from greenbone/add-products-to-cves
Browse files Browse the repository at this point in the history
Change: Insert CVEs products from CPE matches table
  • Loading branch information
a-h-abdelsalam authored Nov 12, 2024
2 parents 158750f + 2ed6a1b commit b6559f8
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/manage_sql_secinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -3406,6 +3406,7 @@ handle_cve_configurations (resource_t cve_db_id, char * cve_id,
cJSON* configurations_json)
{
cJSON *configuration_item;
GString *software = g_string_new ("");

cJSON_ArrayForEach (configuration_item, configurations_json)
{
Expand Down Expand Up @@ -3495,11 +3496,30 @@ handle_cve_configurations (resource_t cve_db_id, char * cve_id,
id,
vulnerable ? 1 : 0,
quoted_match_criteria_id);


if (vulnerable)
{
iterator_t cpe_matches;
init_cpe_match_string_matches_iterator (&cpe_matches, quoted_match_criteria_id);
while (next (&cpe_matches))
g_string_append_printf (software, "%s ", cpe_matches_cpe_name (&cpe_matches));
cleanup_iterator (&cpe_matches);
}
g_free (quoted_match_criteria_id);
}
}
}
if (software->len > 0)
{
gchar *quoted_software = sql_quote (software->str);
sql ("UPDATE scap2.cves"
" SET products = '%s'"
" WHERE id = %llu;",
quoted_software, cve_db_id);
g_free (quoted_software);
}
g_string_free (software, TRUE);

return 0;
}

Expand Down

0 comments on commit b6559f8

Please sign in to comment.