From 27d6c3b1b9b3683d07dab275277791e739476ec0 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Fri, 18 Oct 2024 10:52:27 +0200 Subject: [PATCH] Remove: Drop unused deprecated_by column of CPEs The column has been replaced by a table to allow multiple deprecated_by entries per CPE. --- src/manage.h | 3 --- src/manage_pg.c | 1 - src/manage_sql_secinfo.c | 23 +++++------------------ src/manage_sql_secinfo.h | 5 ++--- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/manage.h b/src/manage.h index 9d2434292..a2cfc5775 100644 --- a/src/manage.h +++ b/src/manage.h @@ -3372,9 +3372,6 @@ cpe_info_iterator_cve_refs (iterator_t*); const char* cpe_info_iterator_cpe_name_id (iterator_t*); -const char* -cpe_info_iterator_deprecated_by_id (iterator_t*); - gchar * cpe_details_xml (const char*); diff --git a/src/manage_pg.c b/src/manage_pg.c index 0cad6c0af..4bc218524 100644 --- a/src/manage_pg.c +++ b/src/manage_pg.c @@ -3525,7 +3525,6 @@ manage_db_init (const gchar *name) " modification_time integer," " title text," " status text," - " deprecated_by_id TEXT," " severity DOUBLE PRECISION DEFAULT 0," " cve_refs INTEGER DEFAULT 0," " nvd_id text," diff --git a/src/manage_sql_secinfo.c b/src/manage_sql_secinfo.c index d8bbe4ec3..f0a87c63c 100644 --- a/src/manage_sql_secinfo.c +++ b/src/manage_sql_secinfo.c @@ -571,17 +571,6 @@ DEF_ACCESS (cpe_info_iterator_title, GET_ITERATOR_COLUMN_COUNT); */ DEF_ACCESS (cpe_info_iterator_deprecated, GET_ITERATOR_COLUMN_COUNT + 1); -/** - * @brief Get the first CPE the current one is deprecated by - * from a CPE iterator. - * - * @param[in] iterator Iterator. - * - * @return The first CPE the current one is deprecated by, - * or NULL if iteration is complete. Freed by cleanup_iterator. - */ -DEF_ACCESS (cpe_info_iterator_deprecated_by_id, GET_ITERATOR_COLUMN_COUNT + 2); - /** * @brief Get the highest severity Score of all CVE's referencing this cpe. * @@ -590,7 +579,7 @@ DEF_ACCESS (cpe_info_iterator_deprecated_by_id, GET_ITERATOR_COLUMN_COUNT + 2); * @return The highest severity score of the CPE, * or NULL if iteration is complete. Freed by cleanup_iterator. */ -DEF_ACCESS (cpe_info_iterator_severity, GET_ITERATOR_COLUMN_COUNT + 3); +DEF_ACCESS (cpe_info_iterator_severity, GET_ITERATOR_COLUMN_COUNT + 2); /** * @brief Get the Number of CVE's referencing this cpe from a CPE iterator. @@ -600,7 +589,7 @@ DEF_ACCESS (cpe_info_iterator_severity, GET_ITERATOR_COLUMN_COUNT + 3); * @return The Number of references to the CPE, or NULL if iteration is * complete. Freed by cleanup_iterator. */ -DEF_ACCESS (cpe_info_iterator_cve_refs, GET_ITERATOR_COLUMN_COUNT + 4); +DEF_ACCESS (cpe_info_iterator_cve_refs, GET_ITERATOR_COLUMN_COUNT + 3); /** * @brief Get the NVD assigned cpeNameId for this CPE. @@ -610,7 +599,7 @@ DEF_ACCESS (cpe_info_iterator_cve_refs, GET_ITERATOR_COLUMN_COUNT + 4); * @return The NVD ID of this CPE, or NULL if iteration is * complete. Freed by cleanup_iterator. */ -DEF_ACCESS (cpe_info_iterator_cpe_name_id, GET_ITERATOR_COLUMN_COUNT + 5); +DEF_ACCESS (cpe_info_iterator_cpe_name_id, GET_ITERATOR_COLUMN_COUNT + 4); /** * @brief Get the XML details / raw data for a given CPE ID. @@ -2373,7 +2362,6 @@ handle_json_cpe_item (inserts_t *inserts, inserts_t *deprecated_by_inserts, if (deprecated) { cJSON *deprecated_by_array, *deprecated_by_item; - char *deprecated_by_id; gchar *quoted_deprecated_by_id; deprecated_by_array = cJSON_GetObjectItemCaseSensitive (cpe_item, "deprecatedBy"); @@ -2394,6 +2382,7 @@ handle_json_cpe_item (inserts_t *inserts, inserts_t *deprecated_by_inserts, cJSON_ArrayForEach (deprecated_by_item, deprecated_by_array) { + char *deprecated_by_id; deprecated_by_id = json_object_item_string (deprecated_by_item, "cpeName"); if (deprecated_by_id == NULL) @@ -2565,7 +2554,6 @@ update_scap_cpes_from_json_file (const gchar *path) " creation_time = EXCLUDED.creation_time," " modification_time = EXCLUDED.modification_time," " deprecated = EXCLUDED.deprecated," - " deprecated_by_id = EXCLUDED.deprecated_by_id," " cpe_name_id = EXCLUDED.cpe_name_id"); inserts_init (&deprecated_by_inserts, 10, @@ -2705,7 +2693,7 @@ update_scap_cpes_from_xml_file (const gchar *path) setting_secinfo_sql_buffer_threshold_bytes (), "INSERT INTO scap2.cpes" " (uuid, name, title, creation_time," - " modification_time, status, deprecated_by_id," + " modification_time, status," " nvd_id)" " VALUES", " ON CONFLICT (uuid) DO UPDATE" @@ -2714,7 +2702,6 @@ update_scap_cpes_from_xml_file (const gchar *path) " creation_time = EXCLUDED.creation_time," " modification_time = EXCLUDED.modification_time," " status = EXCLUDED.status," - " deprecated_by_id = EXCLUDED.deprecated_by_id," " nvd_id = EXCLUDED.nvd_id"); cpe_item = xml_file_iterator_next (file_iterator, &error_message); diff --git a/src/manage_sql_secinfo.h b/src/manage_sql_secinfo.h index 656f240eb..71f00c091 100644 --- a/src/manage_sql_secinfo.h +++ b/src/manage_sql_secinfo.h @@ -101,8 +101,8 @@ * @brief Filter columns for CVE iterator. */ #define CPE_INFO_ITERATOR_FILTER_COLUMNS \ - { GET_ITERATOR_FILTER_COLUMNS, "title", "status", \ - "deprecated_by_id", "severity", "cves", "cpe_name_id", \ + { GET_ITERATOR_FILTER_COLUMNS, "title", "deprecated", \ + "severity", "cves", "cpe_name_id", \ NULL } /** @@ -115,7 +115,6 @@ { "0", NULL, KEYWORD_TYPE_INTEGER }, \ { "title", NULL, KEYWORD_TYPE_STRING }, \ { "deprecated", NULL, KEYWORD_TYPE_INTEGER }, \ - { "deprecated_by_id", NULL, KEYWORD_TYPE_INTEGER }, \ { "severity", NULL, KEYWORD_TYPE_DOUBLE }, \ { "cve_refs", "cves", KEYWORD_TYPE_INTEGER }, \ { "cpe_name_id", NULL, KEYWORD_TYPE_STRING }, \