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

Add: functions to handle an Openvasd scan task #2262

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
29 changes: 15 additions & 14 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pkg_check_modules (LIBGVM_BASE REQUIRED libgvm_base>=22.12)
pkg_check_modules (LIBGVM_UTIL REQUIRED libgvm_util>=22.12)
pkg_check_modules (LIBGVM_OSP REQUIRED libgvm_osp>=22.12)
pkg_check_modules (LIBGVM_GMP REQUIRED libgvm_gmp>=22.12)
pkg_check_modules (LIBGVM_OPENVASD REQUIRED libgvm_openvasd>=22.12)
pkg_check_modules (GNUTLS REQUIRED gnutls>=3.2.15)
pkg_check_modules (GLIB REQUIRED glib-2.0>=2.42)
pkg_check_modules (LIBBSD REQUIRED libbsd)
Expand Down Expand Up @@ -91,7 +92,7 @@ else (WITH_LIBTHEIA)
set (OPT_THEIA_TGT "")
endif (WITH_LIBTHEIA)

include_directories (${LIBGVM_GMP_INCLUDE_DIRS}
include_directories (${LIBGVM_GMP_INCLUDE_DIRS} ${LIBGVM_OPENVASD_INCLUDE_DIRS}
${LIBGVM_BASE_INCLUDE_DIRS} ${LIBGVM_UTIL_INCLUDE_DIRS}
${LIBGVM_OSP_INCLUDE_DIRS} ${LIBBSD_INCLUDE_DIRS} ${GLIB_INCLUDE_DIRS})

Expand Down Expand Up @@ -313,34 +314,34 @@ add_executable (gvmd
target_link_libraries (gvmd m
${GNUTLS_LDFLAGS} ${GPGME_LDFLAGS} ${CMAKE_THREAD_LIBS_INIT} ${LINKER_HARDENING_FLAGS} ${LINKER_DEBUG_FLAGS}
${PostgreSQL_LIBRARIES} ${LIBBSD_LDFLAGS} ${CJSON_LDFLAGS} ${GLIB_LDFLAGS} ${GTHREAD_LDFLAGS}
${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBGVM_OSP_LDFLAGS} ${LIBGVM_GMP_LDFLAGS}
${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS} ${OPT_THEIA_TGT})
${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBGVM_OSP_LDFLAGS} ${LIBGVM_OPENVASD_LDFLAGS}
${LIBGVM_GMP_LDFLAGS} ${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS} ${OPT_THEIA_TGT})
target_link_libraries (manage-test cgreen m
${GNUTLS_LDFLAGS} ${GPGME_LDFLAGS} ${CMAKE_THREAD_LIBS_INIT} ${LINKER_HARDENING_FLAGS} ${LINKER_DEBUG_FLAGS}
${PostgreSQL_LIBRARIES} ${LIBBSD_LDFLAGS} ${CJSON_LDFLAGS} ${GLIB_LDFLAGS} ${GTHREAD_LDFLAGS}
${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBGVM_OSP_LDFLAGS} ${LIBGVM_GMP_LDFLAGS}
${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS} ${OPT_THEIA_TGT})
${LIBGVM_BASE_LDFLAGS} ${LIBGVM_OPENVASD_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBGVM_OSP_LDFLAGS}
${LIBGVM_GMP_LDFLAGS} ${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS} ${OPT_THEIA_TGT})
target_link_libraries (manage-sql-test cgreen m
${GNUTLS_LDFLAGS} ${GPGME_LDFLAGS} ${CMAKE_THREAD_LIBS_INIT} ${LINKER_HARDENING_FLAGS} ${LINKER_DEBUG_FLAGS}
${PostgreSQL_LIBRARIES} ${LIBBSD_LDFLAGS} ${CJSON_LDFLAGS} ${GLIB_LDFLAGS} ${GTHREAD_LDFLAGS}
${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBGVM_OSP_LDFLAGS} ${LIBGVM_GMP_LDFLAGS}
${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS} ${OPT_THEIA_TGT})
${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBGVM_OSP_LDFLAGS} ${LIBGVM_OPENVASD_LDFLAGS}
${LIBGVM_GMP_LDFLAGS} ${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS} ${OPT_THEIA_TGT})
target_link_libraries (manage-utils-test cgreen m
${GNUTLS_LDFLAGS} ${GPGME_LDFLAGS} ${CMAKE_THREAD_LIBS_INIT} ${LINKER_HARDENING_FLAGS} ${LINKER_DEBUG_FLAGS}
${PostgreSQL_LIBRARIES} ${LIBBSD_LDFLAGS} ${CJSON_LDFLAGS} ${GLIB_LDFLAGS} ${GTHREAD_LDFLAGS}
${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBGVM_OSP_LDFLAGS} ${LIBGVM_GMP_LDFLAGS}
${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS} ${OPT_THEIA_TGT})
${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBGVM_OSP_LDFLAGS} ${LIBGVM_OPENVASD_LDFLAGS}
${LIBGVM_GMP_LDFLAGS} ${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS} ${OPT_THEIA_TGT})
target_link_libraries (gmp-tickets-test cgreen m
${GNUTLS_LDFLAGS} ${GPGME_LDFLAGS} ${CMAKE_THREAD_LIBS_INIT} ${LINKER_HARDENING_FLAGS} ${LINKER_DEBUG_FLAGS}
${PostgreSQL_LIBRARIES} ${LIBBSD_LDFLAGS} ${CJSON_LDFLAGS} ${GLIB_LDFLAGS} ${GTHREAD_LDFLAGS}
${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBGVM_OSP_LDFLAGS} ${LIBGVM_GMP_LDFLAGS}
${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS} ${OPT_THEIA_TGT})
${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBGVM_OSP_LDFLAGS} ${LIBGVM_OPENVASD_LDFLAGS}
${LIBGVM_GMP_LDFLAGS} ${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS} ${OPT_THEIA_TGT})
target_link_libraries (utils-test cgreen m
${GNUTLS_LDFLAGS} ${GPGME_LDFLAGS} ${CMAKE_THREAD_LIBS_INIT} ${LINKER_HARDENING_FLAGS} ${LINKER_DEBUG_FLAGS}
${PostgreSQL_LIBRARIES} ${LIBBSD_LDFLAGS} ${CJSON_LDFLAGS} ${GLIB_LDFLAGS} ${GTHREAD_LDFLAGS}
${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBGVM_OSP_LDFLAGS} ${LIBGVM_GMP_LDFLAGS}
${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS} ${OPT_THEIA_TGT})
target_link_libraries (gvm-pg-server ${LIBBSD_LDFLAGS} ${GLIB_LDFLAGS} ${GTHREAD_LDFLAGS} ${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS})
${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBGVM_OSP_LDFLAGS} ${LIBGVM_OPENVASD_LDFLAGS}
${LIBGVM_GMP_LDFLAGS} ${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS} ${OPT_THEIA_TGT})
target_link_libraries (gvm-pg-server ${LIBBSD_LDFLAGS} ${GLIB_LDFLAGS} ${GTHREAD_LDFLAGS} ${LIBGVM_BASE_LDFLAGS} ${LIBGVM_OPENVASD_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS})

set_target_properties (gvmd PROPERTIES LINKER_LANGUAGE C)
set_target_properties (manage-test PROPERTIES LINKER_LANGUAGE C)
Expand Down
55 changes: 55 additions & 0 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -16816,6 +16816,61 @@ handle_get_scanners (gmp_parser_t *gmp_parser, GError **error)
g_free (desc);
g_slist_free (params);
}
if ((scanner_iterator_type (&scanners) == SCANNER_TYPE_OPENVASD)
&& get_scanners_data->get.details)
{
char *s_name = NULL, *s_ver = NULL;
char *d_name = NULL, *d_ver = NULL;
char *p_name = NULL, *p_ver = NULL, *desc = NULL;
GSList *params = NULL, *nodes;

if (!openvasd_get_details_from_iterator (&scanners, &desc, &params))
{
SENDF_TO_CLIENT_OR_FAIL
("<info><scanner><name>Openvasd</name><version>0.1</version>"
"</scanner><daemon><name>OpenVAS</name><version>23.4.1</version>"
"</daemon><protocol><name>SCANNER API</name><version>0.1"
"</version></protocol><description>Openvasd Sensor</description>");

SENDF_TO_CLIENT_OR_FAIL ("<params>");
nodes = params;
while (nodes)
{
openvasd_param_t *param = nodes->data;
g_warning("<param><id>%s</id><name>%s</name>"
"<default>%s</default><description>%s</description>"
"<type>osp_%s</type><mandatory>%d</mandatory></param>",
openvasd_param_id (param), openvasd_param_name(param),
openvasd_param_default (param), openvasd_param_desc (param),
openvasd_param_type (param), openvasd_param_mandatory (param));
SENDF_TO_CLIENT_OR_FAIL
("<param><id>%s</id><name>%s</name>"
"<default>%s</default><description>%s</description>"
"<type>osp_%s</type><mandatory>%d</mandatory></param>",
openvasd_param_id (param), openvasd_param_name(param),
openvasd_param_default (param), openvasd_param_desc (param),
openvasd_param_type (param), 1);

osp_param_free (nodes->data);
nodes = nodes->next;
}
SENDF_TO_CLIENT_OR_FAIL ("</params></info>");
}
else
SENDF_TO_CLIENT_OR_FAIL
("<info><scanner><name/><version/></scanner>"
"<daemon><name/><version/></daemon>"
"<protocol><name/><version/></protocol><description/><params/>"
"</info>");
g_free (s_name);
g_free (s_ver);
g_free (d_name);
g_free (d_ver);
g_free (p_name);
g_free (p_ver);
g_free (desc);
g_slist_free (params);
}
else if (get_scanners_data->get.details)
{
SENDF_TO_CLIENT_OR_FAIL
Expand Down
10 changes: 9 additions & 1 deletion src/gvmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1106,11 +1106,15 @@ handle_sigabrt_simple (int signal)
static int
update_nvt_cache_osp (const gchar *update_socket)
{
#ifdef OPENVASD
setproctitle ("Openvasd: Updating NVT cache");
#else
setproctitle ("OSP: Updating NVT cache");

#endif
return manage_update_nvts_osp (update_socket);
}


/**
* @brief Update NVT cache in forked child, retrying if scanner loading.
*
Expand Down Expand Up @@ -2836,6 +2840,8 @@ gvmd (int argc, char** argv, char *env[])
type = SCANNER_TYPE_OPENVAS;
else if (!strcasecmp (scanner_type, "OSP-Sensor"))
type = SCANNER_TYPE_OSP_SENSOR;
else if (!strcasecmp (scanner_type, "Openvasd"))
type = SCANNER_TYPE_OPENVASD;
else
{
type = atoi (scanner_type);
Expand Down Expand Up @@ -2878,6 +2884,8 @@ gvmd (int argc, char** argv, char *env[])
type = SCANNER_TYPE_OPENVAS;
else if (!strcasecmp (scanner_type, "OSP-Sensor"))
type = SCANNER_TYPE_OSP_SENSOR;
else if (!strcasecmp (scanner_type, "Openvasd"))
type = SCANNER_TYPE_OPENVASD;
else
{
type = atoi (scanner_type);
Expand Down
Loading
Loading