Skip to content

Commit

Permalink
Merge branch 'cpes-from-json' into cves-from-json
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h-abdelsalam committed Oct 2, 2024
2 parents 271bd1e + 12b44f3 commit 39f25b8
Show file tree
Hide file tree
Showing 7 changed files with 725 additions and 83 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ include (CPack)

set (GVMD_DATABASE_VERSION 256)

set (GVMD_SCAP_DATABASE_VERSION 21)
set (GVMD_SCAP_DATABASE_VERSION 22)

set (GVMD_CERT_DATABASE_VERSION 8)

Expand Down
37 changes: 29 additions & 8 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -13421,24 +13421,35 @@ handle_get_info (gmp_parser_t *gmp_parser, GError **error)
"<title>%s</title>",
cpe_info_iterator_title (&info));
xml_string_append (result,
"<nvd_id>%s</nvd_id>"
"<cpe_name_id>%s</cpe_name_id>"
"<severity>%s</severity>"
"<cve_refs>%s</cve_refs>"
"<status>%s</status>",
cpe_info_iterator_nvd_id (&info)
? cpe_info_iterator_nvd_id (&info)
"<deprecated>%s</deprecated>",
cpe_info_iterator_cpe_name_id (&info)
? cpe_info_iterator_cpe_name_id (&info)
: "",
cpe_info_iterator_severity (&info)
? cpe_info_iterator_severity (&info)
: "",
cpe_info_iterator_cve_refs (&info),
cpe_info_iterator_status (&info)
? cpe_info_iterator_status (&info)
: "");
cpe_info_iterator_deprecated (&info)
? cpe_info_iterator_deprecated (&info)
: "0");

if (get_info_data->details == 1)
{
iterator_t cves;
iterator_t deprecated_by, cves, refs;

init_cpe_deprecated_by_iterator (&deprecated_by,
get_iterator_name (&info));
while (next (&deprecated_by))
{
xml_string_append (result,
"<deprecated_by cpe_id=\"%s\"/>",
cpe_deprecated_by_iterator_deprecated_by
(&deprecated_by));
}

g_string_append (result, "<cves>");
init_cpe_cve_iterator (&cves, get_iterator_name (&info), 0, NULL);
while (next (&cves))
Expand Down Expand Up @@ -13466,6 +13477,16 @@ handle_get_info (gmp_parser_t *gmp_parser, GError **error)
: "");
cleanup_iterator (&cves);
g_string_append (result, "</cves>");

g_string_append (result, "<references>");
init_cpe_reference_iterator (&refs, get_iterator_name (&info));
while (next (&refs))
xml_string_append (result,
"<reference href=\"%s\">%s</reference>",
cpe_reference_iterator_href (&refs),
cpe_reference_iterator_type (&refs));
cleanup_iterator (&refs);
g_string_append (result, "</references>");
}
}
else if (g_strcmp0 ("cve", get_info_data->type) == 0)
Expand Down
24 changes: 20 additions & 4 deletions src/manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -3384,6 +3384,12 @@ manage_scap_update_time ();

/* CPE. */

void
init_cpe_deprecated_by_iterator (iterator_t *, const char *);

const char *
cpe_deprecated_by_iterator_deprecated_by (iterator_t *);

void
init_cpe_cve_iterator (iterator_t *, const char *, int, const char *);

Expand All @@ -3400,23 +3406,33 @@ const char*
cpe_info_iterator_title (iterator_t*);

const char*
cpe_info_iterator_status (iterator_t*);
cpe_info_iterator_deprecated (iterator_t*);

const char *
cpe_info_iterator_severity (iterator_t*);

const char*
cpe_info_iterator_deprecated_by_id (iterator_t*);
cpe_info_iterator_cve_refs (iterator_t*);

const char*
cpe_info_iterator_cve_refs (iterator_t*);
cpe_info_iterator_cpe_name_id (iterator_t*);

const char*
cpe_info_iterator_nvd_id (iterator_t*);
cpe_info_iterator_deprecated_by_id (iterator_t*);

gchar *
cpe_details_xml (const char*);

void
init_cpe_reference_iterator (iterator_t *, const char *);

const char*
cpe_reference_iterator_href (iterator_t *);

const char*
cpe_reference_iterator_type (iterator_t *);


/* CVE. */

const char*
Expand Down
17 changes: 15 additions & 2 deletions src/manage_pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -3527,10 +3527,23 @@ manage_db_init (const gchar *name)
" modification_time integer,"
" title text,"
" status text,"
" deprecated_by_id INTEGER,"
" deprecated_by_id TEXT,"
" severity DOUBLE PRECISION DEFAULT 0,"
" cve_refs INTEGER DEFAULT 0,"
" nvd_id text);");
" nvd_id text,"
" deprecated integer,"
" cpe_name_id text);");

sql ("CREATE TABLE scap2.cpe_refs"
" (id SERIAL PRIMARY KEY,"
" cpe INTEGER,"
" ref TEXT,"
" type TEXT);");

sql ("CREATE TABLE scap2.cpes_deprecated_by"
" (id SERIAL PRIMARY KEY,"
" cpe TEXT,"
" deprecated_by TEXT);");

sql ("CREATE TABLE scap2.cpe_match_nodes"
" (id SERIAL PRIMARY KEY,"
Expand Down
Loading

0 comments on commit 39f25b8

Please sign in to comment.