Greenbone Vulnerability Manager
8.0.0~git
|
The Greenbone Vulnerability Manager OTP library. More...
#include "otp.h"
#include "manage.h"
#include "scanner.h"
#include "types.h"
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <gvm/base/strings.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
Macros | |
#define | G_LOG_DOMAIN "md otp" |
GLib log domain. More... | |
Enumerations | |
enum | scanner_state_t { SCANNER_BYE, SCANNER_DONE, SCANNER_ERRMSG_DESCRIPTION, SCANNER_ERRMSG_HOST, SCANNER_ERRMSG_HOSTNAME, SCANNER_ERRMSG_NUMBER, SCANNER_ERRMSG_OID, SCANNER_ALARM_DESCRIPTION, SCANNER_ALARM_HOST, SCANNER_ALARM_HOSTNAME, SCANNER_ALARM_NUMBER, SCANNER_ALARM_OID, SCANNER_LOG_DESCRIPTION, SCANNER_LOG_HOST, SCANNER_LOG_HOSTNAME, SCANNER_LOG_NUMBER, SCANNER_LOG_OID, SCANNER_NVT_INFO, SCANNER_PLUGIN_LIST_BUGTRAQ_ID, SCANNER_PLUGIN_LIST_CATEGORY, SCANNER_PLUGIN_LIST_CVE_ID, SCANNER_PLUGIN_LIST_FAMILY, SCANNER_PLUGIN_LIST_NAME, SCANNER_PLUGIN_LIST_OID, SCANNER_PLUGIN_LIST_TAGS, SCANNER_PLUGIN_LIST_XREFS, SCANNER_PREFERENCE_NAME, SCANNER_PREFERENCE_VALUE, SCANNER_SERVER, SCANNER_STATUS, SCANNER_STATUS_HOST, SCANNER_STATUS_PROGRESS, SCANNER_TIME, SCANNER_TIME_HOST_START_HOST, SCANNER_TIME_HOST_START_TIME, SCANNER_TIME_HOST_END_HOST, SCANNER_TIME_HOST_END_TIME, SCANNER_TIME_SCAN_START, SCANNER_TIME_SCAN_END, SCANNER_TOP } |
Possible states of the scanner. | |
Functions | |
static void | blank_control_chars (char *string) |
Replace any control characters in string with spaces. More... | |
static message_t * | make_message (const char *host) |
Make a message. More... | |
static void | free_message (message_t *message) |
Free a message for g_ptr_array_foreach. More... | |
static void | set_message_hostname (message_t *message, char *hostname) |
Set the hostname of a message. More... | |
static void | set_message_port_number (message_t *message, int number) |
Set the port number of a message. More... | |
static void | set_message_port_protocol (message_t *message, const char *protocol) |
Set the port protocol of a message. More... | |
static void | set_message_port_string (message_t *message, char *string) |
Set the original string of a port of a message. More... | |
static void | set_message_description (message_t *message, char *description) |
Set the description of a message. More... | |
static void | set_message_oid (message_t *message, char *oid) |
Set the OID of a message. More... | |
static void | write_message (task_t task, message_t *message, char *type) |
Write a message for g_ptr_array_foreach. More... | |
static void | append_error_message (task_t task, message_t *message) |
Append a error message to a report. More... | |
static void | append_alarm_message (task_t task, message_t *message) |
Append a hole message to a report. More... | |
static void | append_log_message (task_t task, message_t *message) |
Append a log message to a report. More... | |
void | init_otp_data () |
Initialise OTP library data. More... | |
static void | set_scanner_state (scanner_state_t state) |
Set the scanner state, scanner_state. More... | |
void | set_scanner_init_state (scanner_init_state_t state) |
Set the scanner initialisation state, scanner_init_state. More... | |
void | reset_scanner_states () |
Set the scanner initialisation state, scanner_init_state. More... | |
static int | sync_buffer () |
"Synchronise" the from_scanner buffer. More... | |
static int | parse_scanner_done (char **messages) |
Parse the final SERVER field of an OTP message. More... | |
static int | parse_scanner_bad_login (char **messages) |
Check for a bad login response from the scanner. More... | |
static int | parse_scanner_preference_value (char **messages) |
Parse preference value. More... | |
static int | parse_scanner_plugin_list_tags (char **messages) |
Parse the tags of a plugin list. More... | |
static int | parse_scanner_server (char **messages) |
Parse the field following "SERVER <|>". More... | |
static int | scanner_is_loading (char *messages) |
Check if current message is the scanner loading message. More... | |
static void | parse_scanner_loading (char *messages) |
Parse SCANNER_LOADING response. More... | |
int | process_otp_scanner_input () |
Process any lines available in from_scanner. More... | |
Variables | |
buffer_size_t | from_buffer_size |
Size of from_client data buffer, in bytes. More... | |
static message_t * | current_message = NULL |
Current message during OTP SERVER message commands. | |
static gchar * | current_host = NULL |
Current host during OTP SERVER message commands. | |
static char * | plugins_feed_version = NULL |
The version of the NVT feed. | |
static char * | current_scanner_preference = NULL |
The current scanner preference, during reading of scanner preferences. | |
static nvti_t * | current_plugin = NULL |
The current plugin, during reading of scanner plugin list. | |
static GList * | scanner_plugins_list = NULL |
The full plugins list, during reading of scanner plugin list. | |
static GList * | scanner_preferences_list = NULL |
The full preferences list, during reading of scanner plugin list. | |
static scanner_state_t | scanner_state = SCANNER_TOP |
The state of the scanner. | |
scanner_init_state_t | scanner_init_state = SCANNER_INIT_TOP |
The initialisation state of the scanner. More... | |
int | scanner_init_offset = 0 |
Offset into initialisation string being sent to scanner. More... | |
int | scanner_current_loading = 0 |
Scanner current number of loaded plugins, when still loading. | |
int | scanner_total_loading = 0 |
Scanner total number of plugins to be loaded, when still loading. | |
char * | from_scanner |
Buffer of input from the scanner. More... | |
buffer_size_t | from_scanner_start |
The start of the data in the from_scanner buffer. | |
buffer_size_t | from_scanner_end |
The end of the data in the from_scanner buffer. | |
The Greenbone Vulnerability Manager OTP library.
This file defines an OpenVAS Transfer Protocol (OTP) library, for implementing managers such as the Greenbone Vulnerability Manager daemon.
The library provides a single function, process_otp_scanner_input. This function parses a given string of OTP text and adjusts local task records according to the OTP messages in the string.
#define G_LOG_DOMAIN "md otp" |
GLib log domain.
|
static |
Append a hole message to a report.
[in] | task | Task. |
[in] | message | Message. |
|
static |
Append a error message to a report.
[in] | task | Task. |
[in] | message | Message. |
|
static |
Append a log message to a report.
[in] | task | Task. |
[in] | message | Message. |
|
static |
Replace any control characters in string with spaces.
[in,out] | string | String to replace in. |
|
static |
Free a message for g_ptr_array_foreach.
[in] | message | Pointer to the message. |
void init_otp_data | ( | ) |
Initialise OTP library data.
This must run once, before the first call to process_otp_scanner_input.
|
static |
Make a message.
[in] | host | Host name. |
|
static |
Check for a bad login response from the scanner.
messages | A pointer into the OTP input buffer. |
|
static |
Parse the final SERVER field of an OTP message.
messages | A pointer into the OTP input buffer. |
|
static |
Parse SCANNER_LOADING response.
Updates scanner_current_loading and scanner_total_loading values.
[in] | messages | Messages. |
|
static |
Parse the tags of a plugin list.
messages | A pointer into the OTP input buffer. |
|
static |
Parse preference value.
messages | A pointer into the OTP input buffer. |
|
static |
Parse the field following "SERVER <|>".
messages | A pointer into the OTP input buffer. |
int process_otp_scanner_input | ( | ) |
Process any lines available in from_scanner.
Update scanner information according to the input from the scanner.
This function simply records input from the scanner. Output to the scanner or client is almost always done via process_gmp_client_input in reaction to client requests, the only exception being stop requests initiated in other processes.
void reset_scanner_states | ( | ) |
Set the scanner initialisation state, scanner_init_state.
|
static |
Check if current message is the scanner loading message.
[in] | messages | Message. |
|
static |
Set the description of a message.
[in] | message | Pointer to the message. Used directly, freed by free_message. |
[in] | description | Description. |
|
static |
Set the hostname of a message.
[in] | message | Pointer to the message. Used directly, freed by free_message. |
[in] | hostname | Hostname. |
|
static |
Set the OID of a message.
[in] | message | Pointer to the message. Used directly, freed by free_message. |
[in] | oid | OID. |
|
static |
Set the port number of a message.
[in] | message | Pointer to the message. Used directly, freed by free_message. |
[in] | number | Port number. |
|
static |
Set the port protocol of a message.
[in] | message | Pointer to the message. Used directly, freed by free_message. |
[in] | protocol | Name of protocol on port. |
|
static |
Set the original string of a port of a message.
[in] | message | Pointer to the message. |
[in] | string | Port string. |
void set_scanner_init_state | ( | scanner_init_state_t | state | ) |
Set the scanner initialisation state, scanner_init_state.
[in] | state | New init state. |
|
static |
Set the scanner state, scanner_state.
[in] | state | New state. |
|
static |
"Synchronise" the from_scanner buffer.
Move any OTP in the from_scanner buffer to the front of the buffer.
|
static |
Write a message for g_ptr_array_foreach.
[in] | task | The task with which to associate the message. |
[in] | message | The message. |
[in] | type | The message type (for example "Security Warning"). |
buffer_size_t from_buffer_size |
Size of from_client data buffer, in bytes.
char* from_scanner |
Buffer of input from the scanner.
int scanner_init_offset = 0 |
scanner_init_state_t scanner_init_state = SCANNER_INIT_TOP |