Skip to content

Commit

Permalink
Merge pull request #1077 from timopollmeier/ovaldefs-delete-fix-8.0
Browse files Browse the repository at this point in the history
Fix deletion of OVAL definition data (8.0)
  • Loading branch information
mattmundell authored May 12, 2020
2 parents ee48bc2 + f70b418 commit 9a016dd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Init comment for MODIFY_PERMISSION, in case it's empty [#919](https://github.com/greenbone/gvmd/pull/919)
- Fix Verinice ISM report format and update version [#963](https://github.com/greenbone/gvmd/pull/963)
- Use right format specifier for merge_ovaldef version [#1053](https://github.com/greenbone/gvmd/pull/1053)
- Fix deletion of OVAL definition data [#1077](https://github.com/greenbone/gvmd/pull/1077)

### Removed

Expand Down
3 changes: 3 additions & 0 deletions src/manage_pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -3601,6 +3601,9 @@ manage_db_init (const gchar *name)
sql ("CREATE OR REPLACE FUNCTION scap_delete_oval ()"
" RETURNS TRIGGER AS $$"
" BEGIN"
" DELETE FROM affected_ovaldefs"
" WHERE id IN (SELECT id FROM ovaldefs"
" WHERE ovaldefs.xml_file = old.xml_file);"
" DELETE FROM ovaldefs WHERE ovaldefs.xml_file = old.xml_file;"
" RETURN old;"
" END;"
Expand Down
2 changes: 1 addition & 1 deletion src/manage_sql_secinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -4494,9 +4494,9 @@ rebuild_scap (const char *type)
|| strcasecmp (type, "ovaldef") == 0)
{
g_debug ("%s: rebuilding ovaldefs", __FUNCTION__);
sql ("DELETE FROM ovalfiles");
sql ("DELETE FROM affected_ovaldefs");
sql ("DELETE FROM ovaldefs");
sql ("DELETE FROM ovalfiles");

ret = update_scap (lockfile,
TRUE, /* ignore_last_scap_update */
Expand Down
3 changes: 3 additions & 0 deletions src/manage_sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -4437,6 +4437,9 @@ manage_db_init (const gchar *name)
sql ("CREATE TRIGGER scap.ovalfiles_delete AFTER DELETE"
" ON ovalfiles"
" BEGIN"
" DELETE FROM affected_ovaldefs"
" WHERE id IN (SELECT id FROM ovaldefs"
" WHERE ovaldefs.xml_file = old.xml_file);"
" DELETE FROM ovaldefs WHERE ovaldefs.xml_file = old.xml_file;"
" END;");

Expand Down

0 comments on commit 9a016dd

Please sign in to comment.