OpenVAS Scanner  6.0.0~git
Functions
plugs_req.c File Reference

Performs various checks for requirements set in a given plugin. More...

#include "plugs_req.h"
#include "pluginscheduler.h"
#include <gvm/base/prefs.h>
#include <gvm/util/nvticache.h>
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Functions

int kb_get_port_state_proto (kb_t, int, char *)
 
static int get_closed_ports (kb_t kb, char *ports_list, char *proto)
 Returns whether a port in a port list is closed or not. More...
 
static int kb_missing_keyname_of_namelist (kb_t kb, char *keys, char **keyname)
 Returns the name of the first key which is not present in the kb. More...
 
static int kb_present_keyname_of_namelist (kb_t kb, char *keys, char **keyname)
 Returns the name of the first key which is present in the kb. More...
 
static int check_mandatory_keys (kb_t kb, char *keys)
 Checks mandatory keys presence and value in the KB. More...
 
int mandatory_requirements_met (kb_t kb, nvti_t *nvti)
 Check whether mandatory requirements for plugin are met. More...
 
char * requirements_plugin (kb_t kb, nvti_t *nvti)
 Determine if the plugin requirements are met. More...
 

Detailed Description

Performs various checks for requirements set in a given plugin.

Function Documentation

◆ check_mandatory_keys()

static int check_mandatory_keys ( kb_t  kb,
char *  keys 
)
static

Checks mandatory keys presence and value in the KB.

Parameters
[in]kbKB handle where to search for the keys.
[in]keysComma separated list of mandatory keys.
Returns
1 if a key is missing or not matching its value, 0 otherwise.

◆ get_closed_ports()

static int get_closed_ports ( kb_t  kb,
char *  ports_list,
char *  proto 
)
static

Returns whether a port in a port list is closed or not.

Returns
Whether a port in a port list is closed or not.

◆ kb_get_port_state_proto()

int kb_get_port_state_proto ( kb_t  kb,
int  portnum,
char *  proto 
)
Parameters
protoProtocol (udp/tcp). If NULL, "tcp" will be used.

◆ kb_missing_keyname_of_namelist()

static int kb_missing_keyname_of_namelist ( kb_t  kb,
char *  keys,
char **  keyname 
)
static

Returns the name of the first key which is not present in the kb.

Parameters
[in]kbKB handle where to search for the keys.
[in]keysComma separated list of keys.
[out]keynameKey that was missing. Free with g_free().
Returns
1 if a key is missing in KB, 0 otherwise.

◆ kb_present_keyname_of_namelist()

static int kb_present_keyname_of_namelist ( kb_t  kb,
char *  keys,
char **  keyname 
)
static

Returns the name of the first key which is present in the kb.

Parameters
[in]kbKB handle where to search for the keys.
[in]keysComma separated list of keys.
[out]keynameKey that was found. Free with g_free().
Returns
1 if a key is present in KB, 0 otherwise.

◆ mandatory_requirements_met()

int mandatory_requirements_met ( kb_t  kb,
nvti_t *  nvti 
)

Check whether mandatory requirements for plugin are met.

Parameters
kbThe knowledge base with all keys.
pluginThe scheduler plugin.
Returns
1 if all mandatory requirements for the plugin are met. 0 if it is not the case.

◆ requirements_plugin()

char* requirements_plugin ( kb_t  kb,
nvti_t *  nvti 
)

Determine if the plugin requirements are met.

Returns
Returns NULL is everything is ok, else an error message.