Greenbone Vulnerability Management Libraries
10.0.0
|
API for Open Scanner Protocol communication. More...
#include "osp.h"
#include "../base/hosts.h"
#include "../util/serverutils.h"
#include "../util/xmlutils.h"
#include <assert.h>
#include <gnutls/gnutls.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
Go to the source code of this file.
Data Structures | |
struct | osp_connection |
Struct holding options for OSP connection. More... | |
struct | osp_param |
Struct holding options for OSP parameters. More... | |
Macros | |
#define | G_LOG_DOMAIN "lib osp" |
GLib log domain. More... | |
Functions | |
static int | osp_send_command (osp_connection_t *connection, entity_t *response, const char *fmt,...) |
Send a command to an OSP server. More... | |
void | osp_connection_close (osp_connection_t *connection) |
Close a connection to an OSP server. More... | |
int | osp_get_version (osp_connection_t *connection, char **s_name, char **s_version, char **d_name, char **d_version, char **p_name, char **p_version) |
Get the scanner version from an OSP server. More... | |
int | osp_delete_scan (osp_connection_t *connection, const char *scan_id) |
Delete a scan from an OSP server. More... | |
int | osp_get_scan (osp_connection_t *connection, const char *scan_id, char **report_xml, int details, char **error) |
Get a scan from an OSP server. More... | |
int | osp_stop_scan (osp_connection_t *connection, const char *scan_id, char **error) |
Stop a scan on an OSP server. More... | |
static void | option_concat_as_xml (gpointer key, gpointer value, gpointer pstr) |
Concatenate options as xml. More... | |
int | osp_start_scan (osp_connection_t *connection, const char *target, const char *ports, GHashTable *options, const char *scan_id, char **error) |
Start an OSP scan against a target. More... | |
static osp_param_type_t | osp_param_str_to_type (const char *str) |
Get an OSP parameter's type from its string format. More... | |
const char * | osp_param_type_str (const osp_param_t *param) |
Get an OSP parameter in string format form its type. More... | |
int | osp_get_scanner_details (osp_connection_t *connection, char **desc, GSList **params) |
Get an OSP scanner's details. More... | |
osp_param_t * | osp_param_new (void) |
Create a new OSP parameter. More... | |
const char * | osp_param_id (const osp_param_t *param) |
Get an OSP parameter's id. More... | |
const char * | osp_param_name (const osp_param_t *param) |
Get an OSP parameter's name. More... | |
const char * | osp_param_desc (const osp_param_t *param) |
Get an OSP parameter's description. More... | |
const char * | osp_param_default (const osp_param_t *param) |
Get an OSP parameter's default value. More... | |
int | osp_param_mandatory (const osp_param_t *param) |
Get an OSP parameter's mandatory value. More... | |
void | osp_param_free (osp_param_t *param) |
Free an OSP parameter. More... | |
API for Open Scanner Protocol communication.
Definition in file osp.c.
|
static |
Concatenate options as xml.
[in] | key | Tag name for xml element. |
[in] | value | Text for xml element. |
[in,out] | pstr | Parameters as xml concatenated xml elements. |
Definition at line 427 of file osp.c.
Referenced by osp_start_scan().
void osp_connection_close | ( | osp_connection_t * | connection | ) |
Close a connection to an OSP server.
[in] | connection | Connection to OSP server to close. |
Definition at line 184 of file osp.c.
References gvm_server_close(), osp_connection::host, osp_connection::session, and osp_connection::socket.
int osp_delete_scan | ( | osp_connection_t * | connection, |
const char * | scan_id | ||
) |
Delete a scan from an OSP server.
[in] | connection | Connection to an OSP server. |
[in] | scan_id | ID of scan to delete. |
Definition at line 295 of file osp.c.
References entity_attribute(), free_entity(), and osp_send_command().
int osp_get_scan | ( | osp_connection_t * | connection, |
const char * | scan_id, | ||
char ** | report_xml, | ||
int | details, | ||
char ** | error | ||
) |
Get a scan from an OSP server.
[in] | connection | Connection to an OSP server. |
[in] | scan_id | ID of scan to get. |
[out] | report_xml | Scans report. |
[in] | details | 0 for no scan details, 1 otherwise. |
[out] | error | Pointer to error, if any. |
Definition at line 331 of file osp.c.
References entity_attribute(), entity_child(), free_entity(), osp_send_command(), and print_entity_to_string().
int osp_get_scanner_details | ( | osp_connection_t * | connection, |
char ** | desc, | ||
GSList ** | params | ||
) |
Get an OSP scanner's details.
[in] | connection | Connection to an OSP server. |
[out] | desc | Scanner's description. |
[out] | params | Scanner's parameters. |
Definition at line 578 of file osp.c.
References osp_param::def, osp_param::desc, entity_s::entities, entity_attribute(), entity_child(), entity_text(), free_entity(), osp_param::id, osp_param::mandatory, osp_param::name, next_entities(), osp_param_new(), osp_param_str_to_type(), osp_send_command(), and osp_param::type.
int osp_get_version | ( | osp_connection_t * | connection, |
char ** | s_name, | ||
char ** | s_version, | ||
char ** | d_name, | ||
char ** | d_version, | ||
char ** | p_name, | ||
char ** | p_version | ||
) |
Get the scanner version from an OSP server.
[in] | connection | Connection to an OSP server. |
[out] | s_name | Parsed scanner name. |
[out] | s_version | Parsed scanner version. |
[out] | d_name | Parsed scanner name. |
[out] | d_version | Parsed scanner version. |
[out] | p_name | Parsed scanner name. |
[out] | p_version | Parsed scanner version. |
Definition at line 211 of file osp.c.
References entity_child(), entity_text(), free_entity(), and osp_send_command().
const char* osp_param_default | ( | const osp_param_t * | param | ) |
Get an OSP parameter's default value.
[in] | param | OSP parameter. |
Definition at line 692 of file osp.c.
References osp_param::def.
const char* osp_param_desc | ( | const osp_param_t * | param | ) |
Get an OSP parameter's description.
[in] | param | OSP parameter. |
Definition at line 677 of file osp.c.
References osp_param::desc.
void osp_param_free | ( | osp_param_t * | param | ) |
Free an OSP parameter.
[in] | param | OSP parameter to destroy. |
Definition at line 720 of file osp.c.
References osp_param::def, osp_param::desc, osp_param::id, and osp_param::name.
const char* osp_param_id | ( | const osp_param_t * | param | ) |
Get an OSP parameter's id.
[in] | param | OSP parameter. |
Definition at line 647 of file osp.c.
References osp_param::id.
int osp_param_mandatory | ( | const osp_param_t * | param | ) |
Get an OSP parameter's mandatory value.
[in] | param | OSP parameter. |
Definition at line 707 of file osp.c.
References osp_param::mandatory.
const char* osp_param_name | ( | const osp_param_t * | param | ) |
Get an OSP parameter's name.
[in] | param | OSP parameter. |
Definition at line 662 of file osp.c.
References osp_param::name.
osp_param_t* osp_param_new | ( | void | ) |
Create a new OSP parameter.
Definition at line 634 of file osp.c.
Referenced by osp_get_scanner_details().
|
static |
Get an OSP parameter's type from its string format.
[in] | str | OSP parameter in string format. |
Definition at line 511 of file osp.c.
References OSP_PARAM_TYPE_BOOLEAN, OSP_PARAM_TYPE_CRD_UP, OSP_PARAM_TYPE_FILE, OSP_PARAM_TYPE_INT, OSP_PARAM_TYPE_OVALDEF_FILE, OSP_PARAM_TYPE_PASSWORD, OSP_PARAM_TYPE_SELECTION, and OSP_PARAM_TYPE_STR.
Referenced by osp_get_scanner_details().
const char* osp_param_type_str | ( | const osp_param_t * | param | ) |
Get an OSP parameter in string format form its type.
[in] | param | OSP parameter. |
Definition at line 542 of file osp.c.
References OSP_PARAM_TYPE_BOOLEAN, OSP_PARAM_TYPE_CRD_UP, OSP_PARAM_TYPE_FILE, OSP_PARAM_TYPE_INT, OSP_PARAM_TYPE_OVALDEF_FILE, OSP_PARAM_TYPE_PASSWORD, OSP_PARAM_TYPE_SELECTION, OSP_PARAM_TYPE_STR, and osp_param::type.
|
static |
Send a command to an OSP server.
[in] | connection | Connection to OSP server. |
[out] | response | Response from OSP server. |
[in] | fmt | OSP Command to send. |
Definition at line 71 of file osp.c.
References gvm_get_host_type(), gvm_server_open_with_cert(), osp_connection::host, osp_connection::port, osp_connection::session, and osp_connection::socket.
Referenced by osp_delete_scan(), osp_get_scan(), osp_get_scanner_details(), osp_get_version(), osp_start_scan(), and osp_stop_scan().
int osp_start_scan | ( | osp_connection_t * | connection, |
const char * | target, | ||
const char * | ports, | ||
GHashTable * | options, | ||
const char * | scan_id, | ||
char ** | error | ||
) |
Start an OSP scan against a target.
[in] | connection | Connection to an OSP server. |
[in] | target | Target host to scan. |
[in] | ports | List of ports to scan. |
[in] | options | Table of scan options. |
[in] | scan_id | uuid to set for scan, null otherwise. |
[out] | error | Pointer to error, if any. |
Definition at line 457 of file osp.c.
References entity_attribute(), free_entity(), option_concat_as_xml(), and osp_send_command().
int osp_stop_scan | ( | osp_connection_t * | connection, |
const char * | scan_id, | ||
char ** | error | ||
) |
Stop a scan on an OSP server.
[in] | connection | Connection to an OSP server. |
[in] | scan_id | ID of scan to delete. |
[out] | error | Pointer to error, if any. |
Definition at line 384 of file osp.c.
References entity_attribute(), free_entity(), and osp_send_command().