Greenbone Vulnerability Management Libraries 22.18.1
|
API for Openvas Daemon communication. More...
#include "../base/nvti.h"
#include "../util/jsonpull.h"
#include <glib.h>
#include <stdio.h>
#include <time.h>
Go to the source code of this file.
Data Structures | |
struct | openvasd_result |
Struct to hold an scan result. More... | |
struct | openvasd_response |
struct | openvasd_scan_status |
Typedefs | |
typedef struct openvasd_response * | openvasd_resp_t |
typedef enum OPENVASD_RESULT_MEMBER_INT | openvasd_result_member_int_t |
typedef enum OPENVASD_RESULT_MEMBER_STRING | openvasd_result_member_string_t |
typedef enum OPENVASD_CONNECTOR_OPTS | openvasd_conn_opt_t |
typedef enum OPENVASD_ERROR | openvasd_error_t |
typedef struct openvasd_result * | openvasd_result_t |
typedef struct openvasd_connector * | openvasd_connector_t |
typedef struct openvasd_scan_status * | openvasd_scan_status_t |
typedef struct openvasd_param | openvasd_param_t |
typedef struct openvasd_target | openvasd_target_t |
typedef struct openvasd_vt_single | openvasd_vt_single_t |
typedef struct openvasd_credential | openvasd_credential_t |
Enumerations | |
enum | OPENVASD_ERROR { OPENVASD_INVALID_OPT , OPENVASD_NOT_INITIALIZED , OPENVASD_INVALID_VALUE , OPENVASD_ERROR , OPENVASD_OK } |
Openvasd Errors. More... | |
enum | OPENVASD_CONNECTOR_OPTS { OPENVASD_CA_CERT , OPENVASD_CERT , OPENVASD_KEY , OPENVASD_API_KEY , OPENVASD_SERVER , OPENVASD_HOST , OPENVASD_SCAN_ID , OPENVASD_PORT } |
Openvasd options for the connector builder. More... | |
enum | OPENVASD_RESULT_MEMBER_STRING { TYPE , IP_ADDRESS , HOSTNAME , OID , PROTOCOL , MESSAGE , DETAIL_NAME , DETAIL_VALUE , DETAIL_SOURCE_NAME , DETAIL_SOURCE_TYPE , DETAIL_SOURCE_DESCRIPTION } |
enum | OPENVASD_RESULT_MEMBER_INT { ID , PORT } |
enum | openvasd_status_t { OPENVASD_SCAN_STATUS_ERROR = -2 , OPENVASD_SCAN_STATUS_FAILED = -1 , OPENVASD_SCAN_STATUS_STORED , OPENVASD_SCAN_STATUS_REQUESTED , OPENVASD_SCAN_STATUS_RUNNING , OPENVASD_SCAN_STATUS_STOPPED , OPENVASD_SCAN_STATUS_SUCCEEDED } |
Openvasd scan status. More... | |
API for Openvas Daemon communication.
typedef enum OPENVASD_CONNECTOR_OPTS openvasd_conn_opt_t |
typedef struct openvasd_connector* openvasd_connector_t |
typedef struct openvasd_credential openvasd_credential_t |
typedef enum OPENVASD_ERROR openvasd_error_t |
typedef struct openvasd_param openvasd_param_t |
typedef struct openvasd_response* openvasd_resp_t |
typedef enum OPENVASD_RESULT_MEMBER_INT openvasd_result_member_int_t |
typedef struct openvasd_result* openvasd_result_t |
typedef struct openvasd_scan_status* openvasd_scan_status_t |
typedef struct openvasd_target openvasd_target_t |
typedef struct openvasd_vt_single openvasd_vt_single_t |
enum OPENVASD_ERROR |
enum openvasd_status_t |
Openvasd scan status.
char * openvasd_build_scan_config_json | ( | openvasd_target_t * | target, |
GHashTable * | scan_preferences, | ||
GSList * | vts ) |
Build a json object with data necessary to start a scan.
JSON result consists of scan_id, message type, host ip, hostname, port, together with proto, OID, result message and uri.
target | target |
scan_preferences | Scan preferences to be added to the scan config |
vts | VTS collection to be added to the scan config. |
openvasd_error_t openvasd_connector_builder | ( | openvasd_connector_t | conn, |
openvasd_conn_opt_t | opt, | ||
const void * | val ) |
Build a openvasd connector.
Receive option name and value to build the openvasd connector
conn | struct holding the openvasd connector information |
opt | option to set |
val | value to set |
openvasd_error_t openvasd_connector_free | ( | openvasd_connector_t | conn | ) |
Build a openvasd connector.
Receive option name and value to build the openvasd connector
conn | struct holding the openvasd connector information |
openvasd_connector_t openvasd_connector_new | ( | void | ) |
Initialize an openvasd connector.
void openvasd_credential_free | ( | openvasd_credential_t * | credential | ) |
Free an Openvasd credential.
credential | The credential to free. |
openvasd_credential_t * openvasd_credential_new | ( | const gchar * | type, |
const gchar * | service, | ||
const gchar * | port ) |
Allocate and initialize a new Openvasd credential.
type | The credential type. |
service | The service the credential is for. |
port | The port. |
void openvasd_credential_set_auth_data | ( | openvasd_credential_t * | credential, |
const gchar * | name, | ||
const gchar * | value ) |
Get authentication data from an Openvasd credential.
credential | The credential to get the data from. |
name | The name of the data item to get. |
value | The authentication data or NULL to unset. |
openvasd_resp_t openvasd_delete_scan | ( | openvasd_connector_t | conn | ) |
openvasd_resp_t openvasd_get_health_alive | ( | openvasd_connector_t | conn | ) |
openvasd_resp_t openvasd_get_health_ready | ( | openvasd_connector_t | conn | ) |
openvasd_resp_t openvasd_get_health_started | ( | openvasd_connector_t | conn | ) |
int openvasd_get_result_member_int | ( | openvasd_result_t | result, |
openvasd_result_member_int_t | member ) |
char * openvasd_get_result_member_str | ( | openvasd_result_t | result, |
openvasd_result_member_string_t | member ) |
openvasd_resp_t openvasd_get_scan_preferences | ( | openvasd_connector_t | conn | ) |
int openvasd_get_scan_progress | ( | openvasd_connector_t | conn | ) |
openvasd_resp_t openvasd_get_scan_results | ( | openvasd_connector_t | conn, |
long | first, | ||
long | last ) |
openvasd_resp_t openvasd_get_scan_status | ( | openvasd_connector_t | conn | ) |
openvasd_resp_t openvasd_get_version | ( | openvasd_connector_t | conn | ) |
Request HEAD.
conn | Connector struct with the data necessary for the connection |
int openvasd_get_vt_stream | ( | openvasd_connector_t | conn | ) |
Get a new feed metadata chunk.
This function must be call until the return value is 0, meaning there is no more data to fetch.
mhnd | Curl multiperfom for requesting the feed metadata |
openvasd_resp_t openvasd_get_vt_stream_init | ( | openvasd_connector_t | conn | ) |
Initialized an curl multiperform handler which allows fetch feed metadata chunk by chunk.
conn | Connector struct with the data necessary for the connection |
mhnd | The curl multiperform handler. It the caller doesn't provide it initialized, it will be initialized. The caller has to free it with openvasd_curlm_handler_close(). |
resp | The stringstream struct for the write callback function. |
openvasd_resp_t openvasd_get_vts | ( | openvasd_connector_t | conn | ) |
Get VT's metadata.
conn | Connector struct with the data necessary for the connection |
char * openvasd_param_default | ( | openvasd_param_t * | param | ) |
Get the parameter default.
param | Openvasd parameter |
char * openvasd_param_desc | ( | openvasd_param_t * | param | ) |
Get the parameter description.
param | Openvasd parameter |
void openvasd_param_free | ( | openvasd_param_t * | param | ) |
Free an Openvasd parameter.
param | Openvasd parameter to destroy. |
char * openvasd_param_id | ( | openvasd_param_t * | param | ) |
Get the parameter id.
param | Openvasd parameter |
int openvasd_param_mandatory | ( | openvasd_param_t * | param | ) |
If the parameter is mandatory.
param | Openvasd parameter |
char * openvasd_param_name | ( | openvasd_param_t * | param | ) |
Get the parameter default.
param | Openvasd parameter |
char * openvasd_param_type | ( | openvasd_param_t * | param | ) |
Get the parameter type.
param | Openvasd parameter |
nvti_t * openvasd_parse_vt | ( | gvm_json_pull_parser_t * | parser, |
gvm_json_pull_event_t * | event ) |
Parse a VT element given in json format.
parser | Json pull parser. |
event | Json pull event. |
int openvasd_parsed_results | ( | openvasd_connector_t | conn, |
unsigned long | first, | ||
unsigned long | last, | ||
GSList ** | results ) |
openvasd_scan_status_t openvasd_parsed_scan_status | ( | openvasd_connector_t | conn | ) |
Return a struct with the general scan status.
conn | Openvasd connector data |
int openvasd_parsed_scans_preferences | ( | openvasd_connector_t | conn, |
GSList ** | params ) |
void openvasd_reset_vt_stream | ( | openvasd_connector_t | conn | ) |
void openvasd_response_cleanup | ( | openvasd_resp_t | resp | ) |
Free an openvasd response struct.
resp | Response to be freed |
void openvasd_result_free | ( | openvasd_result_t | result | ) |
openvasd_result_t openvasd_result_new | ( | unsigned long | id, |
gchar * | type, | ||
gchar * | ip_address, | ||
gchar * | hostname, | ||
gchar * | oid, | ||
int | port, | ||
gchar * | protocol, | ||
gchar * | message, | ||
gchar * | detail_name, | ||
gchar * | detail_value, | ||
gchar * | detail_source_type, | ||
gchar * | detail_source_name, | ||
gchar * | detail_source_description ) |
openvasd_resp_t openvasd_start_scan | ( | openvasd_connector_t | conn, |
gchar * | data ) |
@Brief Get VT's metadata
conn | Connector struct with the data necessary for the connection |
data | String containing the scan config in JSON format. |
openvasd_resp_t openvasd_stop_scan | ( | openvasd_connector_t | conn | ) |
void openvasd_target_add_alive_test_methods | ( | openvasd_target_t * | target, |
gboolean | icmp, | ||
gboolean | tcp_syn, | ||
gboolean | tcp_ack, | ||
gboolean | arp, | ||
gboolean | consider_alive ) |
Add alive test methods to Openvasd target.
target | The Openvasd target to add the methods to. |
icmp | Use ICMP ping. |
tcp_syn | Use TCP-SYN ping. |
tcp_ack | Use TCP-ACK ping. |
arp | Use ARP ping. |
consider_alive | Consider host to be alive. |
void openvasd_target_add_credential | ( | openvasd_target_t * | target, |
openvasd_credential_t * | credential ) |
Add a credential to an Openvasd target.
target | The Openvasd target to add the credential to. |
credential | The credential to add. Will be freed with target. |
void openvasd_target_free | ( | openvasd_target_t * | target | ) |
Free an Openvasd target, including all added credentials.
target | The Openvasd target to free. |
openvasd_target_t * openvasd_target_new | ( | const gchar * | scanid, |
const gchar * | hosts, | ||
const gchar * | ports, | ||
const gchar * | exclude_hosts, | ||
int | reverse_lookup_unify, | ||
int | reverse_lookup_only ) |
Create a new Openvasd target.
scanid | Scan ID. |
hosts | The hostnames of the target. |
ports | The ports of the target. |
exclude_hosts | The excluded hosts of the target. |
reverse_lookup_unify | Lookup flag. |
reverse_lookup_only | Lookup flag. |
void openvasd_target_set_finished_hosts | ( | openvasd_target_t * | target, |
const gchar * | finished_hosts ) |
Set the finished hosts of an Openvasd target.
target | The Openvasd target to modify. |
finished_hosts | The hostnames to consider finished. |
void openvasd_vt_single_add_value | ( | openvasd_vt_single_t * | vt_single, |
const gchar * | name, | ||
const gchar * | value ) |
Add a preference value to an Openvasd VT.
This creates a copy of the name and value.
vt_single | The VT to add the preference to. |
name | The name / identifier of the preference. |
value | The value of the preference. |
void openvasd_vt_single_free | ( | openvasd_vt_single_t * | vt_single | ) |
Free a single Openvasd VT, including all preference values.
vt_single | The Openvasd VT to free. |
openvasd_vt_single_t * openvasd_vt_single_new | ( | const gchar * | vt_id | ) |
Create a new single Openvasd VT.
vt_id | The id of the VT. |
size_t openvasd_vt_stream_len | ( | openvasd_connector_t | conn | ) |
char * openvasd_vt_stream_str | ( | openvasd_connector_t | conn | ) |