Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: Insert CVEs products from CPE matches table #2320

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indented 2 to far (compare with the return below). Made me think that the free was happening inside the iteration above.

I find this cJSON_ArrayForEach style awkward, especially when the body is so large. I think this style makes it tricky for the auto indentation in editors.


return 0;
}

Expand Down
Loading