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

Clean up NVTs set to name in cleanup-result-nvts #1039

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Change setting UUID to correct length [#1018](https://github.com/greenbone/gvmd/pull/1018)
- Change licence to AGPL-3.0-or-later [#1026](https://github.com/greenbone/gvmd/pull/1026)
- Count only best OS matches for OS asset hosts [#1029](https://github.com/greenbone/gvmd/pull/1029)
- Clean up NVTs set to name in cleanup-result-nvts [#1039](https://github.com/greenbone/gvmd/pull/1039)

### Fixed
- Add NULL check in nvts_feed_version_epoch [#768](https://github.com/greenbone/gvmd/pull/768)
Expand Down
11 changes: 11 additions & 0 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -23336,6 +23336,17 @@ cleanup_result_nvts ()
GArray *affected;
int index;

g_debug ("%s: Cleaning up results with wrong nvt ids", __func__);
sql ("UPDATE results"
" SET nvt = (SELECT oid FROM nvts WHERE name = nvt),"
" result_nvt = NULL"
" WHERE nvt IN (SELECT name FROM nvts WHERE name != oid);");

g_debug ("%s: Cleaning up result_nvts entries with wrong nvt ids",
__func__);
sql ("DELETE FROM result_nvts"
" WHERE nvt IN (SELECT name FROM nvts WHERE name != oid);");

g_debug ("%s: Creating missing result_nvts entries", __func__);
sql ("INSERT INTO result_nvts (nvt)"
" SELECT DISTINCT nvt FROM results ON CONFLICT (nvt) DO NOTHING;");
Expand Down