Skip to content

Commit

Permalink
Remove: Drop unused deprecated_by column of CPEs
Browse files Browse the repository at this point in the history
The column has been replaced by a table to allow multiple
deprecated_by entries per CPE.
  • Loading branch information
timopollmeier committed Oct 22, 2024
1 parent 96208aa commit 8a1c684
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 25 deletions.
3 changes: 0 additions & 3 deletions src/manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*);

Expand Down
1 change: 0 additions & 1 deletion src/manage_pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,"
Expand Down
23 changes: 5 additions & 18 deletions src/manage_sql_secinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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");
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand All @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions src/manage_sql_secinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

/**
Expand All @@ -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 }, \
Expand Down

0 comments on commit 8a1c684

Please sign in to comment.