Skip to content

Commit

Permalink
Merge branch 'master' into get-vulns-fail
Browse files Browse the repository at this point in the history
  • Loading branch information
timopollmeier authored Aug 15, 2019
2 parents 464f2e6 + a176c3a commit 70d0d7b
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 2,517 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]

### Added
- Added TLS certificates as a new resource type [#585](https://github.com/greenbone/gvmd/pull/585) [#663](https://github.com/greenbone/gvmd/pull/663) [#673](https://github.com/greenbone/gvmd/pull/673)
- Added TLS certificates as a new resource type [#585](https://github.com/greenbone/gvmd/pull/585) [#663](https://github.com/greenbone/gvmd/pull/663) [#673](https://github.com/greenbone/gvmd/pull/673) [#695](https://github.com/greenbone/gvmd/pull/695)
- Update NVTs via OSP [#392](https://github.com/greenbone/gvmd/pull/392) [#609](https://github.com/greenbone/gvmd/pull/609) [#626](https://github.com/greenbone/gvmd/pull/626)
- Handle addition of ID to NVT preferences. [#413](https://github.com/greenbone/gvmd/pull/413)
- Add setting 'OMP Slave Check Period' [#491](https://github.com/greenbone/gvmd/pull/491)
Expand Down Expand Up @@ -39,7 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix an issue in getting the reports from GMP scanners [#659](https://github.com/greenbone/gvmd/pull/659) [#665](https://github.com/greenbone/gvmd/pull/665)
- Fix GET_SYSTEM_REPORTS using slave_id [#668](https://github.com/greenbone/gvmd/pull/668)
- Fix RAW_DATA when calling GET_INFO with type NVT without attributes name or info_id [#682](https://github.com/greenbone/gvmd/pull/682)
- Fix ORPHAN calculation in GET_TICKETS [#684](https://github.com/greenbone/gvmd/pull/684)
- Fix ORPHAN calculations in GET_TICKETS [#684](https://github.com/greenbone/gvmd/pull/684) [#692](https://github.com/greenbone/gvmd/pull/692)
- Fix assignment of orphaned tickets to the current user [#685](https://github.com/greenbone/gvmd/pull/685)
- Fix response from GET_VULNS when given vuln_id does not exists [#696](https://github.com/greenbone/gvmd/pull/696)

Expand Down
2,507 changes: 0 additions & 2,507 deletions CHANGES-OLD

This file was deleted.

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ include (CPack)

## Variables

set (GVMD_DATABASE_VERSION 216)
set (GVMD_DATABASE_VERSION 217)

set (GVMD_SCAP_DATABASE_VERSION 15)

Expand Down
41 changes: 41 additions & 0 deletions src/manage_migrators.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,46 @@ migrate_215_to_216 ()
return 0;
}

/**
* @brief Migrate the database from version 216 to version 217.
*
* @return 0 success, -1 error.
*/
int
migrate_216_to_217 ()
{
sql_begin_immediate ();

/* Ensure that the database is currently version 216. */

if (manage_db_version () != 216)
{
sql_rollback ();
return -1;
}

/* Update the database. */

/* Ticket references to reports and results are now cleared when the
* report is deleted. */

sql ("UPDATE tickets"
" SET report = -1"
" WHERE report NOT IN (SELECT id FROM reports);");

sql ("UPDATE ticket_results"
" SET report = -1, result = -1"
" WHERE report NOT IN (SELECT id FROM reports);");

/* Set the database version to 217. */

set_db_version (217);

sql_commit ();

return 0;
}

#undef UPDATE_DASHBOARD_SETTINGS

/**
Expand All @@ -1266,6 +1306,7 @@ static migrator_t database_migrators[] = {
{214, migrate_213_to_214},
{215, migrate_214_to_215},
{216, migrate_215_to_216},
{217, migrate_216_to_217},
/* End marker. */
{-1, NULL}};

Expand Down
1 change: 1 addition & 0 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -26242,6 +26242,7 @@ delete_report_internal (report_t report)

permissions_set_orphans ("report", report, LOCATION_TABLE);
tags_remove_resource ("report", report, LOCATION_TABLE);
tickets_remove_report (report);

/* Update the task state. */

Expand Down
26 changes: 24 additions & 2 deletions src/manage_sql_tickets.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ ticket_status_name (ticket_status_t status)
{ "iso_time (fix_verified_time)", NULL, KEYWORD_TYPE_STRING }, \
{ "fix_verified_time", "fix_verified", KEYWORD_TYPE_INTEGER }, \
{ \
"(task = -1)", \
"(task = -1 OR report = -1)", \
"orphan", \
KEYWORD_TYPE_INTEGER \
}, \
Expand Down Expand Up @@ -236,7 +236,7 @@ ticket_status_name (ticket_status_t status)
{ "iso_time (fix_verified_time)", NULL, KEYWORD_TYPE_STRING }, \
{ "fix_verified_time", "fix_verified", KEYWORD_TYPE_INTEGER }, \
{ \
"(task = -1)", \
"(task = -1 OR report = -1)", \
"orphan", \
KEYWORD_TYPE_INTEGER \
}, \
Expand Down Expand Up @@ -543,6 +543,7 @@ init_ticket_result_iterator (iterator_t *iterator, const gchar *ticket_id,
" result_uuid"
" FROM ticket_results%s"
" WHERE ticket = %llu"
" AND report > 0"
" ORDER BY id;",
trash ? "_trash" : "",
ticket);
Expand Down Expand Up @@ -1624,6 +1625,27 @@ tickets_remove_task (task_t task)
sql ("UPDATE tickets_trash SET task = -1 WHERE task = %llu;", task);
}

/**
* @brief Remove a report from all tickets.
*
* @param[in] report Report.
*/
void
tickets_remove_report (report_t report)
{
sql ("UPDATE tickets SET report = -1 WHERE report = %llu;", report);
sql ("UPDATE tickets_trash SET report = -1 WHERE report = %llu;", report);

sql ("UPDATE ticket_results"
" SET report = -1, result = -1"
" WHERE report = %llu;",
report);
sql ("UPDATE ticket_results_trash"
" SET report = -1, result = -1"
" WHERE report = %llu;",
report);
}

/**
* @brief Remove all of a user's tasks from all tickets.
*
Expand Down
3 changes: 3 additions & 0 deletions src/manage_sql_tickets.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ inherit_tickets (user_t, user_t);
void
tickets_remove_task (task_t);

void
tickets_remove_report (report_t);

void
tickets_remove_tasks_user (user_t);

Expand Down
6 changes: 1 addition & 5 deletions src/manage_sql_tls_certificates.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,11 +826,7 @@ delete_tls_certificates_user (user_t user)
{
/* Regular tls_certificate. */

sql ("DELETE FROM tls_certificate WHERE owner = %llu;", user);

/* Trash tls_certificate. */

sql ("DELETE FROM tls_certificate_trash WHERE owner = %llu;", user);
sql ("DELETE FROM tls_certificates WHERE owner = %llu;", user);
}

/**
Expand Down

0 comments on commit 70d0d7b

Please sign in to comment.