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

Auto sync predefined port lists from feed #952

Merged
merged 18 commits into from
Jan 23, 2020
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add "Base" scan config [#862](https://github.com/greenbone/gvmd/pull/862)
- Add setting "BPM Data" [#915](https://github.com/greenbone/gvmd/pull/915)
- Automatically load predefined configs from the feed [#931](https://github.com/greenbone/gvmd/pull/931) [#933](https://github.com/greenbone/gvmd/pull/933) [#934](https://github.com/greenbone/gvmd/pull/934)
- Automatically load predefined port lists from the feed [#950](https://github.com/greenbone/gvmd/pull/950)
- Automatically load predefined port lists from the feed [#950](https://github.com/greenbone/gvmd/pull/950) [#952](https://github.com/greenbone/gvmd/pull/952)

### Changed
- Update SCAP and CERT feed info in sync scripts [#810](https://github.com/greenbone/gvmd/pull/810)
Expand Down
32 changes: 8 additions & 24 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,9 @@ add_executable (manage-utils-test

gvmd.c gmpd.c
manage.c sql.c
manage_ranges_all_tcp_nmap_5_51_top_100.c
manage_ranges_all_tcp_nmap_5_51_top_1000.c
manage_ranges_iana_tcp_2012.c manage_ranges_iana_tcp_udp_2012.c
manage_ranges_nmap_5_51_top_2000_top_100.c
manage_acl.c manage_configs.c manage_config_discovery.c
manage_config_host_discovery.c manage_config_system_discovery.c
manage_port_lists.c
manage_sql.c manage_sql_nvts.c manage_sql_secinfo.c
manage_sql_port_lists.c manage_sql_configs.c
manage_sql_tickets.c manage_sql_tls_certificates.c
Expand All @@ -118,12 +115,9 @@ add_executable (manage-test

gvmd.c gmpd.c
manage_utils.c sql.c
manage_ranges_all_tcp_nmap_5_51_top_100.c
manage_ranges_all_tcp_nmap_5_51_top_1000.c
manage_ranges_iana_tcp_2012.c manage_ranges_iana_tcp_udp_2012.c
manage_ranges_nmap_5_51_top_2000_top_100.c
manage_acl.c manage_configs.c manage_config_discovery.c
manage_config_host_discovery.c manage_config_system_discovery.c
manage_port_lists.c
manage_sql.c manage_sql_nvts.c manage_sql_secinfo.c
manage_sql_port_lists.c manage_sql_configs.c
manage_sql_tickets.c manage_sql_tls_certificates.c
Expand All @@ -142,12 +136,9 @@ add_executable (gmp-tickets-test

gvmd.c gmpd.c
manage_utils.c manage.c sql.c
manage_ranges_all_tcp_nmap_5_51_top_100.c
manage_ranges_all_tcp_nmap_5_51_top_1000.c
manage_ranges_iana_tcp_2012.c manage_ranges_iana_tcp_udp_2012.c
manage_ranges_nmap_5_51_top_2000_top_100.c
manage_acl.c manage_configs.c manage_config_discovery.c
manage_config_host_discovery.c manage_config_system_discovery.c
manage_port_lists.c
manage_sql.c manage_sql_nvts.c manage_sql_secinfo.c
manage_sql_port_lists.c manage_sql_configs.c
manage_sql_tickets.c manage_sql_tls_certificates.c
Expand All @@ -173,12 +164,9 @@ add_custom_target (tests
add_executable (gvmd
main.c gvmd.c gmpd.c
manage_utils.c manage.c sql.c
manage_ranges_all_tcp_nmap_5_51_top_100.c
manage_ranges_all_tcp_nmap_5_51_top_1000.c
manage_ranges_iana_tcp_2012.c manage_ranges_iana_tcp_udp_2012.c
manage_ranges_nmap_5_51_top_2000_top_100.c
manage_acl.c manage_configs.c manage_config_discovery.c
manage_config_host_discovery.c manage_config_system_discovery.c
manage_port_lists.c
manage_sql.c manage_sql_nvts.c manage_sql_secinfo.c
manage_sql_port_lists.c manage_sql_configs.c
manage_sql_tickets.c manage_sql_tls_certificates.c
Expand Down Expand Up @@ -210,9 +198,10 @@ target_link_libraries (gmp-tickets-test cgreen m
${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBGVM_OSP_LDFLAGS} ${LIBGVM_GMP_LDFLAGS}
${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS})
target_link_libraries (utils-test cgreen m
${CMAKE_THREAD_LIBS_INIT} ${LINKER_HARDENING_FLAGS} ${LINKER_DEBUG_FLAGS}
${GLIB_LDFLAGS} ${GTHREAD_LDFLAGS}
${LINKER_HARDENING_FLAGS})
${GNUTLS_LDFLAGS} ${GPGME_LDFLAGS} ${CMAKE_THREAD_LIBS_INIT} ${LINKER_HARDENING_FLAGS} ${LINKER_DEBUG_FLAGS}
${PostgreSQL_LIBRARIES} ${GLIB_LDFLAGS} ${GTHREAD_LDFLAGS}
${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBGVM_OSP_LDFLAGS} ${LIBGVM_GMP_LDFLAGS}
${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS})
target_link_libraries (gvm-pg-server ${GLIB_LDFLAGS} ${GTHREAD_LDFLAGS} ${LIBGVM_BASE_LDFLAGS} ${LIBGVM_UTIL_LDFLAGS} ${LIBICAL_LDFLAGS} ${LINKER_HARDENING_FLAGS})

set_target_properties (gvmd PROPERTIES LINKER_LANGUAGE C)
Expand Down Expand Up @@ -376,11 +365,6 @@ set (C_FILES "${CMAKE_CURRENT_SOURCE_DIR}/gvmd.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_config_discovery.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_config_host_discovery.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_config_system_discovery.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_ranges_all_tcp_nmap_5_51_top_100.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_ranges_all_tcp_nmap_5_51_top_1000.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_ranges_iana_tcp_2012.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_ranges_iana_tcp_udp_2012.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_ranges_nmap_5_51_top_2000_top_100.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_sql.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_sql_configs.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_sql_nvts.c"
Expand Down
2 changes: 0 additions & 2 deletions src/gmp_port_lists.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ parse_port_list_entity (entity_t port_list, const char **port_list_id,

children = next_entities (children);
}

array_terminate (*ranges);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "manage.h"
#include "manage_acl.h"
#include "manage_configs.h"
#include "manage_port_lists.h"
#include "manage_sql.h"
#include "manage_sql_secinfo.h"
#include "manage_sql_nvts.h"
Expand Down Expand Up @@ -7144,6 +7145,7 @@ manage_sync (sigset_t *sigmask_current,
manage_sync_scap (sigmask_current);
manage_sync_cert (sigmask_current);
manage_sync_configs ();
manage_sync_port_lists ();
}

/**
Expand Down
45 changes: 1 addition & 44 deletions src/manage_configs.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "manage_configs.h"
#include "manage_sql.h"
#include "manage_sql_configs.h"
#include "utils.h"

#include <errno.h>
#include <glib.h>
Expand Down Expand Up @@ -194,50 +195,6 @@ create_feed_config_permissions (const gchar *config_id)
g_free (roles);
}

/**
* @brief Create entity from XML file.
*
* @param[in] path Path to XML.
* @param[out] config Config tree.
*
* @return 0 success, -1 error.
*/
static int
parse_xml_file (const gchar *path, entity_t *config)
{
gsize xml_len;
char *xml;
GError *error;

/* Buffer the file. */

error = NULL;
g_file_get_contents (path,
&xml,
&xml_len,
&error);
if (error)
{
g_warning ("%s: Failed to read file: %s",
__func__,
error->message);
g_error_free (error);
return -1;
}

/* Parse the buffer into an entity. */

if (parse_entity (xml, config))
{
g_free (xml);
g_warning ("%s: Failed to parse XML", __func__);
return -1;
}
g_free (xml);

return 0;
}

/**
* @brief Create a config from an XML file.
*
Expand Down
Loading