|
Greenbone Vulnerability Manager
21.4.5
|
Module for Greenbone Vulnerability Manager: Manage library utilities. More...
#include "manage_utils.h"#include <assert.h>#include <ctype.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <gvm/base/hosts.h>#include <gvm/util/uuidutils.h>Macros | |
| #define | G_LOG_DOMAIN "md utils" |
| GLib log domain. | |
| #define | SECS_PER_DAY 86400 |
| Number of seconds in a day. | |
| #define | GVM_PRODID |
| GVM product ID. More... | |
| #define | ICAL_RETURN_ERROR(message) |
| Error return for icalendar_from_string. More... | |
Functions | |
| long | current_offset (const char *zone) |
| Get the current offset from UTC of a timezone. More... | |
| time_t | add_months (time_t time, int months) |
| Add months to a time. More... | |
| int | manage_count_hosts_max (const char *given_hosts, const char *exclude_hosts, int max_hosts) |
| Return number of hosts described by a hosts string. More... | |
| double | level_min_severity (const char *level) |
| Get the minimum severity for a severity level. More... | |
| double | level_max_severity (const char *level) |
| Get the maximum severity for a severity level. More... | |
| int | hosts_str_contains (const char *hosts_str, const char *find_host_str, int max_hosts) |
| Returns whether a host has an equal host in a hosts string. More... | |
| int | valid_db_resource_type (const char *type) |
| Check whether a resource type table name is valid. More... | |
| void | blank_control_chars (char *string) |
| Replace any control characters in string with spaces. More... | |
| icaltimezone * | icalendar_timezone_from_string (const char *tzid) |
| Try to get a built-in libical timezone from a tzid or city name. More... | |
| icalcomponent * | icalendar_from_old_schedule_data (time_t first_time, time_t period, time_t period_months, time_t duration, int byday_mask) |
| Create an iCalendar component from old schedule data. More... | |
| static icalcomponent * | icalendar_simplify_vevent (icalcomponent *vevent, icaltimezone *zone, gchar **error, GString *warnings_buffer) |
| Simplify an VEVENT iCal component. More... | |
| icalcomponent * | icalendar_from_string (const char *ical_string, icaltimezone *zone, gchar **error) |
| Creates a new, simplified VCALENDAR component from a string. More... | |
| int | icalendar_approximate_rrule_from_vcalendar (icalcomponent *vcalendar, time_t *period, time_t *period_months, int *byday_mask) |
| Approximate the recurrence of a VCALENDAR as classic schedule data. The VCALENDAR must have simplified with icalendar_from_string for this to work reliably. More... | |
| static GPtrArray * | icalendar_times_from_vevent (icalcomponent *vevent, icalproperty_kind type) |
| Collect the times of EXDATE or RDATE properties from an VEVENT. The returned GPtrArray will contain pointers to icaltimetype structs, which will be freed with g_ptr_array_free. More... | |
| static gboolean | icalendar_time_matches_array (icaltimetype time, GPtrArray *times_array) |
| Tests if an icaltimetype matches one in a GPtrArray. When an icaltimetype is a date, only the date must match, otherwise both date and time must match. More... | |
| static time_t | icalendar_next_time_from_rdates (GPtrArray *rdates, icaltimetype ref_time_ical, icaltimezone *tz, int periods_offset) |
| Get the next or previous time from a list of RDATEs. More... | |
| static time_t | icalendar_next_time_from_recurrence (struct icalrecurrencetype recurrence, icaltimetype dtstart, icaltimetype reference_time, icaltimezone *tz, GPtrArray *exdates, GPtrArray *rdates, int periods_offset) |
| Calculate the next time of a recurrence. More... | |
| time_t | icalendar_next_time_from_vcalendar (icalcomponent *vcalendar, const char *default_tzid, int periods_offset) |
| Get the next or previous due time from a VCALENDAR component. The VCALENDAR must have simplified with icalendar_from_string for this to work reliably. More... | |
| time_t | icalendar_next_time_from_string (const char *ical_string, const char *default_tzid, int periods_offset) |
| Get the next or previous due time from a VCALENDAR string. The string must be a VCALENDAR simplified with icalendar_from_string for this to work reliably. More... | |
| int | icalendar_duration_from_vcalendar (icalcomponent *vcalendar) |
| Get the duration VCALENDAR component. The VCALENDAR must have simplified with icalendar_from_string for this to work reliably. More... | |
| time_t | icalendar_first_time_from_vcalendar (icalcomponent *vcalendar, icaltimezone *default_tz) |
| Get the first time from a VCALENDAR component. The VCALENDAR must have simplified with icalendar_from_string for this to work reliably. More... | |
| gchar * | clean_hosts_string (const char *hosts) |
| Cleans up a hosts string, removing extra zeroes from IPv4 addresses. More... | |
Module for Greenbone Vulnerability Manager: Manage library utilities.
The Greenbone Vulnerability Manager management library.
Utilities used by the manage library that do not depend on anything.
| #define GVM_PRODID |
GVM product ID.
| #define ICAL_RETURN_ERROR | ( | message | ) |
Error return for icalendar_from_string.
| time_t add_months | ( | time_t | time, |
| int | months | ||
| ) |
Add months to a time.
| [in] | time | Time. |
| [in] | months | Months. |
| void blank_control_chars | ( | char * | string | ) |
Replace any control characters in string with spaces.
| [in,out] | string | String to replace in. |
| gchar* clean_hosts_string | ( | const char * | hosts | ) |
Cleans up a hosts string, removing extra zeroes from IPv4 addresses.
| [in] | hosts | The hosts string to clean. |
| long current_offset | ( | const char * | zone | ) |
Get the current offset from UTC of a timezone.
| [in] | zone | Timezone, or NULL for UTC. |
| int hosts_str_contains | ( | const char * | hosts_str, |
| const char * | find_host_str, | ||
| int | max_hosts | ||
| ) |
Returns whether a host has an equal host in a hosts string.
For example, 192.168.10.1 has an equal in a hosts string "192.168.10.1-5, 192.168.10.10-20" string while 192.168.10.7 doesn't.
| [in] | hosts_str | Hosts string to check. |
| [in] | find_host_str | The host to find. |
| [in] | max_hosts | Maximum number of hosts allowed in hosts_str. |
| int icalendar_approximate_rrule_from_vcalendar | ( | icalcomponent * | vcalendar, |
| time_t * | period, | ||
| time_t * | period_months, | ||
| int * | byday_mask | ||
| ) |
Approximate the recurrence of a VCALENDAR as classic schedule data. The VCALENDAR must have simplified with icalendar_from_string for this to work reliably.
| [in] | vcalendar | The VCALENDAR component to get the data from. |
| [out] | period | Output of the period in seconds. |
| [out] | period_months | Output of the period in months. |
| [out] | byday_mask | Output of the GVM byday mask. |
| int icalendar_duration_from_vcalendar | ( | icalcomponent * | vcalendar | ) |
Get the duration VCALENDAR component. The VCALENDAR must have simplified with icalendar_from_string for this to work reliably.
| [in] | vcalendar | The VCALENDAR component to get the time from. |
| time_t icalendar_first_time_from_vcalendar | ( | icalcomponent * | vcalendar, |
| icaltimezone * | default_tz | ||
| ) |
Get the first time from a VCALENDAR component. The VCALENDAR must have simplified with icalendar_from_string for this to work reliably.
| [in] | vcalendar | The VCALENDAR component to get the time from. |
| [in] | default_tz | Timezone to use if none is set in the iCal. |
| icalcomponent* icalendar_from_old_schedule_data | ( | time_t | first_time, |
| time_t | period, | ||
| time_t | period_months, | ||
| time_t | duration, | ||
| int | byday_mask | ||
| ) |
Create an iCalendar component from old schedule data.
| [in] | first_time | The first run time. |
| [in] | period | The period in seconds. |
| [in] | period_months | The period in months. |
| [in] | duration | The duration in seconds. |
| [in] | byday_mask | The byday mask. |
| icalcomponent* icalendar_from_string | ( | const char * | ical_string, |
| icaltimezone * | zone, | ||
| gchar ** | error | ||
| ) |
Creates a new, simplified VCALENDAR component from a string.
| [in] | ical_string | The ical_string to create the component from. |
| [in] | zone | Timezone. |
| [out] | error | Output of iCal errors or warnings. |
|
static |
Get the next or previous time from a list of RDATEs.
| [in] | rdates | The list of RDATEs. |
| [in] | tz | The icaltimezone to use. |
| [in] | ref_time_ical | The reference time (usually the current time). |
| [in] | periods_offset | 0 for next, -1 for previous from/before reference. |
|
static |
Calculate the next time of a recurrence.
| [in] | recurrence | The recurrence rule to evaluate. |
| [in] | dtstart | The start time of the recurrence. |
| [in] | reference_time | The reference time (usually the current time). |
| [in] | tz | The icaltimezone to use. |
| [in] | exdates | GList of EXDATE dates or datetimes to skip. |
| [in] | rdates | GList of RDATE datetimes to include. |
| [in] | periods_offset | 0 for next, -1 for previous from/before reference. |
| time_t icalendar_next_time_from_string | ( | const char * | ical_string, |
| const char * | default_tzid, | ||
| int | periods_offset | ||
| ) |
Get the next or previous due time from a VCALENDAR string. The string must be a VCALENDAR simplified with icalendar_from_string for this to work reliably.
| [in] | ical_string | The VCALENDAR string to get the time from. |
| [in] | default_tzid | Timezone id to use if none is set in the iCal. |
| [in] | periods_offset | 0 for next, -1 for previous from/before now. |
| time_t icalendar_next_time_from_vcalendar | ( | icalcomponent * | vcalendar, |
| const char * | default_tzid, | ||
| int | periods_offset | ||
| ) |
Get the next or previous due time from a VCALENDAR component. The VCALENDAR must have simplified with icalendar_from_string for this to work reliably.
| [in] | vcalendar | The VCALENDAR component to get the time from. |
| [in] | default_tzid | Timezone id to use if none is set in the iCal. |
| [in] | periods_offset | 0 for next, -1 for previous from/before now. |
|
static |
Simplify an VEVENT iCal component.
| [in] | vevent | The VEVENT component to simplify. |
| [in] | zone | Timezone. |
| [out] | error | Output of iCal errors or warnings. |
| [out] | warnings_buffer | GString buffer to write warnings to. |
|
static |
Tests if an icaltimetype matches one in a GPtrArray. When an icaltimetype is a date, only the date must match, otherwise both date and time must match.
| [in] | time | The icaltimetype to try to find a match of. |
| [in] | times_array | Array of pointers to check for a matching time. |
|
static |
Collect the times of EXDATE or RDATE properties from an VEVENT. The returned GPtrArray will contain pointers to icaltimetype structs, which will be freed with g_ptr_array_free.
| [in] | vevent | The VEVENT component to collect times. |
| [in] | type | The property to get the times from. |
| icaltimezone* icalendar_timezone_from_string | ( | const char * | tzid | ) |
Try to get a built-in libical timezone from a tzid or city name.
| [in] | tzid | The tzid or Olson city name. |
| double level_max_severity | ( | const char * | level | ) |
Get the maximum severity for a severity level.
This function has a database equivalent in manage_pg_server.c. These two functions must stay in sync.
| [in] | level | The name of the severity level. |
| double level_min_severity | ( | const char * | level | ) |
Get the minimum severity for a severity level.
This function has a database equivalent in manage_pg_server.c. These two functions must stay in sync.
| [in] | level | The name of the severity level. |
| int manage_count_hosts_max | ( | const char * | given_hosts, |
| const char * | exclude_hosts, | ||
| int | max_hosts | ||
| ) |
Return number of hosts described by a hosts string.
| [in] | given_hosts | String describing hosts. |
| [in] | exclude_hosts | String describing hosts excluded from given set. |
| [in] | max_hosts | Max hosts. |
| int valid_db_resource_type | ( | const char * | type | ) |
Check whether a resource type table name is valid.
| [in] | type | Type of resource. |
1.8.14