Loading...
Searching...
No Matches
cpedict_priv.c File Reference

Interface to Common Platform Enumeration (CPE) Language. More...

`#include <libxml/xmlreader.h>`
`#include <stdlib.h>`
`#include <ctype.h>`
`#include <string.h>`
`#include <stdbool.h>`
`#include "public/cpe_dict.h"`
`#include "public/cpe_name.h"`
`#include "cpedict_ext_priv.h"`
`#include "cpedict_priv.h"`
`#include "cpe_ctx_priv.h"`
`#include "common/list.h"`
`#include "common/elements.h"`
`#include "common/text_priv.h"`
`#include "common/util.h"`
`#include "common/_error.h"`
`#include "common/xmlns_priv.h"`
`#include "common/xmltext_priv.h"`
`#include "source/oscap_source_priv.h"`
`#include "source/public/oscap_source.h"`
Include dependency graph for cpedict_priv.c:

## Data Structures

struct | cpe_item
| Structure representing single CPE dictionary item. More...
struct | cpe_item_metadata
| Structure representing metadata of CPE item. More...
struct | cpe_check
| Structure representing single CPE check. More...
struct | cpe_reference
| CPE dictionary item reference. More...
struct | cpe_generator
| Structure with information about document. More...
struct | cpe_product
| Product of some vendor. More...
struct | cpe_version
| Version of product. More...
struct | cpe_update
| Update of product version. More...
struct | cpe_edition
| Edition of product update. More...
struct | cpe_language
| Language of product edition. More...

## Macros

#define | TAG_CHECK_STR BAD_CAST "check"
#define | TAG_NOTES_STR BAD_CAST "notes"
#define | TAG_REFERENCES_STR BAD_CAST "references"
#define | ATTR_DEP_BY_NVDID_STR BAD_CAST "deprecated-by-nvd-id"
#define | ATTR_NVD_ID_STR BAD_CAST "nvd-id"
#define | ATTR_STATUS_STR BAD_CAST "status"
#define | ATTR_MODIFICATION_DATE_STR BAD_CAST "modification-date"
#define | TAG_ITEM_METADATA_STR BAD_CAST "item-metadata"
#define | TAG_REFERENCE_STR BAD_CAST "reference"
#define | TAG_NOTE_STR BAD_CAST "note"
#define | TAG_TITLE_STR BAD_CAST "title"
#define | TAG_CPE_ITEM_STR BAD_CAST "cpe-item"
#define | ATTR_DEPRECATION_DATE_STR BAD_CAST "deprecation_date"
#define | ATTR_DEPRECATED_BY_STR BAD_CAST "deprecated_by"
#define | ATTR_DEPRECATED_STR BAD_CAST "deprecated"
#define | ATTR_NAME_STR BAD_CAST "name"
#define | TAG_GENERATOR_STR BAD_CAST "generator"
#define | TAG_PRODUCT_STR BAD_CAST "product"
#define | TAG_PRODUCT_NAME_STR BAD_CAST "product_name"
#define | TAG_PRODUCT_VERSION_STR BAD_CAST "product_version"
#define | TAG_SCHEMA_VERSION_STR BAD_CAST "schema_version"
#define | TAG_TIMESTAMP_STR BAD_CAST "timestamp"
#define | TAG_COMPONENT_TREE_STR BAD_CAST "component-tree"
#define | TAG_VENDOR_STR BAD_CAST "vendor"
#define | TAG_CPE_LIST_STR BAD_CAST "cpe-list"
#define | TAG_VERSION_STR BAD_CAST "version"
#define | TAG_UPDATE_STR BAD_CAST "update"
#define | TAG_EDITION_STR BAD_CAST "edition"
#define | TAG_LANGUAGE_STR BAD_CAST "language"
#define | ATTR_VALUE_STR BAD_CAST "value"
#define | ATTR_PART_STR BAD_CAST "part"
#define | ATTR_SYSTEM_STR BAD_CAST "system"
#define | ATTR_HREF_STR BAD_CAST "href"
#define | NS_META_STR BAD_CAST "meta"
#define | ATTR_XML_LANG_STR BAD_CAST "xml:lang"
#define | VAL_TRUE_STR BAD_CAST "true"

## Functions

| OSCAP_ITERATOR_REMOVE_F (cpe_reference)
| OSCAP_IGETINS_GEN (cpe_item, OSCAP_ITERATOR_REMOVE_Fc cpe_dict_model, items, item)
struct cpe_notes * | cpe_notes_new (void)
void | cpe_notes_free (struct cpe_notes *notes)
struct cpe_dict_model * | cpe_dict_model_new ()
struct cpe_item_metadata * | cpe_item_metadata_new ()
struct cpe_item * | cpe_item_new ()
struct cpe_check * | cpe_check_new ()
struct cpe_reference * | cpe_reference_new ()
struct cpe_generator * | cpe_generator_new ()
struct cpe_vendor * | cpe_vendor_new ()
struct cpe_product * | cpe_product_new ()
struct cpe_version * | cpe_version_new ()
struct cpe_update * | cpe_update_new ()
struct cpe_edition * | cpe_edition_new ()
struct cpe_language * | cpe_language_new ()
struct cpe_dict_model * | cpe_dict_model_parse (struct cpe_parser_ctx *ctx)
| Load new CPE dictionary from XML node.
struct cpe_generator * | cpe_generator_parse (struct cpe_parser_ctx *ctx)
| Parse generator part of CPE dictionary XML file.
struct cpe_item * | cpe_item_parse (struct cpe_parser_ctx *ctx)
| New dictionary item from XML.
struct cpe_vendor * | cpe_vendor_parse (xmlTextReaderPtr reader)
| Parsing function to parse vendors of CPE dictionary.
void | cpe_dict_model_export_xml (const struct cpe_dict_model *dict, const char *file)
| Export function for CPE dictionary model.
void | cpe_dict_export (const struct cpe_dict_model *dict, xmlTextWriterPtr writer)
| Internal export function for CPE dictionary model.
void | cpe_generator_export (const struct cpe_generator *generator, xmlTextWriterPtr writer)
| Exporting function for CPE generator - information of XML document.
void | cpe_item_export (const struct cpe_item *item, xmlTextWriterPtr writer, int base_version)
| Exporting function for CPE item.
void | cpe_vendor_export (const struct cpe_vendor *vendor, xmlTextWriterPtr writer)
| Exporting function for CPE vendor.
bool | cpe_dict_model_set_origin_file (struct cpe_dict_model *dict, const char *origin_file)
| Sets the origin file hint.
const char * | cpe_dict_model_get_origin_file (const struct cpe_dict_model *dict)
| Gets the file the CPE dict model was loaded from This is necessary to figure out the full OVAL file path for applicability testing.
void | cpe_dict_model_free (struct cpe_dict_model *dict)
void | cpe_item_free (struct cpe_item *item)
void | cpe_generator_free (struct cpe_generator *generator)
void | cpe_check_free (struct cpe_check *check)
void | cpe_reference_free (struct cpe_reference *ref)
void | cpe_vendor_free (struct cpe_vendor *vendor)
void | cpe_product_free (struct cpe_product *product)
void | cpe_version_free (struct cpe_version *version)
void | cpe_update_free (struct cpe_update *update)
void | cpe_edition_free (struct cpe_edition *edition)
void | cpe_language_free (struct cpe_language *language)
void | cpe_itemmetadata_free (struct cpe_item_metadata *meta)

## Variables

const char * | PART_TO_CHAR [] = { NULL, "h", "o", "a" }

## Detailed Description

Interface to Common Platform Enumeration (CPE) Language.

See more details at http://nvd.nist.gov/cpe.cfm

## Function Documentation

## cpe_dict_export()

void cpe_dict_export | ( | const struct cpe_dict_model * | dict,
|  | xmlTextWriterPtr | writer )

Internal export function for CPE dictionary model.

Parameters

  dict | CPE dictionary
  writer | xmlTextWriterPtr representing XML model

## cpe_dict_model_export_xml()

void cpe_dict_model_export_xml | ( | const struct cpe_dict_model * | dict,
|  | const char * | file )

Export function for CPE dictionary model.

Parameters

  dict | CPE dictionary structure
  file | filename to export

## cpe_dict_model_get_origin_file()

const char * cpe_dict_model_get_origin_file | ( | const struct cpe_dict_model * | dict | ) |

Gets the file the CPE dict model was loaded from This is necessary to figure out the full OVAL file path for applicability testing.

We can't do applicability here in the CPE module because that would create awful interdependencies.

## cpe_dict_model_parse()

struct cpe_dict_model * cpe_dict_model_parse | ( | struct cpe_parser_ctx * | ctx | ) |

Load new CPE dictionary from XML node.

Parameters

  ctx | CPE parser context

Returns
  new dictionary

Return values

  NULL | on failure

## cpe_dict_model_set_origin_file()

bool cpe_dict_model_set_origin_file | ( | struct cpe_dict_model * | dict,
|  | const char * | origin_file )

Sets the origin file hint.

See also
  cpe_dict_model_get_origin_file

## cpe_generator_export()

void cpe_generator_export | ( | const struct cpe_generator * | generator,
|  | xmlTextWriterPtr | writer )

Exporting function for CPE generator - information of XML document.

Parameters

  generator | CPE generator structure
  writer | xmlTextWriterPtr representing XML model

## cpe_generator_parse()

struct cpe_generator * cpe_generator_parse | ( | struct cpe_parser_ctx * | ctx | ) |

Parse generator part of CPE dictionary XML file.

Parameters

  ctx | CPE Parser's context

Returns
  new structure cpe_generator

## cpe_item_export()

void cpe_item_export | ( | const struct cpe_item * | item,
|  | xmlTextWriterPtr | writer,
|  | int | base_version )

Exporting function for CPE item.

Parameters

  item | CPE item structure
  writer | xmlTextWriterPtr representing XML model
  base_version | what is the base version of target CPE dict (1 for CPE 1.x, 2 for CPE 2.x, ...)

## cpe_item_parse()

struct cpe_item * cpe_item_parse | ( | struct cpe_parser_ctx * | ctx | ) |

New dictionary item from XML.

Parameters

  ctx | CPE parser's context

Returns
  new dictionary item

Return values

  NULL | on failure

## cpe_vendor_export()

void cpe_vendor_export | ( | const struct cpe_vendor * | vendor,
|  | xmlTextWriterPtr | writer )

Exporting function for CPE vendor.

Parameters

  vendor | CPE vendor structure
  writer | xmlTextWriterPtr representing XML model

## cpe_vendor_parse()

struct cpe_vendor * cpe_vendor_parse | ( | xmlTextReaderPtr | reader | ) |

Parsing function to parse vendors of CPE dictionary.

Parameters

  reader | xmlTextReaderPtr representing XML model

Returns
  new structure cpe_vendor

## OSCAP_ITERATOR_REMOVE_F()

OSCAP_ITERATOR_REMOVE_F | ( | cpe_reference |  | ) |

< representation of <notes> element

< xml:lang attribute

< list of inner <note> elements