Skip to content

Commit 7bf3fa7

Browse files
jjnicolaKraemiinichtsfrei
authored
Add: Notus rust implementation and integrate it into openvasd
This commit contains the complete notus implementation and integration in the openvas rust framework. To enable the notus endpoint, it has to be configured in the `openvasd.toml` file, e.g.: ``` [notus] advisory_path = "/var/lib/notus/products" ``` Note: adjust path according to your local setup, be sure to pick the products directory If everything is done correctly, the notus endpoint is available at `/notus` and `/notus/{os}`. For the following examples the URL and X-API-KEY must be changed according to the used configuration. With a get request to `/notus` all available products (OS) are returned, e.g.: ``` curl --verbose --insecure --request GET https://127.0.0.1:3000/notus -H "X-API-KEY: changeme" |jq . ``` With a post request to `/notus/{os}`, a notus scan is requested. For the `{os}` key the required operating system must be given, e.g. for Debian 12 the corresponding os string is debian_12. The general rule is, the os string in lowercase and all white spaces are replacec by `_`. Here an example for a small notus scan execution: ``` curl --verbose --insecure --request POST https://127.0.0.1:3000/notus/debian_12 -H "X-API-KEY: changeme" -d '["firefox-esr-102.12.0esr-1~deb12u1"]' |jq . ``` The following changes are contained in the notus implementation/integration: * SC-941: Add Notus endpoint to OpenAPI documentation * SC-942: Implement notus entrypoint * SC-943: Implement tests for notus functionality * SC-944: Implement Hashsum file loader for Notus Load Notus files from the feed using the Sha256sums file. Hashsums are verified, as the files are needed. * SC-945: Implement version comparison algorithm * SC-946: Create Package type models Supported package systems: ebuild, rpm, deb, slackware * SC-947: Use openvasd Notus endpoint for LSC in openvas - add URI parser to get the schema, host and port to communicate with openvasd - use curl for simple http/https client - add structures and functions to parse the openvasd response, the notus json object containing the advisories and vulnerabilities - function to process the advisories and to store them in the redis kb in the right format. - dont init mqtt if openvasd lsc is enabled. Fix OS format. And other small improvements * SC-948: Implement Notus Scanning logic * SC-951: Change Hashsum loader to only verify necessary Hashsums For the verification of the Hashsum used in the feed, an Iterator is used to check each line of the Hashsum file. The Hashsum was immediately verified, regardless if each iteration Item was even necessary. With this change, it is possible to only verify the Hashsum, when the corresponding File is needed. * SC-954: Add /notus endpoint to get a list of supported product OS * SC-967 Add: perform notus signature check If enabled in the congiguration file (or passed via command line option) and the GNUPGHOME env variable is set pointing to the gnupg keyring, it will perform the signature check each time that a new product file is uploaded. * Add notus standalone executable * Change: add libcurl to docker images. * Fix: CodeQL: uses build image Although the build image construct got deprecated codeql relies on it. To change that CodeQL now uses gvm-libs and install the dependencies like the other build steps. --------- Co-authored-by: Kraemii <[email protected]> Co-authored-by: Philipp Eder <[email protected]>
1 parent e398a54 commit 7bf3fa7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+35435
-211
lines changed

.docker/build.Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ RUN apt-get update && apt-get install --no-install-recommends --no-install-sugge
2828
libroken19-heimdal \
2929
libhdb9-heimdal \
3030
libpopt0 \
31+
libcurl4-gnutls-dev \
3132
&& rm -rf /var/lib/apt/lists/*

.docker/prod-oldstable.Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ RUN apt-get update && apt-get install --no-install-recommends --no-install-sugge
3131
libroken18-heimdal \
3232
libhdb9-heimdal \
3333
libpopt0 \
34+
libcurl4-gnutls-dev \
35+
libcurl4 \
3436
libcgreen1-dev \
3537
&& rm -rf /var/lib/apt/lists/*
3638

@@ -64,6 +66,7 @@ RUN apt-get update && apt-get install --no-install-recommends --no-install-sugge
6466
libroken18-heimdal \
6567
libhdb9-heimdal \
6668
libpopt0 \
69+
libcurl4 \
6770
zlib1g\
6871
&& rm -rf /var/lib/apt/lists/*
6972
COPY .docker/openvas.conf /etc/openvas/

.docker/prod-testing.Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ RUN apt-get update && apt-get install --no-install-recommends --no-install-sugge
3939
libroken19-heimdal \
4040
libhdb9-heimdal \
4141
libpopt0 \
42+
libcurl4 \
4243
zlib1g\
4344
&& rm -rf /var/lib/apt/lists/*
4445
COPY .docker/openvas.conf /etc/openvas/

.docker/prod.Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ RUN apt-get update && apt-get install --no-install-recommends --no-install-sugge
3535
libroken19-heimdal \
3636
libhdb9-heimdal \
3737
libpopt0 \
38-
zlib1g\
38+
libcurl4 \
39+
zlib1g \
3940
&& rm -rf /var/lib/apt/lists/*
4041
COPY .docker/openvas.conf /etc/openvas/
4142
# must be pre built within the rust dir and moved to the bin dir

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.vscode/
22
.mergify.yml
33
build/
4+
rust/target

.github/install-openvas-dependencies.sh

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ apt-get update && apt-get install --no-install-recommends --no-install-suggests
2626
libroken19-heimdal \
2727
libhdb9-heimdal \
2828
libpopt0 \
29+
libcurl4 \
30+
libcurl4-gnutls-dev \
2931
&& rm -rf /var/lib/apt/lists/*
3032

3133
curl -L -o cgreen.tar.gz https://github.com/cgreen-devs/cgreen/archive/refs/tags/1.6.2.tar.gz -k

.github/workflows/codeql-analysis-c.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
actions: read
1717
contents: read
1818
security-events: write
19-
container: ${{ github.repository }}-build:unstable
19+
container: greenbone/gvm-libs:unstable
2020

2121
strategy:
2222
fail-fast: false
@@ -26,7 +26,9 @@ jobs:
2626
steps:
2727
- name: Checkout repository
2828
uses: actions/checkout@v4
29-
29+
- name: install dependencies
30+
run: |
31+
sh .github/install-openvas-dependencies.sh
3032
- name: Initialize CodeQL
3133
uses: github/codeql-action/init@v2
3234
with:

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ configure_file (src/openvas_log_conf.cmake_in src/openvas_log.conf)
200200
enable_testing ()
201201

202202
add_custom_target (tests
203-
DEPENDS attack-test pcap-test ipc-openvas-test)
203+
DEPENDS attack-test pcap-test ipc-openvas-test lsc-test)
204204

205205
## Program
206206

INSTALL.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Prerequisites:
2525
* libssh >= 0.6.0
2626
* libksba >= 1.0.7
2727
* libgnutls >= 3.6.4
28+
* libcurl4-gnutls-dev
2829
* libbsd
2930

3031
Prerequisites for building documentation:
@@ -54,7 +55,7 @@ Install prerequisites on Debian GNU/Linux 'Bullseye' 11:
5455

5556
apt-get install gcc pkg-config libssh-gcrypt-dev libgnutls28-dev \
5657
libglib2.0-dev libjson-glib-dev libpcap-dev libgpgme-dev bison libksba-dev \
57-
libsnmp-dev libgcrypt20-dev redis-server libbsd-dev
58+
libsnmp-dev libgcrypt20-dev redis-server libbsd-dev libcurl4-gnutls-dev
5859

5960

6061
Compiling openvas

doc/full_installation_guide.md

+1
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ sudo apt install -y \
295295
rsync \
296296
nmap \
297297
libjson-glib-dev \
298+
libcurl4-gnutls-dev \
298299
libbsd-dev
299300
```
300301

misc/CMakeLists.txt

+20-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ endif (NOT PKG_CONFIG_FOUND)
1414
pkg_check_modules (GLIB REQUIRED glib-2.0>=2.42)
1515
pkg_check_modules (GLIB_JSON REQUIRED json-glib-1.0>=1.4.4)
1616
pkg_check_modules (GNUTLS REQUIRED gnutls>=3.6.4)
17+
pkg_check_modules (CURL REQUIRED libcurl>=7.74.0)
1718

1819
pkg_check_modules (LIBGVM_BASE REQUIRED libgvm_base>=22.4)
1920
pkg_check_modules (LIBGVM_UTIL REQUIRED libgvm_util>=22.4)
@@ -68,7 +69,7 @@ add_definitions (-DOPENVAS_MISC_VERSION="${PROJECT_VERSION_STRING}")
6869

6970
include_directories (${GLIB_INCLUDE_DIRS} ${GLIB_JSON_INCLUDE_DIRS}
7071
${LIBGVM_BASE_INCLUDE_DIRS}
71-
${GNUTLS_INCLUDE_DIRS})
72+
${GNUTLS_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS})
7273

7374
# Library
7475

@@ -92,7 +93,7 @@ set_target_properties (openvas_misc_shared PROPERTIES VERSION "${PROJECT_VERSION
9293
target_link_libraries (openvas_misc_shared LINK_PRIVATE
9394
${GNUTLS_LDFLAGS} ${UUID_LDFLAGS}
9495
${GLIB_LDFLAGS} ${GLIB_JSON_LDFLAGS}
95-
${PCAP_LDFLAGS} ${LIBGVM_BOREAS_LDFLAGS}
96+
${PCAP_LDFLAGS} ${LIBGVM_BOREAS_LDFLAGS} ${CURL_LDFLAGS}
9697
${LINKER_HARDENING_FLAGS})
9798

9899
if (OPENVAS_STATE_DIR)
@@ -135,6 +136,7 @@ set (LINK_LIBS_FOR_TESTS cgreen
135136
${LIBGVM_BASE_LDFLAGS}
136137
${GLIB_LDFLAGS}
137138
${PCAP_LDFLAGS}
139+
${CURL_LDFLAGS}
138140
${LINKER_HARDENING_FLAGS} ${CMAKE_THREAD_LIBS_INIT}
139141
${ALIVEDETECTION_TEST_LINKER_WRAP_OPTIONS})
140142

@@ -161,9 +163,25 @@ target_include_directories (ipc-openvas-test PRIVATE ${CGREEN_INCLUDE_DIRS})
161163
target_link_libraries (ipc-openvas-test cgreen
162164
${GLIB_LDFLAGS}
163165
${GLIB_JSON_LDFLAGS}
166+
${CURL_LDFLAGS}
164167
${LINKER_HARDENING_FLAGS})
165168

166169
add_custom_target (tests-ipc-openvas
167170
DEPENDS ipc-openvas-test)
168171

172+
# lsc-tests
173+
add_executable (lsc-test EXCLUDE_FROM_ALL table_driven_lsc_tests.c kb_cache.c plugutils.c scan_id.c)
174+
add_test (lsc-test lsc-test)
175+
target_include_directories (lsc-test PRIVATE ${CGREEN_INCLUDE_DIRS})
176+
target_link_libraries (lsc-test cgreen
177+
${LIBGVM_BASE_LDFLAGS}
178+
${LIBGVM_UTIL_LDFLAGS}
179+
${GLIB_LDFLAGS}
180+
${GLIB_JSON_LDFLAGS}
181+
${CURL_LDFLAGS}
182+
${LINKER_HARDENING_FLAGS})
183+
184+
add_custom_target (tests-lsc
185+
DEPENDS lsc-test)
186+
169187
## End

0 commit comments

Comments
 (0)