|
Greenbone Vulnerability Management Libraries 22.24.0
|
Functions to convert different CPE notations into each other. More...
#include "cpeutils.h"#include <assert.h>#include <ctype.h>#include <errno.h>#include <glib.h>#include <string.h>Go to the source code of this file.
Macros | |
| #define | G_LOG_DOMAIN "libgvm util" |
| GLib logging domain. | |
Functions | |
| static enum set_relation | compare_component (const char *source, const char *target) |
| Returns if the component "source" is a match for the component "target". That means that source is a superset of target. | |
| static enum set_relation | compare_strings (const char *source, const char *target) |
| Returns if the string of a component "source" is a match for the the string of a component "target". That means that source represents a superset of target. | |
| static int | count_escapes (const char *str, int start, int end) |
| Counts the number of unescaped escape signs ("\") in a specified part of a string. | |
| static gboolean | is_even_wildcards (const char *str, int index) |
| Returns true if an even number of escape (backslash) characters precede the character at the index "index" in string "str". | |
| static gboolean | has_wildcards (const char *str) |
| Returns if a given string contains wildcards ("*" or "?"). | |
| static int | index_of (const char *str, const char *sub_str, int offset) |
| Searches the string "str" for the first occurrence of the string "sub_str", starting at the offset "offset" in "str". | |
| static gboolean | is_string (const char *str) |
| Returns if a string is an ordinary string and does not represent one of the logical values "ANY" or "NA". | |
| static char * | get_uri_component (const char *uri_cpe, int index) |
| Get the indexth component of a URI CPE. | |
| static char * | decode_uri_component (const char *component) |
| Decode a component of a URI CPE. | |
| static void | unpack_sixth_uri_component (const char *component, cpe_struct_t *cpe) |
| Unpack the sixth component of a URI CPE. | |
| static char * | get_fs_component (const char *fs_cpe, int index) |
| Get the indexth component of a formatted string CPE. | |
| static char * | unbind_fs_component (char *component) |
| Unbind a formatted string CPE component. | |
| static char * | add_quoting (const char *component) |
| Handle the quoting for an unbind formatted string CPE component. | |
| static char * | bind_cpe_component_for_uri (const char *component) |
| Bind a CPE component for a URI CPE. | |
| static char * | transform_for_uri (const char *component) |
| Transform a CPE component for a URI CPE. | |
| static char * | pack_sixth_uri_component (const cpe_struct_t *cpe) |
| Pack the sixth component of a URI CPE. | |
| static char * | bind_cpe_component_for_fs (const char *component) |
| Bind a CPE component for a formatted string CPE. | |
| static char * | process_quoted_chars (const char *component) |
| Process the quoted characters of a CPE component for a formatted string CPE. | |
| static void | trim_pct (char *str) |
| Cut of trailing ':' signs. | |
| static void | get_code (char *code, const char *str) |
| Get the percent code from the start of a string. | |
| char * | uri_cpe_to_fs_cpe (const char *uri_cpe) |
| Convert a URI CPE to a formatted string CPE. | |
| char * | uri_cpe_to_fs_product (const char *uri_cpe) |
| Convert a URI CPE to a formatted string product. | |
| char * | uri_cpe_to_uri_product (const char *uri_cpe) |
| Convert a URI CPE to a formatted string product. | |
| char * | fs_cpe_to_uri_cpe (const char *fs_cpe) |
| Convert a formatted string CPE to a URI CPE. | |
| char * | fs_cpe_to_uri_product (const char *fs_cpe) |
| Convert a formatted string CPE to an URI product. | |
| void | uri_cpe_to_cpe_struct (const char *uri_cpe, cpe_struct_t *cpe) |
| Read a URI CPE into the CPE struct. | |
| char * | cpe_struct_to_uri_cpe (const cpe_struct_t *cpe) |
| Convert a CPE struct into a URI CPE. | |
| char * | cpe_struct_to_uri_product (const cpe_struct_t *cpe) |
| Convert a CPE struct into a URI product. | |
| char * | get_version_from_uri_cpe (const char *uri_cpe) |
| Get the version from an uri cpe. | |
| void | fs_cpe_to_cpe_struct (const char *fs_cpe, cpe_struct_t *cpe) |
| Read a formatted string CPE into the CPE struct. | |
| char * | cpe_struct_to_fs_cpe (const cpe_struct_t *cpe) |
| Convert a CPE struct into a formatted string CPE. | |
| char * | cpe_struct_to_fs_product (const cpe_struct_t *cpe) |
| Convert a CPE struct into a formatted string product. | |
| void | cpe_struct_init (cpe_struct_t *cpe) |
| Initialize a CPE struct. | |
| void | cpe_struct_free (cpe_struct_t *cpe) |
| Free a CPE struct. | |
| gboolean | cpe_struct_match (cpe_struct_t *source, cpe_struct_t *target) |
| Returns if source is a match for target. That means that source is a superset of target. | |
| gboolean | cpe_struct_match_tail (cpe_struct_t *source, cpe_struct_t *target) |
| Returns if the part behind the version of source is a match for that part of target. That means, that source is a superset of target if also the first part matches. | |
Functions to convert different CPE notations into each other.
This library provides functions to read the CPE 2.2 URI binding of a CPE or the CPE 2.3 formatted string binding of a CPE into a CPE struct that corresponds to the WFN naming of a CPE. Further functions to convert the CPE struct into the different bindings are provided. This file also contains a function that checks if one CPE (represented in a CPE struct) is a match for an other CPE (also represented in a CPE struct).
| #define G_LOG_DOMAIN "libgvm util" |
GLib logging domain.
|
static |
Handle the quoting for an unbind formatted string CPE component.
| [in] | component | The component to add the quotings to. |
|
static |
Bind a CPE component for a formatted string CPE.
| [in] | component | The component to bind. |
|
static |
Bind a CPE component for a URI CPE.
| [in] | component | The component to bind. |
|
static |
Returns if the component "source" is a match for the component "target". That means that source is a superset of target.
| [in] | source | The component of a cpe_struct. |
| [in] | target | The component of a cpe_struct that is checked if it is a subset of source meaning that it is matched by source. |
|
static |
Returns if the string of a component "source" is a match for the the string of a component "target". That means that source represents a superset of target.
| [in] | source | The string of a component of a cpe_struct. |
| [in] | target | The string of a component of a cpe_struct that is checked if it represents a subset of source meaning that it is matched by source. |
|
static |
Counts the number of unescaped escape signs ("\") in a specified part of a string.
| [in] | str | The string to be examined. |
| [in] | start | The start position in the string where the examination begins. |
| [in] | end | The end position in the string where the examination ends. |
| void cpe_struct_free | ( | cpe_struct_t * | cpe | ) |
Free a CPE struct.
| [in/out] | cpe The CPE to be freed. |
| void cpe_struct_init | ( | cpe_struct_t * | cpe | ) |
Initialize a CPE struct.
| [in/out] | cpe The pointer to the CPE to initialize. |
| gboolean cpe_struct_match | ( | cpe_struct_t * | source, |
| cpe_struct_t * | target ) |
Returns if source is a match for target. That means that source is a superset of target.
| [in] | source | The cpe_struct that represents a set of CPEs. |
| [in] | target | The cpe_struct that represents a single CPE or or a set of CPEs that is checked if it is a subset of source meaning that it is matched by source. |
| gboolean cpe_struct_match_tail | ( | cpe_struct_t * | source, |
| cpe_struct_t * | target ) |
Returns if the part behind the version of source is a match for that part of target. That means, that source is a superset of target if also the first part matches.
| [in] | source | The cpe_struct that represents a set of CPEs. |
| [in] | target | The cpe_struct that represents a single CPE or or a set of CPEs that is checked if it is a subset of source meaning that it is matched by source. |
| char * cpe_struct_to_fs_cpe | ( | const cpe_struct_t * | cpe | ) |
Convert a CPE struct into a formatted string CPE.
| [in] | cpe | A pointer to the CPE struct. |
| char * cpe_struct_to_fs_product | ( | const cpe_struct_t * | cpe | ) |
Convert a CPE struct into a formatted string product.
| [in] | cpe | A pointer to the CPE struct. |
| char * cpe_struct_to_uri_cpe | ( | const cpe_struct_t * | cpe | ) |
Convert a CPE struct into a URI CPE.
| [in] | cpe | A pointer to the CPE struct. |
| char * cpe_struct_to_uri_product | ( | const cpe_struct_t * | cpe | ) |
Convert a CPE struct into a URI product.
| [in] | cpe | A pointer to the CPE struct. |
|
static |
Decode a component of a URI CPE.
| [in] | component | The component to decode. |
| void fs_cpe_to_cpe_struct | ( | const char * | fs_cpe, |
| cpe_struct_t * | cpe ) |
Read a formatted string CPE into the CPE struct.
| [in] | fs_cpe | A formatted string CPE. |
| [out] | cpe | Pointer to the filled CPE struct. |
| char * fs_cpe_to_uri_cpe | ( | const char * | fs_cpe | ) |
Convert a formatted string CPE to a URI CPE.
| [in] | fs_cpe | A formatted string CPE. |
| char * fs_cpe_to_uri_product | ( | const char * | fs_cpe | ) |
Convert a formatted string CPE to an URI product.
| [in] | fs_cpe | A formatted string CPE. |
|
static |
Get the percent code from the start of a string.
| [in] | str | The string to get the code from. |
| [out] | code | The percent code. |
|
static |
Get the indexth component of a formatted string CPE.
| [in] | fs_cpe | The formatted string CPE. |
| [in] | index | The number of the component to get. |
|
static |
Get the indexth component of a URI CPE.
| [in] | uri_cpe | The URI CPE. |
| [in] | index | The number of the component to get. |
| char * get_version_from_uri_cpe | ( | const char * | uri_cpe | ) |
Get the version from an uri cpe.
| [in] | uri_cpe | The uri cpe to get the version from. |
|
static |
Returns if a given string contains wildcards ("*" or "?").
| [in] | str | The string to be examined. |
|
static |
Searches the string "str" for the first occurrence of the string "sub_str", starting at the offset "offset" in "str".
| [in] | str | The string to be examined. |
| [in] | sub_str | The string to be searched for in "str". |
| [in] | offset | The offset where to start the search in "str". |
|
static |
Returns true if an even number of escape (backslash) characters precede the character at the index "index" in string "str".
| [in] | str | The string to be examined. |
| [in] | index | The index where the examination starts. |
|
static |
Returns if a string is an ordinary string and does not represent one of the logical values "ANY" or "NA".
| [in] | str | The string to be examined. |
|
static |
Pack the sixth component of a URI CPE.
| [in] | component | The CPE struct with the components to pack into the sixth component of a URI CPE. |
|
static |
Process the quoted characters of a CPE component for a formatted string CPE.
| [in] | component | The component to process. |
|
static |
Transform a CPE component for a URI CPE.
| [in] | component | The component to transform. |
|
static |
Cut of trailing ':' signs.
| [in/out] | str The string to be processed. |
|
static |
Unbind a formatted string CPE component.
| [in] | component | The component to unbind. |
|
static |
Unpack the sixth component of a URI CPE.
| [in] | component | The component to unpack. |
| [out] | cpe | Pointer to the CPE struct where the unpacked and decoded values of the component are stored. |
| void uri_cpe_to_cpe_struct | ( | const char * | uri_cpe, |
| cpe_struct_t * | cpe ) |
Read a URI CPE into the CPE struct.
| [in] | uri_cpe | A CPE v2.2-conformant URI. |
| [out] | cpe | Pointer to the filled CPE struct. |
| char * uri_cpe_to_fs_cpe | ( | const char * | uri_cpe | ) |
Convert a URI CPE to a formatted string CPE.
| [in] | uri_cpe | A CPE v2.2-conformant URI. |
| char * uri_cpe_to_fs_product | ( | const char * | uri_cpe | ) |
Convert a URI CPE to a formatted string product.
| [in] | uri_cpe | A CPE v2.2-conformant URI. |
| char * uri_cpe_to_uri_product | ( | const char * | uri_cpe | ) |
Convert a URI CPE to a formatted string product.
| [in] | uri_cpe | A CPE v2.2-conformant URI. |