Greenbone Vulnerability Management Libraries 22.12.2
osp.h File Reference

API for Open Scanner Protocol communication. More...

#include "../util/xmlutils.h"
#include <glib.h>

Go to the source code of this file.

Data Structures

struct  osp_get_scan_status_opts_t
 
struct  osp_get_performance_opts_t
 
struct  osp_get_vts_opts_t
 
struct  osp_start_scan_opts_t
 

Typedefs

typedef struct osp_connection osp_connection_t
 
typedef struct osp_credential osp_credential_t
 
typedef struct osp_target osp_target_t
 
typedef struct osp_vt_group osp_vt_group_t
 
typedef struct osp_vt_single osp_vt_single_t
 
typedef struct osp_param osp_param_t
 

Enumerations

enum  osp_param_type_t {
  OSP_PARAM_TYPE_INT = 0 , OSP_PARAM_TYPE_STR , OSP_PARAM_TYPE_PASSWORD , OSP_PARAM_TYPE_FILE ,
  OSP_PARAM_TYPE_BOOLEAN , OSP_PARAM_TYPE_OVALDEF_FILE , OSP_PARAM_TYPE_SELECTION , OSP_PARAM_TYPE_CRD_UP
}
 OSP parameter types. More...
 
enum  osp_scan_status_t {
  OSP_SCAN_STATUS_ERROR = -1 , OSP_SCAN_STATUS_INIT , OSP_SCAN_STATUS_RUNNING , OSP_SCAN_STATUS_STOPPED ,
  OSP_SCAN_STATUS_FINISHED , OSP_SCAN_STATUS_QUEUED , OSP_SCAN_STATUS_INTERRUPTED
}
 OSP scan status. More...
 

Functions

osp_connection_tosp_connection_new (const char *, int, const char *, const char *, const char *)
 
void osp_connection_close (osp_connection_t *)
 Close a connection to an OSP server.
 
int osp_check_feed (osp_connection_t *, int *, int *, char **, char **)
 Gets additional status info about the feed.
 
int osp_get_version (osp_connection_t *, char **, char **, char **, char **, char **, char **)
 Get the scanner version from an OSP server.
 
int osp_get_vts_version (osp_connection_t *, char **, char **error)
 Get the VTs version from an OSP server.
 
int osp_get_vts_feed_info (osp_connection_t *, char **, char **, char **, char **, char **)
 Get the VTs version as well as other feed info from an OSP server.
 
int osp_get_vts (osp_connection_t *, entity_t *)
 Get all VTs from an OSP server.
 
int osp_get_vts_ext (osp_connection_t *, osp_get_vts_opts_t, entity_t *)
 Get filtered set of VTs from an OSP server.
 
int osp_get_vts_ext_str (osp_connection_t *, osp_get_vts_opts_t, gchar **)
 Get filtered set of VTs from an OSP server.
 
int osp_start_scan (osp_connection_t *, const char *, const char *, GHashTable *, const char *, char **)
 Start an OSP scan against a target.
 
int osp_start_scan_ext (osp_connection_t *, osp_start_scan_opts_t, char **)
 Start an OSP scan against a target.
 
int osp_get_scan (osp_connection_t *, const char *, char **, int, char **)
 Get a scan from an OSP server.
 
int osp_get_scan_pop (osp_connection_t *, const char *, char **, int, int, char **)
 Get a scan from an OSP server, optionally removing the results.
 
osp_scan_status_t osp_get_scan_status_ext (osp_connection_t *, osp_get_scan_status_opts_t, char **)
 Get a scan status from an OSP server.
 
int osp_delete_scan (osp_connection_t *, const char *)
 Delete a scan from an OSP server.
 
int osp_stop_scan (osp_connection_t *, const char *, char **)
 Stop a scan on an OSP server.
 
int osp_get_scanner_details (osp_connection_t *, char **, GSList **)
 Get an OSP scanner's details.
 
int osp_get_performance_ext (osp_connection_t *, osp_get_performance_opts_t, char **, char **)
 Get performance graphics from an OSP server.
 
osp_param_tosp_param_new (void)
 Create a new OSP parameter.
 
const char * osp_param_id (const osp_param_t *)
 Get an OSP parameter's id.
 
const char * osp_param_name (const osp_param_t *)
 Get an OSP parameter's name.
 
const char * osp_param_desc (const osp_param_t *)
 Get an OSP parameter's description.
 
const char * osp_param_default (const osp_param_t *)
 Get an OSP parameter's default value.
 
const char * osp_param_type_str (const osp_param_t *)
 Get an OSP parameter in string format form its type.
 
int osp_param_mandatory (const osp_param_t *)
 Get an OSP parameter's mandatory value.
 
void osp_param_free (osp_param_t *)
 Free an OSP parameter.
 
osp_credential_tosp_credential_new (const char *, const char *, const char *)
 Allocate and initialize a new OSP credential.
 
void osp_credential_free (osp_credential_t *)
 Free an OSP credential.
 
const gchar * osp_credential_get_auth_data (osp_credential_t *, const char *)
 Get authentication data from an OSP credential.
 
void osp_credential_set_auth_data (osp_credential_t *, const char *, const char *)
 Get authentication data from an OSP credential.
 
osp_target_tosp_target_new (const char *, const char *, const char *, int, int, int)
 Create a new OSP target.
 
void osp_target_set_finished_hosts (osp_target_t *, const char *)
 Set the finished hosts of an OSP target.
 
void osp_target_free (osp_target_t *)
 Free an OSP target, including all added credentials.
 
void osp_target_add_alive_test_methods (osp_target_t *, gboolean, gboolean, gboolean, gboolean, gboolean)
 Add alive test methods to OSP target.
 
void osp_target_add_credential (osp_target_t *, osp_credential_t *)
 Add a credential to an OSP target.
 
osp_vt_group_tosp_vt_group_new (const char *)
 Create a new OSP VT group.
 
void osp_vt_group_free (osp_vt_group_t *)
 Free a OSP VT group.
 
osp_vt_single_tosp_vt_single_new (const char *)
 Create a new single OSP VT.
 
void osp_vt_single_free (osp_vt_single_t *)
 Free a single OSP VT, including all preference values.
 
void osp_vt_single_add_value (osp_vt_single_t *, const char *, const char *)
 Add a preference value to an OSP VT. This creates a copy of the name and value.
 

Variables

static const osp_get_vts_opts_t osp_get_vts_opts_default = {NULL, 0}
 Sensible default values for osp_get_vts_opts_t.
 

Detailed Description

API for Open Scanner Protocol communication.

Typedef Documentation

◆ osp_connection_t

◆ osp_credential_t

◆ osp_param_t

typedef struct osp_param osp_param_t

◆ osp_target_t

typedef struct osp_target osp_target_t

◆ osp_vt_group_t

typedef struct osp_vt_group osp_vt_group_t

◆ osp_vt_single_t

Enumeration Type Documentation

◆ osp_param_type_t

OSP parameter types.

Enumerator
OSP_PARAM_TYPE_INT 

Integer type.

OSP_PARAM_TYPE_STR 

String type.

OSP_PARAM_TYPE_PASSWORD 

Password type.

OSP_PARAM_TYPE_FILE 

File type.

OSP_PARAM_TYPE_BOOLEAN 

Boolean type.

OSP_PARAM_TYPE_OVALDEF_FILE 

Oval definition type.

OSP_PARAM_TYPE_SELECTION 

Selection type.

OSP_PARAM_TYPE_CRD_UP 

Credential user/pass type.

◆ osp_scan_status_t

OSP scan status.

Enumerator
OSP_SCAN_STATUS_ERROR 

Error status.

OSP_SCAN_STATUS_INIT 

Init status.

OSP_SCAN_STATUS_RUNNING 

Running status.

OSP_SCAN_STATUS_STOPPED 

Stopped status.

OSP_SCAN_STATUS_FINISHED 

Finished status.

OSP_SCAN_STATUS_QUEUED 

Queued status

OSP_SCAN_STATUS_INTERRUPTED 

Interrupted status

Function Documentation

◆ osp_check_feed()

int osp_check_feed ( osp_connection_t * connection,
int * lockfile_in_use,
int * self_test_exit_error,
char ** self_test_error_msg,
char ** cmd_error )

Gets additional status info about the feed.

The lockfile_in_use and self_test_exit_error fields will be set to -1 if the corresponding elements are missing.

Parameters
[in]connectionConnection to an OSP server.
[out]lockfile_in_useWhether the lockfile is in use.
[out]self_test_exit_errorWhether the sync script self check failed.
[out]self_test_error_msgSelf check error message if one occurred.
[out]cmd_errorError message of the OSP command.
Returns
0 if success, 1 if error.

◆ osp_connection_close()

void osp_connection_close ( osp_connection_t * connection)

Close a connection to an OSP server.

Parameters
[in]connectionConnection to OSP server to close.

◆ osp_connection_new()

osp_connection_t * osp_connection_new ( const char * ,
int ,
const char * ,
const char * ,
const char *  )

◆ osp_credential_free()

void osp_credential_free ( osp_credential_t * credential)

Free an OSP credential.

Parameters
[in]credentialThe credential to free.

◆ osp_credential_get_auth_data()

const gchar * osp_credential_get_auth_data ( osp_credential_t * credential,
const char * name )

Get authentication data from an OSP credential.

Parameters
[in]credentialThe credential to get the data from.
[in]nameThe name of the data item to get.
Returns
The requested authentication data or NULL if not available.

◆ osp_credential_new()

osp_credential_t * osp_credential_new ( const char * type,
const char * service,
const char * port )

Allocate and initialize a new OSP credential.

Parameters
[in]typeThe credential type.
[in]serviceThe service the credential is for.
[in]portThe port.
Returns
New osp credential.

◆ osp_credential_set_auth_data()

void osp_credential_set_auth_data ( osp_credential_t * credential,
const char * name,
const char * value )

Get authentication data from an OSP credential.

Parameters
[in]credentialThe credential to get the data from.
[in]nameThe name of the data item to get.
[in]valueThe authentication data or NULL to unset.

◆ osp_delete_scan()

int osp_delete_scan ( osp_connection_t * connection,
const char * scan_id )

Delete a scan from an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[in]scan_idID of scan to delete.
Returns
0 if success, 1 if error.

◆ osp_get_performance_ext()

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.

Parameters
[in]connectionConnection to an OSP server.
[in]optsStruct containing the options to apply.
[out]graphGraphic base64 encoded.
[out]errorPointer to error, if any.
Returns
0 if success, -1 if error.

◆ osp_get_scan()

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.

Parameters
[in]connectionConnection to an OSP server.
[in]scan_idID of scan to get.
[out]report_xmlScans report.
[in]details0 for no scan details, 1 otherwise.
[out]errorPointer to error, if any.
Returns
Scan progress if success, -1 if error.

◆ osp_get_scan_pop()

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.

Parameters
[in]connectionConnection to an OSP server.
[in]scan_idID of scan to get.
[out]report_xmlScans report.
[in]details0 for no scan details, 1 otherwise.
[in]pop_results0 to leave results, 1 to pop results from scanner.
[out]errorPointer to error, if any.
Returns
Scan progress if success, -1 if error.

◆ osp_get_scan_status_ext()

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.

Parameters
[in]connectionConnection to an OSP server.
[in]optsStruct containing the options to apply.
[out]errorPointer to error, if any.
Returns
Osp scan status

◆ osp_get_scanner_details()

int osp_get_scanner_details ( osp_connection_t * connection,
char ** desc,
GSList ** params )

Get an OSP scanner's details.

Parameters
[in]connectionConnection to an OSP server.
[out]descScanner's description.
[out]paramsScanner's parameters.
Returns
0 if success, 1 if failure.

◆ osp_get_version()

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.

Parameters
[in]connectionConnection to an OSP server.
[out]s_nameParsed scanner name.
[out]s_versionParsed scanner version.
[out]d_nameParsed scanner name.
[out]d_versionParsed scanner version.
[out]p_nameParsed scanner name.
[out]p_versionParsed scanner version.
Returns
0 if success, 1 if error.

◆ osp_get_vts()

int osp_get_vts ( osp_connection_t * connection,
entity_t * vts )

Get all VTs from an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[out]vtsVTs.
Returns
0 if success, 1 if error.

◆ osp_get_vts_ext()

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.

Parameters
[in]connectionConnection to an OSP server.
[in]optsStruct containing the options to apply.
[out]vtsVTs.
Returns
0 if success, 1 if error.

◆ osp_get_vts_ext_str()

int osp_get_vts_ext_str ( osp_connection_t * connection,
osp_get_vts_opts_t opts,
gchar ** str )

Get filtered set of VTs from an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[in]optsStruct containing the options to apply.
[out]strResponse.
Returns
0 if success, 1 if error.

◆ osp_get_vts_feed_info()

int osp_get_vts_feed_info ( osp_connection_t * connection,
char ** vts_version,
char ** feed_name,
char ** feed_vendor,
char ** feed_home,
char ** error )

Get the VTs version as well as other feed info from an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[out]vts_versionParsed VTs feed version.
[out]feed_nameParsed VTs feed name.
[out]feed_vendorParsed VTs feed vendor.
[out]feed_homeParsed VTs feed home URL.
[out]errorPointer to error, if any.
Returns
0 if success, 1 if error.

◆ osp_get_vts_version()

int osp_get_vts_version ( osp_connection_t * connection,
char ** vts_version,
char ** error )

Get the VTs version from an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[out]vts_versionParsed scanner version.
[out]errorPointer to error, if any.
Returns
0 if success, 1 if error.

◆ osp_param_default()

const char * osp_param_default ( const osp_param_t * param)

Get an OSP parameter's default value.

Parameters
[in]paramOSP parameter.
Returns
Default value of OSP parameter.

◆ osp_param_desc()

const char * osp_param_desc ( const osp_param_t * param)

Get an OSP parameter's description.

Parameters
[in]paramOSP parameter.
Returns
Description of OSP parameter.

◆ osp_param_free()

void osp_param_free ( osp_param_t * param)

Free an OSP parameter.

Parameters
[in]paramOSP parameter to destroy.

◆ osp_param_id()

const char * osp_param_id ( const osp_param_t * param)

Get an OSP parameter's id.

Parameters
[in]paramOSP parameter.
Returns
ID of OSP parameter.

◆ osp_param_mandatory()

int osp_param_mandatory ( const osp_param_t * param)

Get an OSP parameter's mandatory value.

Parameters
[in]paramOSP parameter.
Returns
Mandatory value of OSP parameter.

◆ osp_param_name()

const char * osp_param_name ( const osp_param_t * param)

Get an OSP parameter's name.

Parameters
[in]paramOSP parameter.
Returns
Name of OSP parameter.

◆ osp_param_new()

osp_param_t * osp_param_new ( void )

Create a new OSP parameter.

Returns
New OSP parameter.

◆ osp_param_type_str()

const char * osp_param_type_str ( const osp_param_t * param)

Get an OSP parameter in string format form its type.

Parameters
[in]paramOSP parameter.
Returns
OSP parameter in string format.

◆ osp_start_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.

Parameters
[in]connectionConnection to an OSP server.
[in]targetTarget host to scan.
[in]portsList of ports to scan.
[in]optionsTable of scan options.
[in]scan_iduuid to set for scan, null otherwise.
[out]errorPointer to error, if any.
Returns
0 on success, -1 otherwise.

◆ osp_start_scan_ext()

int osp_start_scan_ext ( osp_connection_t * connection,
osp_start_scan_opts_t opts,
char ** error )

Start an OSP scan against a target.

Parameters
[in]connectionConnection to an OSP server.
[in]optsStruct containing the options to apply.
[out]errorPointer to error, if any.
Returns
0 on success, -1 otherwise.

◆ osp_stop_scan()

int osp_stop_scan ( osp_connection_t * connection,
const char * scan_id,
char ** error )

Stop a scan on an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[in]scan_idID of scan to delete.
[out]errorPointer to error, if any.
Returns
Scan progress if success, -1 if error.

◆ osp_target_add_alive_test_methods()

void osp_target_add_alive_test_methods ( osp_target_t * target,
gboolean icmp,
gboolean tcp_syn,
gboolean tcp_ack,
gboolean arp,
gboolean consider_alive )

Add alive test methods to OSP target.

Parameters
[in]targetThe OSP target to add the methods to.
[in]icmpUse ICMP ping.
[in]tcp_synUse TCP-SYN ping.
[in]tcp_ackUse TCP-ACK ping.
[in]arpUse ARP ping.
[in]consider_aliveConsider host to be alive.

◆ osp_target_add_credential()

void osp_target_add_credential ( osp_target_t * target,
osp_credential_t * credential )

Add a credential to an OSP target.

Parameters
[in]targetThe OSP target to add the credential to.
[in]credentialThe credential to add. Will be freed with target.

◆ osp_target_free()

void osp_target_free ( osp_target_t * target)

Free an OSP target, including all added credentials.

Parameters
[in]targetThe OSP target to free.

◆ osp_target_new()

osp_target_t * osp_target_new ( const char * hosts,
const char * ports,
const char * exclude_hosts,
int alive_test,
int reverse_lookup_unify,
int reverse_lookup_only )

Create a new OSP target.

Parameters
[in]hostsThe hostnames of the target.
[in]portsThe ports of the target.
[in]exclude_hostsThe excluded hosts of the target.
[in]alive_testThe alive test method of the target.
[in]reverse_lookup_unifyLookup flag.
[in]reverse_lookup_onlyLookup flag.
Returns
The newly allocated osp_target_t.

◆ osp_target_set_finished_hosts()

void osp_target_set_finished_hosts ( osp_target_t * target,
const char * finished_hosts )

Set the finished hosts of an OSP target.

Parameters
[in]targetThe OSP target to modify.
[in]finished_hostsThe hostnames to consider finished.

◆ osp_vt_group_free()

void osp_vt_group_free ( osp_vt_group_t * vt_group)

Free a OSP VT group.

Parameters
[in]vt_groupThe VT group to free.

◆ osp_vt_group_new()

osp_vt_group_t * osp_vt_group_new ( const char * filter)

Create a new OSP VT group.

Parameters
[in]filterThe filter string for the VT group.
Returns
The newly allocated VT group.

◆ osp_vt_single_add_value()

void osp_vt_single_add_value ( osp_vt_single_t * vt_single,
const char * name,
const char * value )

Add a preference value to an OSP VT. This creates a copy of the name and value.

Parameters
[in]vt_singleThe VT to add the preference to.
[in]nameThe name / identifier of the preference.
[in]valueThe value of the preference.

◆ osp_vt_single_free()

void osp_vt_single_free ( osp_vt_single_t * vt_single)

Free a single OSP VT, including all preference values.

Parameters
[in]vt_singleThe OSP VT to free.

◆ osp_vt_single_new()

osp_vt_single_t * osp_vt_single_new ( const char * vt_id)

Create a new single OSP VT.

Parameters
[in]vt_idThe id of the VT.
Returns
The newly allocated single VT.

Variable Documentation

◆ osp_get_vts_opts_default

const osp_get_vts_opts_t osp_get_vts_opts_default = {NULL, 0}
static

Sensible default values for osp_get_vts_opts_t.