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

Merge middleware into main #609

Merged
merged 33 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
96e9feb
Add MQTT support
ArnoStiefvater Jun 28, 2021
111c04b
Add docker file for gvm-libs-master-debian-buster-gcc-test
y0urself Jun 28, 2021
89e45a4
Add more dockerfiles
y0urself Jun 28, 2021
974e469
Add dockerfiles for middleware branch
y0urself Jun 30, 2021
93392e4
Refactor MQTT handling
ArnoStiefvater Jul 6, 2021
42580b0
Merge pull request #563 from greenbone/mergify/bp/master/pr-561
ArnoStiefvater Jul 14, 2021
349df99
Refactor MQTT handling
ArnoStiefvater Jul 13, 2021
939fc24
Small adjustments on the CI
y0urself Jul 14, 2021
d92078c
Merge pull request #565 from greenbone/y0urself/middleware-ci
y0urself Jul 14, 2021
0202784
Merge branch 'middleware' into master
y0urself Jul 14, 2021
4a18ae5
Merge pull request #566 from greenbone/master
ArnoStiefvater Jul 15, 2021
79ea166
Add function for checking init status
ArnoStiefvater Jul 20, 2021
2582fb5
Add changelog entries for middleware branch
ArnoStiefvater Jul 21, 2021
342ac69
Merge pull request #567 from ArnoStiefvater/middleware
ArnoStiefvater Jul 21, 2021
d461a47
Add function to get the severity_vector, otherwise the cvss_base_vector.
jjnicola Jul 26, 2021
f489c9f
Add tests
jjnicola Jul 26, 2021
aecb143
Fix docstrings
jjnicola Jul 27, 2021
e5e4f52
Merge pull request #568 from jjnicola/get-vector
ArnoStiefvater Jul 27, 2021
3194575
Add: subscribe and retrieve message from mqtt
nichtsfrei Aug 3, 2021
14f37d1
Remove timeout from the nvti structure.
jjnicola Aug 12, 2021
3817f9e
Remove NVT_TIMEOUT_POS from the redis structure.
jjnicola Aug 12, 2021
ff415bd
Remove nvticache_get_timeout()
jjnicola Aug 12, 2021
695c5d8
Define fixed ID for the timeout nvt preference.
jjnicola Aug 12, 2021
fa1bc07
Fix format
jjnicola Aug 12, 2021
557083b
Fix type when add nvt to redis
jjnicola Aug 13, 2021
922b77e
Remove prefs_nvt_timeout
jjnicola Aug 16, 2021
a319729
Update Changelog
jjnicola Aug 16, 2021
6913753
Merge pull request #578 from jjnicola/timeout
ArnoStiefvater Aug 17, 2021
827d671
Fix prototype
jjnicola Sep 1, 2021
05845e3
Merge pull request #584 from jjnicola/fix-strict-prototypes
ArnoStiefvater Sep 1, 2021
8ff2a3a
duplicate function for host and vhost
Kraemii Sep 28, 2021
11037fc
Merge branch 'middleware' into merge-middleware
ArnoStiefvater Oct 18, 2021
5604a1b
Remove old docker files
y0urself Oct 19, 2021
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 .docker/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Dockerfile for gvm-libs-$VERSION-$COMPILER-build

# Define ARG we use through the build
ARG VERSION=master
ARG VERSION=main
ARG BUILD_TYPE=Debug
ARG COMPILER=gcc

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-c.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build and test C

on:
push:
branches: [ main, oldstable, stable, middleware ]
branches: [ main, oldstable, stable ]
pull_request:
branches: [ main, oldstable, stable, middleware ]
branches: [ main, oldstable, stable ]


jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and upload docker images

on:
push:
branches: [ main, oldstable, stable, middleware ]
branches: [ main, oldstable, stable ]

jobs:
upload-testing:
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
build/
.ccls
# clangd
# generated by
# cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1
compile_commands.json
.cache/
# cmake
CMakeFiles/
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Possibility to use lcrypt with `$6$` (sha512) for authentication [484](https://github.com/greenbone/gvm-libs/pull/484)
- Add function to perform an alive test and get the amount of alive hosts. [495](https://github.com/greenbone/gvm-libs/pull/495)
- Add functions for sentry integration. [#502](https://github.com/greenbone/gvm-libs/pull/502) [#506](https://github.com/greenbone/gvm-libs/pull/506)
- Add basic support for mqtt.
Original
[#505](https://github.com/greenbone/gvm-libs/pull/505)
[#511](https://github.com/greenbone/gvm-libs/pull/511).
Reintroduction after Rebase
[#538](https://github.com/greenbone/gvm-libs/pull/538)
- Refactor MQTT handling [#562](https://github.com/greenbone/gvm-libs/pull/562). Add function for mqtt init status [#567](https://github.com/greenbone/gvm-libs/pull/567). Fix prototypes in mqtt.h. [#584](https://github.com/greenbone/gvm-libs/pull/584)
- Add function to get the severity_vector, otherwise the cvss_base_vector. [#568](https://github.com/greenbone/gvm-libs/pull/568)
- Add function to duplicate host and vhost objects [#590](https://github.com/greenbone/gvm-libs/pull/590)

### Changed
- Handle script timeout as script preference with ID 0 [#581](https://github.com/greenbone/gvm-libs/pull/581)
Expand Down
2 changes: 2 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ Install prerequisites for optional features on Debian GNU/Linux 'Buster' 10:
libldap2-dev \
libradcli-dev

Prerequisites for MQTT support:
* libpaho-mqtt-dev >= 1.3.8. This package is currently not available in debian buster stable. Could be installed from source, backports or unstable branch.

Compiling gvm-libs
------------------
Expand Down
30 changes: 30 additions & 0 deletions base/nvti.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,36 @@ nvti_severity_score (const nvti_t *n)
return score;
}

/**
* @brief Get the severity score
*
* Extended severity was introduced but still not all
* vts are using it. Therefore it must be checked if
* we can calculate the score from the severity_vector tag
* or if we have to calculate it from the deprecated
* cvss_base_vector tag.
*
* @param n The NVT Info structure.
*
* @return The severity_vector if present or cvss_base_vector otherwise.
* NULL indicates an error. Must be free()'d by the caller.
*/
gchar *
nvti_severity_vector_from_tag (const nvti_t *n)
{
gchar *vector;

/* Currently, only one severity_vector can be stored as tag.
* Therfore we just check this one. */
vector = nvti_get_tag (n, "severity_vector");
if (vector)
return vector;

vector = nvti_get_tag (n, "cvss_base_vector");

return vector;
}

/**
* @brief Get the solution.
*
Expand Down
2 changes: 2 additions & 0 deletions base/nvti.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ vtseverity_t *
nvti_vtseverity (const nvti_t *, guint);
double
nvti_severity_score (const nvti_t *);
gchar *
nvti_severity_vector_from_tag (const nvti_t *);

nvti_t *
nvti_new (void);
Expand Down
47 changes: 47 additions & 0 deletions base/nvti_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,48 @@ Ensure (nvti, nvtis_add_does_not_use_oid_as_key)
assert_that (nvtis_lookup (nvtis, "2"), is_null);
}

/* nvti severity vector */

Ensure (nvti, nvti_get_severity_vector_both)
{
nvti_t *nvti;

nvti = nvti_new ();
nvti_set_tag (nvti, "cvss_base_vector=DEF");
nvti_set_tag (nvti, "severity_vector=ABC");

assert_that (nvti_severity_vector_from_tag (nvti),
is_equal_to_string ("ABC"));

nvti_free (nvti);
}

Ensure (nvti, nvti_get_severity_vector_no_cvss_base)
{
nvti_t *nvti;

nvti = nvti_new ();
nvti_set_tag (nvti, "severity_vector=ABC");

assert_that (nvti_severity_vector_from_tag (nvti),
is_equal_to_string ("ABC"));

nvti_free (nvti);
}

Ensure (nvti, nvti_get_severity_vector_no_severity_vector)
{
nvti_t *nvti;

nvti = nvti_new ();
nvti_set_tag (nvti, "cvss_base_vector=DEF");

assert_that (nvti_severity_vector_from_tag (nvti),
is_equal_to_string ("DEF"));

nvti_free (nvti);
}

/* Test suite. */

int
Expand All @@ -163,6 +205,11 @@ main (int argc, char **argv)

add_test_with_context (suite, nvti, nvtis_add_does_not_use_oid_as_key);

add_test_with_context (suite, nvti, nvti_get_severity_vector_both);
add_test_with_context (suite, nvti,
nvti_get_severity_vector_no_severity_vector);
add_test_with_context (suite, nvti, nvti_get_severity_vector_no_cvss_base);

if (argc > 1)
return run_single_test (suite, argv[1], create_text_reporter ());

Expand Down
17 changes: 14 additions & 3 deletions util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ pkg_check_modules (REDIS REQUIRED hiredis>=0.10.1)
# for fast XML we need libxml2
pkg_check_modules (LIBXML2 REQUIRED libxml-2.0>=2.0)

# for mqtt
# Optional for now because lib is currently not in debian buster stable.
find_library(LIBPAHO paho-mqtt3c)
message (STATUS "Looking for paho-mqtt3c ... ${LIBPAHO}")
if (NOT LIBPAHO)
message (STATUS "libpaho-mqtt3c is required for MQTTv5 support.")
else (LIBPAHO)
set (LIBPAHO_LDFLAGS "paho-mqtt3c")
add_definitions (-DHAVE_MQTT=1)
endif (NOT LIBPAHO)

#for gpgmeutils we need libgpgme
set (GPGME_MIN_VERSION "1.7.0")
message (STATUS "Looking for gpgme...")
Expand Down Expand Up @@ -156,11 +167,11 @@ include_directories (${GLIB_INCLUDE_DIRS} ${GPGME_INCLUDE_DIRS} ${GCRYPT_INCLUDE
${LIBXML2_INCLUDE_DIRS})

set (FILES passwordbasedauthentication.c compressutils.c fileutils.c gpgmeutils.c kb.c ldaputils.c
nvticache.c radiusutils.c serverutils.c sshutils.c uuidutils.c
nvticache.c mqtt.c radiusutils.c serverutils.c sshutils.c uuidutils.c
xmlutils.c)

set (HEADERS passwordbasedauthentication.h authutils.h compressutils.h fileutils.h gpgmeutils.h kb.h
ldaputils.h nvticache.h radiusutils.h serverutils.h sshutils.h
ldaputils.h nvticache.h mqtt.h radiusutils.h serverutils.h sshutils.h
uuidutils.h xmlutils.h)

if (BUILD_STATIC)
Expand All @@ -178,7 +189,7 @@ if (BUILD_SHARED)
set_target_properties (gvm_util_shared PROPERTIES VERSION "${CPACK_PACKAGE_VERSION}")
set_target_properties (gvm_util_shared PROPERTIES PUBLIC_HEADER "${HEADERS}")

target_link_libraries (gvm_util_shared LINK_PRIVATE ${GLIB_LDFLAGS}
target_link_libraries (gvm_util_shared LINK_PRIVATE ${LIBPAHO_LDFLAGS} ${GLIB_LDFLAGS}
${GIO_LDFLAGS} ${GPGME_LDFLAGS} ${ZLIB_LDFLAGS}
${RADIUS_LDFLAGS} ${LIBSSH_LDFLAGS} ${GNUTLS_LDFLAGS}
${GCRYPT_LDFLAGS} ${LDAP_LDFLAGS} ${REDIS_LDFLAGS}
Expand Down
Loading