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

Resolve tags: solution and solution_type #681

Merged
merged 8 commits into from
Aug 11, 2019
24 changes: 23 additions & 1 deletion src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10170,10 +10170,30 @@ results_xml_append_nvt (iterator_t *results, GString *buffer, int cert_loaded)
else
{
const char *cvss_base = result_iterator_nvt_cvss_base (results);
GString *tags = g_string_new (result_iterator_nvt_tag (results));

if (!cvss_base && !strcmp (oid, "0"))
cvss_base = "0.0";

/* Add the elements that are expected as part of the pipe-separated tag list
* via API although internally already explicitely stored. Once the API is
* extended to have these elements explicitely, they do not need to be
* added to this string anymore. */
if (result_iterator_nvt_solution (results))
{
if (tags->str)
g_string_append_printf (tags, "|solution=%s", result_iterator_nvt_solution (results));
else
g_string_append_printf (tags, "solution=%s", result_iterator_nvt_solution (results));
}
if (result_iterator_nvt_solution_type (results))
{
if (tags->str)
g_string_append_printf (tags, "|solution_type=%s", result_iterator_nvt_solution_type (results));
Copy link
Contributor

Choose a reason for hiding this comment

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

These lines are getting long. Timo and I still pretty much always stick to the old 80 characters rule.

else
g_string_append_printf (tags, "solution_type=%s", result_iterator_nvt_solution_type (results));
}

buffer_xml_append_printf (buffer,
"<nvt oid=\"%s\">"
"<type>nvt</type>"
Expand All @@ -10185,14 +10205,16 @@ results_xml_append_nvt (iterator_t *results, GString *buffer, int cert_loaded)
result_iterator_nvt_name (results) ?: oid,
result_iterator_nvt_family (results) ?: "",
cvss_base ?: "",
result_iterator_nvt_tag (results) ?: "");
tags->str ?: "");

buffer_xml_append_printf (buffer, "<refs>");
result_iterator_nvt_refs_append (buffer, results);
results_xml_append_cert (buffer, oid, cert_loaded,
result_iterator_has_cert_bunds (results),
result_iterator_has_dfn_certs (results));
buffer_xml_append_printf (buffer, "</refs>");

g_string_free (tags, TRUE);
}

}
Expand Down