Skip to content

Commit

Permalink
Merge pull request #1003 from mattmundell/nvt-sync-remove-prefs
Browse files Browse the repository at this point in the history
Improve handling of removed NVT prefs
  • Loading branch information
mattmundell authored Mar 9, 2020
2 parents 90dd913 + 0dd72c4 commit caa3c38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Move report format dirs when inheriting user [#989](https://github.com/greenbone/gvmd/pull/989)
- Delete report format dirs when deleting user [#993](https://github.com/greenbone/gvmd/pull/993)
- Put 'lean' back to 0 for GET_RESULTS [#1001](https://github.com/greenbone/gvmd/pull/1001)
- Improve handling of removed NVT prefs [#1003](https://github.com/greenbone/gvmd/pull/1003)

### Removed
- Remove support for "All SecInfo": removal of "allinfo" for type in get_info [#790](https://github.com/greenbone/gvmd/pull/790)
Expand Down
10 changes: 6 additions & 4 deletions src/manage_sql_nvts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,6 @@ update_nvts_from_vts (entity_t *get_vts_response,
* To solve both cases, we remove all nvt_preferences. */
sql ("TRUNCATE nvt_preferences;");

preferences = NULL;
children = vts->entities;
while ((vt = first_entity (children)))
{
Expand All @@ -1437,19 +1436,21 @@ update_nvts_from_vts (entity_t *get_vts_response,

insert_nvt (nvti);

preferences = NULL;
if (update_preferences_from_vt (vt, nvti_oid (nvti), &preferences))
{
sql_rollback ();
return;
}
sql ("DELETE FROM nvt_preferences WHERE name LIKE '%s:%%';",
nvti_oid (nvti));
insert_nvt_preferences_list (preferences);
g_list_free_full (preferences, g_free);

nvti_free (nvti);
children = next_entities (children);
}

insert_nvt_preferences_list (preferences);
g_list_free_full (preferences, g_free);

set_nvts_check_time (count_new_vts, count_modified_vts);

set_nvts_feed_version (scanner_feed_version);
Expand Down Expand Up @@ -1819,6 +1820,7 @@ update_or_rebuild (int update)
if (update == 0)
{
sql ("TRUNCATE nvts;");
sql ("TRUNCATE nvt_preferences;");
set_nvts_feed_version ("0");
}

Expand Down

0 comments on commit caa3c38

Please sign in to comment.