| 1 | /** |
| 2 | * @file oval_definitions_impl.h |
| 3 | * \brief Open Vulnerability and Assessment Language |
| 4 | * |
| 5 | * See more details at http://oval.mitre.org/ |
| 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * Copyright 2009--2013 Red Hat Inc., Durham, North Carolina. |
| 10 | * All Rights Reserved. |
| 11 | * |
| 12 | * This library is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU Lesser General Public |
| 14 | * License as published by the Free Software Foundation; either |
| 15 | * version 2.1 of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This library is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 20 | * Lesser General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU Lesser General Public |
| 23 | * License along with this library; if not, write to the Free Software |
| 24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 | * |
| 26 | * Authors: |
| 27 | * "David Niemoller" <[email protected]> |
| 28 | */ |
| 29 | |
| 30 | #ifndef OVAL_DEFINITIONS_IMPL |
| 31 | #define OVAL_DEFINITIONS_IMPL |
| 32 | |
| 33 | #include <libxml/xmlreader.h> |
| 34 | #include "public/oval_definitions.h" |
| 35 | #include "public/oval_system_characteristics.h" |
| 36 | #if defined(OVAL_PROBES_ENABLED) |
| 37 | # include "public/oval_probe_session.h" |
| 38 | #endif |
| 39 | #include "public/oval_system_characteristics.h" |
| 40 | #include "oval_parser_impl.h" |
| 41 | #include "adt/oval_string_map_impl.h" |
| 42 | #include "../common/util.h" |
| 43 | |
| 44 | |
| 45 | oval_family_t oval_family_parse(xmlTextReaderPtr); |
| 46 | xmlNs *oval_family_to_namespace(oval_family_t family, const char *schema_ns, xmlDoc *doc, xmlNode *parent); |
| 47 | oval_subtype_t oval_subtype_parse(xmlTextReaderPtr); |
| 48 | oval_affected_family_t oval_affected_family_parse(xmlTextReaderPtr); |
| 49 | oval_operator_t oval_operator_parse(xmlTextReaderPtr, char *, oval_operator_t); |
| 50 | oval_operation_t oval_operation_parse(xmlTextReaderPtr, char *, oval_operation_t); |
| 51 | oval_definition_class_t oval_definition_class_parse(xmlTextReaderPtr); |
| 52 | oval_existence_t oval_existence_parse(xmlTextReaderPtr, char *, oval_existence_t); |
| 53 | oval_check_t oval_check_parse(xmlTextReaderPtr, char *, oval_check_t); |
| 54 | const char *oval_check_get_description(oval_check_t); |
| 55 | oval_entity_type_t oval_entity_type_parse(xmlTextReaderPtr); |
| 56 | oval_datatype_t oval_datatype_parse(xmlTextReaderPtr, char *, oval_datatype_t); |
| 57 | oval_entity_varref_type_t oval_entity_varref_type_parse(xmlTextReaderPtr); |
| 58 | oval_setobject_type_t oval_set_type_parse(xmlTextReaderPtr); |
| 59 | oval_setobject_operation_t oval_set_operation_parse(xmlTextReaderPtr, char *, oval_setobject_operation_t); |
| 60 | oval_filter_action_t oval_filter_action_parse(xmlTextReaderPtr, char *, oval_filter_action_t); |
| 61 | oval_variable_type_t oval_variable_type_parse(xmlTextReaderPtr); |
| 62 | oval_component_type_t oval_component_type_parse(xmlTextReaderPtr); |
| 63 | oval_arithmetic_operation_t oval_arithmetic_operation_parse(xmlTextReaderPtr, char *, oval_arithmetic_operation_t); |
| 64 | oval_datetime_format_t oval_datetime_format_parse(xmlTextReaderPtr, char *, oval_datetime_format_t); |
| 65 | oval_message_level_t oval_message_level_parse(xmlTextReaderPtr, char *, oval_message_level_t); |
| 66 | void oval_variable_set_type(struct oval_variable *variable, oval_variable_type_t type); |
| 67 | |
| 68 | |
| 69 | oval_definition_class_t oval_definition_class_enum(char *); |
| 70 | const char *oval_definition_class_text(oval_definition_class_t); |
| 71 | |
| 72 | |
| 73 | typedef void (*oval_affected_consumer) (struct oval_affected *, void *); |
| 74 | int oval_affected_parse_tag(xmlTextReaderPtr reader, struct oval_parser_context *context, oval_affected_consumer, void *); |
| 75 | |
| 76 | char *oval_test_get_state_names(struct oval_test *test); |
| 77 | int oval_test_parse_tag(xmlTextReaderPtr reader, struct oval_parser_context *context, void *); |
| 78 | xmlNode *oval_test_to_dom(struct oval_test *, xmlDoc *, xmlNode *); |
| 79 | |
| 80 | typedef void (*oval_criteria_consumer) (struct oval_criteria_node *, void *); |
| 81 | xmlNode *oval_criteria_node_to_dom(struct oval_criteria_node *, xmlDoc *, xmlNode *); |
| 82 | int oval_criteria_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oval_criteria_consumer, void *); |
| 83 | |
| 84 | typedef void (*oval_reference_consumer) (struct oval_reference *, void *); |
| 85 | int oval_reference_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oval_reference_consumer, void *); |
| 86 | |
| 87 | int oval_definition_parse_tag(xmlTextReaderPtr reader, struct oval_parser_context *context, void *); |
| 88 | xmlNode *oval_definition_to_dom(struct oval_definition *, xmlDoc *, xmlNode *); |
| 89 | |
| 90 | int oval_object_parse_tag(xmlTextReaderPtr reader, struct oval_parser_context *context, void *); |
| 91 | xmlNode *oval_object_to_dom(struct oval_object *, xmlDoc *, xmlNode *); |
| 92 | struct oval_object *oval_object_clone2(struct oval_definition_model *, struct oval_object *, char *); |
| 93 | struct oval_object *oval_object_create_internal(struct oval_object *, char *); |
| 94 | struct oval_object *oval_object_get_base_obj(struct oval_object *); |
| 95 | |
| 96 | oval_schema_version_t oval_state_get_platform_schema_version(const struct oval_state *state); |
| 97 | int oval_state_parse_tag(xmlTextReaderPtr reader, struct oval_parser_context *context, void *); |
| 98 | xmlNode *oval_state_to_dom(struct oval_state *, xmlDoc *, xmlNode *); |
| 99 | |
| 100 | int oval_variable_parse_tag(xmlTextReaderPtr reader, struct oval_parser_context *context, void *); |
| 101 | xmlNode *oval_variable_to_dom(struct oval_variable *, xmlDoc *, xmlNode *); |
| 102 | |
| 103 | typedef void (*oval_variable_binding_consumer) (struct oval_variable_binding *, void *); |
| 104 | void oval_variable_binding_to_dom(struct oval_variable_binding *, xmlDoc *, xmlNode *); |
| 105 | int oval_variable_binding_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oval_variable_binding_consumer, void *); |
| 106 | |
| 107 | const char *oval_variable_type_get_text(oval_variable_type_t); |
| 108 | |
| 109 | typedef void (*oval_filter_consumer) (struct oval_filter *, void *); |
| 110 | int oval_filter_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oval_filter_consumer, void *); |
| 111 | xmlNode *oval_filter_to_dom(struct oval_filter *, xmlDoc *, xmlNode *); |
| 112 | |
| 113 | typedef void (*oval_object_content_consumer) (struct oval_object_content *, void *); |
| 114 | xmlNode *oval_object_content_to_dom(struct oval_object_content *, xmlDoc *, xmlNode *); |
| 115 | int oval_object_content_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oval_object_content_consumer, void *); |
| 116 | |
| 117 | int oval_state_content_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oscap_consumer_func, void *); |
| 118 | xmlNode *oval_state_content_to_dom(struct oval_state_content *, xmlDoc *, xmlNode *); |
| 119 | |
| 120 | typedef void (*oval_behavior_consumer) (struct oval_behavior *, void *); |
| 121 | int oval_behavior_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, |
| 122 | oval_family_t, oval_behavior_consumer, void *); |
| 123 | |
| 124 | int oval_entity_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oscap_consumer_func, void *); |
| 125 | xmlNode *oval_entity_to_dom(struct oval_entity *, xmlDoc *, xmlNode *); |
| 126 | |
| 127 | int oval_record_field_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, |
| 128 | oscap_consumer_func, void *, oval_record_field_type_t); |
| 129 | xmlNode *oval_record_field_to_dom(struct oval_record_field *, bool, xmlDoc *, xmlNode *, xmlNs *); |
| 130 | |
| 131 | typedef void (*oval_set_consumer) (struct oval_setobject *, void *); |
| 132 | int oval_set_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oval_set_consumer, void *); |
| 133 | xmlNode *oval_set_to_dom(struct oval_setobject *, xmlDoc *, xmlNode *); |
| 134 | void oval_set_propagate_filters(struct oval_definition_model *, struct oval_setobject *, char *); |
| 135 | |
| 136 | typedef void (*oval_value_consumer) (struct oval_value *, void *); |
| 137 | int oval_value_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oval_value_consumer, void *); |
| 138 | xmlNode *oval_value_to_dom(struct oval_value *, xmlDoc *, xmlNode *); |
| 139 | int oval_value_cast(struct oval_value *value, oval_datatype_t new_dt); |
| 140 | |
| 141 | oval_syschar_collection_flag_t oval_component_compute(struct oval_syschar_model *sysmod, struct oval_component *component, |
| 142 | struct oval_collection *value_collection); |
| 143 | #if defined(OVAL_PROBES_ENABLED) |
| 144 | oval_syschar_collection_flag_t oval_component_query(oval_probe_session_t *sess, struct oval_component *component, |
| 145 | struct oval_collection *value_collection); |
| 146 | |
| 147 | int oval_probe_session_query_object(oval_probe_session_t *sess, struct oval_object *object); |
| 148 | #endif /* OVAL_PROBES_ENABLED */ |
| 149 | |
| 150 | typedef void (*oval_component_consumer) (struct oval_component *, void *); |
| 151 | int oval_component_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oval_component_consumer, void *); |
| 152 | xmlNode *oval_component_to_dom(struct oval_component *, xmlDoc *, xmlNode *); |
| 153 | |
| 154 | /* message */ |
| 155 | typedef void (*oval_message_consumer) (struct oval_message *, void *); |
| 156 | int oval_message_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oscap_consumer_func, void *); |
| 157 | void oval_message_to_dom(struct oval_message *, xmlDoc *, xmlNode *); |
| 158 | |
| 159 | /* generator */ |
| 160 | int oval_generator_parse_tag(xmlTextReader *, struct oval_parser_context *, void *user); |
| 161 | xmlNode *oval_generator_to_dom(struct oval_generator *, xmlDocPtr, xmlNode *); |
| 162 | |
| 163 | /* definition_model */ |
| 164 | xmlNode *oval_definition_model_to_dom(struct oval_definition_model *definition_model, xmlDocPtr doc, xmlNode * parent); |
| 165 | void oval_definition_model_optimize_by_filter_propagation(struct oval_definition_model *); |
| 166 | |
| 167 | struct oval_definition *oval_definition_model_get_new_definition(struct oval_definition_model *, const char *); |
| 168 | struct oval_test *oval_definition_model_get_new_test(struct oval_definition_model *, const char *); |
| 169 | struct oval_object *oval_definition_model_get_new_object(struct oval_definition_model *, const char *); |
| 170 | struct oval_state *oval_definition_model_get_new_state(struct oval_definition_model *, const char *); |
| 171 | struct oval_variable *oval_definition_model_get_new_variable(struct oval_definition_model *, const char *, oval_variable_type_t type); |
| 172 | void oval_definition_model_add_definition(struct oval_definition_model *, struct oval_definition *); |
| 173 | void oval_definition_model_add_test(struct oval_definition_model *, struct oval_test *); |
| 174 | void oval_definition_model_add_object(struct oval_definition_model *, struct oval_object *); |
| 175 | void oval_definition_model_add_state(struct oval_definition_model *, struct oval_state *); |
| 176 | void oval_definition_model_add_variable(struct oval_definition_model *, struct oval_variable *); |
| 177 | |
| 178 | const char * oval_definition_model_get_schema(struct oval_definition_model * model); |
| 179 | void oval_definition_model_set_schema(struct oval_definition_model *model, const char *version); |
| 180 | oval_schema_version_t oval_definition_model_get_core_schema_version(struct oval_definition_model *model); |
| 181 | oval_schema_version_t oval_definition_model_get_platform_schema_version(struct oval_definition_model *model, const char *platform); |
| 182 | |
| 183 | struct oval_string_map *oval_definition_model_build_vardef_mapping(struct oval_definition_model *model); |
| 184 | struct oval_string_iterator *oval_definition_model_get_definitions_dependent_on_variable(struct oval_definition_model *model, struct oval_variable *variable); |
| 185 | |
| 186 | /* variable model */ |
| 187 | struct oval_collection *oval_variable_model_get_values_ref(struct oval_variable_model *, char *); |
| 188 | int oval_variable_bind_ext_var(struct oval_variable *, struct oval_variable_model *, char *); |
| 189 | bool oval_variable_contains_value(struct oval_variable *variable, const char* o_value_text); |
| 190 | |
| 191 | #endif |