Skip to content

Commit

Permalink
Merge pull request #1550 from timopollmeier/sentry-integration
Browse files Browse the repository at this point in the history
Add basic Sentry integration and logging
  • Loading branch information
timopollmeier authored Jun 18, 2021
2 parents 28bddf8 + 81505aa commit 5622dbe
Show file tree
Hide file tree
Showing 11 changed files with 259 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Added
- Add a new modification_time column to reports [#1513](https://github.com/greenbone/gvmd/pull/1513), [#1519](https://github.com/greenbone/gvmd/pull/1519)
- Add basic Sentry integration and logging [#1550](https://github.com/greenbone/gvmd/pull/1550)

### Changed
- Use pg-gvm extension for C PostgreSQL functions [#1400](https://github.com/greenbone/gvmd/pull/1400), [#1453](https://github.com/greenbone/gvmd/pull/1453)
Expand Down
9 changes: 8 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ add_executable (manage-utils-test
EXCLUDE_FROM_ALL
manage_utils_tests.c

debug_utils.c
gvmd.c gmpd.c
manage.c sql.c
manage_acl.c manage_configs.c manage_get.c
Expand All @@ -123,6 +124,7 @@ add_executable (manage-test
EXCLUDE_FROM_ALL
manage_tests.c

debug_utils.c
gvmd.c gmpd.c
manage_utils.c sql.c
manage_acl.c manage_configs.c manage_get.c
Expand All @@ -147,6 +149,7 @@ add_executable (manage-sql-test
EXCLUDE_FROM_ALL
manage_sql_tests.c

debug_utils.c
gvmd.c gmpd.c
manage_utils.c manage.c sql.c
manage_acl.c manage_configs.c manage_get.c
Expand All @@ -171,6 +174,7 @@ add_executable (gmp-tickets-test
EXCLUDE_FROM_ALL
gmp_tickets_tests.c

debug_utils.c
gvmd.c gmpd.c
manage_utils.c manage.c sql.c
manage_acl.c manage_configs.c manage_get.c
Expand All @@ -194,6 +198,7 @@ add_executable (utils-test
EXCLUDE_FROM_ALL
utils_tests.c

debug_utils.c
gvmd.c gmpd.c
manage_utils.c manage.c sql.c
manage_acl.c manage_configs.c manage_get.c
Expand All @@ -219,7 +224,9 @@ add_custom_target (tests
gmp-tickets-test manage-test manage-sql-test manage-utils-test utils-test)

add_executable (gvmd
main.c gvmd.c gmpd.c
main.c gvmd.c
debug_utils.c
gmpd.c
manage_utils.c manage.c sql.c
manage_acl.c manage_configs.c manage_get.c
manage_port_lists.c manage_preferences.c
Expand Down
52 changes: 52 additions & 0 deletions src/debug_utils.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* Copyright (C) 2021 Greenbone Networks GmbH
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @file debug_utils.c
* @brief Debug utilties and Sentry integration
*/

#include "debug_utils.h"

#include <gvm/base/logging.h>
#include <stdio.h> /* for snprintf */
#include <stdlib.h>

/**
* @brief Initialize Sentry using the current gvmd version and DSN.
*
* The DSN is set via the environment variable SENTRY_DSN_GVMD.
*
* @return 1 if sentry support was enabled, 0 if not.
*/
int
init_sentry (void)
{
char *sentry_dsn_gvmd = NULL;
char version[96];

snprintf (version, sizeof (version), "gvmd@%s", GVMD_VERSION);

sentry_dsn_gvmd = getenv ("SENTRY_DSN_GVMD");
if (gvm_has_sentry_support () && sentry_dsn_gvmd && *sentry_dsn_gvmd)
{
gvm_sentry_init (sentry_dsn_gvmd, version);
return 1;
}
return 0;
}
33 changes: 33 additions & 0 deletions src/debug_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* Copyright (C) 2021 Greenbone Networks GmbH
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


/**
* @file debug_utils.h
* @brief Headers for debug utilties and Sentry integration
*/

#ifndef _OPENVAS_DEBUG_UTILS_H
#define _OPENVAS_DEBUG_UTILS_H

#include <gvm/base/gvm_sentry.h> /* for gvm_sentry_init */

int
init_sentry (void);

#endif
Loading

0 comments on commit 5622dbe

Please sign in to comment.