Greenbone Vulnerability Management Libraries
21.4.2
|
API for Open Scanner Protocol communication. More...
#include "osp.h"
#include "../base/hosts.h"
#include "../util/serverutils.h"
#include <assert.h>
#include <gnutls/gnutls.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
Data Structures | |
struct | osp_connection |
Struct holding options for OSP connection. More... | |
struct | osp_param |
Struct holding options for OSP parameters. More... | |
struct | osp_credential |
Struct credential information for OSP. More... | |
struct | osp_target |
Struct holding target information. More... | |
struct | osp_vt_group |
Struct holding vt_group information. More... | |
struct | osp_vt_single |
Struct holding vt_group information. More... | |
Macros | |
#define | G_LOG_DOMAIN "libgvm 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_get_vts_version (osp_connection_t *connection, char **vts_version, char **error) |
Get the VTs version from an OSP server. More... | |
int | osp_get_vts (osp_connection_t *connection, entity_t *vts) |
Get all VTs from an OSP server. More... | |
int | osp_get_vts_ext (osp_connection_t *connection, osp_get_vts_opts_t opts, entity_t *vts) |
Get filtered set of VTs 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_performance_ext (osp_connection_t *connection, osp_get_performance_opts_t opts, char **graph, char **error) |
Get performance graphics from an OSP server. More... | |
osp_scan_status_t | osp_get_scan_status_ext (osp_connection_t *connection, osp_get_scan_status_opts_t opts, char **error) |
Get a scan status from an OSP server. More... | |
int | osp_get_scan_pop (osp_connection_t *connection, const char *scan_id, char **report_xml, int details, int pop_results, char **error) |
Get a scan from an OSP server, optionally removing the results. 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 void | credential_append_as_xml (osp_credential_t *credential, GString *xml_string) |
Concatenate a credential as XML. More... | |
static void | target_append_as_xml (osp_target_t *target, GString *xml_string) |
Concatenate a target as XML. More... | |
static void | vt_group_append_as_xml (osp_vt_group_t *vt_group, GString *xml_string) |
Append VT groups as XML to a string buffer. More... | |
static void | vt_value_append_as_xml (gpointer id, gchar *value, GString *xml_string) |
Append VT values as XML to a string buffer. More... | |
static void | vt_single_append_as_xml (osp_vt_single_t *vt_single, GString *xml_string) |
Append single VTs as XML to a string buffer. More... | |
int | osp_start_scan_ext (osp_connection_t *connection, osp_start_scan_opts_t opts, 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... | |
osp_credential_t * | osp_credential_new (const char *type, const char *service, const char *port) |
Allocate and initialize a new OSP credential. More... | |
void | osp_credential_free (osp_credential_t *credential) |
Free an OSP credential. More... | |
const gchar * | osp_credential_get_auth_data (osp_credential_t *credential, const char *name) |
Get authentication data from an OSP credential. More... | |
void | osp_credential_set_auth_data (osp_credential_t *credential, const char *name, const char *value) |
Get authentication data from an OSP credential. More... | |
API for Open Scanner Protocol communication.
#define G_LOG_DOMAIN "libgvm osp" |
GLib log domain.
|
static |
Concatenate a credential as XML.
[in] | credential | Credential data. |
[in,out] | xml_string | XML string buffer to append to. |
|
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. |
void osp_connection_close | ( | osp_connection_t * | connection | ) |
Close a connection to an OSP server.
[in] | connection | Connection to OSP server to close. |
void osp_credential_free | ( | osp_credential_t * | credential | ) |
Free an OSP credential.
[in] | credential | The credential to free. |
const gchar* osp_credential_get_auth_data | ( | osp_credential_t * | credential, |
const char * | name | ||
) |
Get authentication data from an OSP credential.
[in] | credential | The credential to get the data from. |
[in] | name | The name of the data item to get. |
osp_credential_t* osp_credential_new | ( | const char * | type, |
const char * | service, | ||
const char * | port | ||
) |
Allocate and initialize a new OSP credential.
[in] | type | The credential type. |
[in] | service | The service the credential is for. |
[in] | port | The port. |
void osp_credential_set_auth_data | ( | osp_credential_t * | credential, |
const char * | name, | ||
const char * | value | ||
) |
Get authentication data from an OSP credential.
[in] | credential | The credential to get the data from. |
[in] | name | The name of the data item to get. |
[in] | value | The authentication data or NULL to unset. |
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. |
int osp_get_performance_ext | ( | osp_connection_t * | connection, |
osp_get_performance_opts_t | opts, | ||
char ** | graph, | ||
char ** | error | ||
) |
Get performance graphics from an OSP server.
[in] | connection | Connection to an OSP server. |
[in] | opts | Struct containing the options to apply. |
[out] | graph | Graphic base64 encoded. |
[out] | error | Pointer to error, if any. |
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. |
int osp_get_scan_pop | ( | osp_connection_t * | connection, |
const char * | scan_id, | ||
char ** | report_xml, | ||
int | details, | ||
int | pop_results, | ||
char ** | error | ||
) |
Get a scan from an OSP server, optionally removing the results.
[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. |
[in] | pop_results | 0 to leave results, 1 to pop results from scanner. |
[out] | error | Pointer to error, if any. |
osp_scan_status_t osp_get_scan_status_ext | ( | osp_connection_t * | connection, |
osp_get_scan_status_opts_t | opts, | ||
char ** | error | ||
) |
Get a scan status from an OSP server.
[in] | connection | Connection to an OSP server. |
[in] | scan_id | ID of scan to get. |
[out] | error | Pointer to error, if any. |
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. |
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. |
int osp_get_vts | ( | osp_connection_t * | connection, |
entity_t * | vts | ||
) |
Get all VTs from an OSP server.
[in] | connection | Connection to an OSP server. |
[out] | vts | VTs. |
int osp_get_vts_ext | ( | osp_connection_t * | connection, |
osp_get_vts_opts_t | opts, | ||
entity_t * | vts | ||
) |
Get filtered set of VTs from an OSP server.
[in] | connection | Connection to an OSP server. |
[in] | opts | Struct containing the options to apply. |
[out] | vts | VTs. |
int osp_get_vts_version | ( | osp_connection_t * | connection, |
char ** | vts_version, | ||
char ** | error | ||
) |
Get the VTs version from an OSP server.
[in] | connection | Connection to an OSP server. |
[out] | vts_version | Parsed scanner version. |
[out] | error | Pointer to error, if any. |
const char* osp_param_default | ( | const osp_param_t * | param | ) |
Get an OSP parameter's default value.
[in] | param | OSP parameter. |
const char* osp_param_desc | ( | const osp_param_t * | param | ) |
Get an OSP parameter's description.
[in] | param | OSP parameter. |
void osp_param_free | ( | osp_param_t * | param | ) |
Free an OSP parameter.
[in] | param | OSP parameter to destroy. |
const char* osp_param_id | ( | const osp_param_t * | param | ) |
Get an OSP parameter's id.
[in] | param | OSP parameter. |
int osp_param_mandatory | ( | const osp_param_t * | param | ) |
Get an OSP parameter's mandatory value.
[in] | param | OSP parameter. |
const char* osp_param_name | ( | const osp_param_t * | param | ) |
Get an OSP parameter's name.
[in] | param | OSP parameter. |
osp_param_t* osp_param_new | ( | void | ) |
Create a new OSP parameter.
|
static |
Get an OSP parameter's type from its string format.
[in] | str | OSP parameter in string format. |
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. |
|
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. |
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. |
int osp_start_scan_ext | ( | osp_connection_t * | connection, |
osp_start_scan_opts_t | opts, | ||
char ** | error | ||
) |
Start an OSP scan against a target.
[in] | connection | Connection to an OSP server. |
[in] | opts | Struct containing the options to apply. |
[out] | error | Pointer to error, if any. |
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. |
|
static |
Concatenate a target as XML.
[in] | target | Target data. |
[in,out] | xml_string | XML string buffer to append to. |
|
static |
Append VT groups as XML to a string buffer.
[in] | vt_group | VT group data. |
[in,out] | xml_string | XML string buffer to append to. |
|
static |
Append single VTs as XML to a string buffer.
[in] | vt_single | Single VT data. |
[in,out] | xml_string | XML string buffer to append to. |
|
static |
Append VT values as XML to a string buffer.
[in] | id | Identifier of the vt_value. |
[in] | value | The value of the vt_value. |
[in,out] | xml_string | XML string buffer to append to. |