|
Open SCAP Library
|
00001 /* 00002 * Copyright 2009 Red Hat Inc., Durham, North Carolina. 00003 * All Rights Reserved. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 * 00019 * Authors: 00020 * Lukas Kuklinek <lkuklinek@redhat.com> 00021 */ 00022 00023 #ifndef XCCDF_ELEMENTS_H_ 00024 #define XCCDF_ELEMENTS_H_ 00025 00026 #include <stdbool.h> 00027 #include <time.h> 00028 00029 #include "common/util.h" 00030 #include "common/elements.h" 00031 #include "common/_error.h" 00032 00033 #include <libxml/xmlreader.h> 00034 00035 OSCAP_HIDDEN_START; 00036 00042 const struct xccdf_version_info* xccdf_detect_version_parser(xmlTextReaderPtr reader); 00043 00049 char *xccdf_detect_version_priv(xmlTextReader *reader); 00050 00054 bool xccdf_is_supported_namespace(xmlNs *ns); 00055 int xccdf_version_cmp(const struct xccdf_version_info *actual, const char *desired); 00056 00057 typedef enum { 00058 XCCDFE_ERROR = -1, 00059 XCCDFE_UNMATCHED = 0, 00060 00061 // XCCDF 1.1+ elements 00062 XCCDFE_BENCHMARK, 00063 XCCDFE_GROUP, 00064 XCCDFE_RULE, 00065 XCCDFE_VALUE, 00066 XCCDFE_PROFILE, 00067 XCCDFE_TESTRESULT, 00068 XCCDFE_RESULT_BENCHMARK, 00069 XCCDFE_CHECK, 00070 XCCDFE_CHECK_IMPORT, 00071 XCCDFE_CHECK_EXPORT, 00072 XCCDFE_CHECK_CONTENT, 00073 XCCDFE_CHECK_CONTENT_REF, 00074 XCCDFE_CHOICES, 00075 XCCDFE_CHOICE, 00076 XCCDFE_COMPLEX_CHECK, 00077 XCCDFE_CONFLICTS, 00078 XCCDFE_CPE_LIST, 00079 XCCDFE_DC_STATUS, 00080 XCCDFE_DEFAULT, 00081 XCCDFE_DESCRIPTION, 00082 XCCDFE_FACT, 00083 XCCDFE_FIX, 00084 XCCDFE_FIXTEXT, 00085 XCCDFE_FRONT_MATTER, 00086 XCCDFE_IDENT, 00087 XCCDFE_IDENTITY, 00088 XCCDFE_IMPACT_METRIC, 00089 XCCDFE_INSTANCE, 00090 XCCDFE_LOWER_BOUND, 00091 XCCDFE_MATCH, 00092 XCCDFE_MESSAGE, 00093 XCCDFE_METADATA, 00094 XCCDFE_MODEL, 00095 XCCDFE_NEW_RESULT, 00096 XCCDFE_NOTICE, 00097 XCCDFE_OLD_RESULT, 00098 XCCDFE_ORGANIZATION, 00099 XCCDFE_OVERRIDE, 00100 XCCDFE_PARAM, 00101 XCCDFE_PLAIN_TEXT, 00102 XCCDFE_PLATFORM, 00103 XCCDFE_CPE2_PLATFORMSPEC, 00104 XCCDFE_RESULT_PROFILE, 00105 XCCDFE_PROFILE_NOTE, 00106 XCCDFE_QUESTION, 00107 XCCDFE_RATIONALE, 00108 XCCDFE_REAR_MATTER, 00109 XCCDFE_REFERENCE, 00110 XCCDFE_REFINE_RULE, 00111 XCCDFE_REFINE_VALUE, 00112 XCCDFE_REMARK, 00113 XCCDFE_REQUIRES, 00114 XCCDFE_RESULT, 00115 XCCDFE_RULE_RESULT, 00116 XCCDFE_SCORE, 00117 XCCDFE_SELECT, 00118 XCCDFE_SET_VALUE, 00119 XCCDFE_SIGNATURE, 00120 XCCDFE_SOURCE, 00121 XCCDFE_STATUS, 00122 XCCDFE_SUB, 00123 XCCDFE_TAILORING, 00124 XCCDFE_TARGET, 00125 XCCDFE_TARGET_ADDRESS, 00126 XCCDFE_TARGET_FACTS, 00127 XCCDFE_TARGET_IDENTIFIER, 00128 XCCDFE_TITLE, 00129 XCCDFE_UPPER_BOUND, 00130 XCCDFE_VALUE_VAL, 00131 XCCDFE_VERSION, 00132 XCCDFE_WARNING, 00134 XCCDFE_BENCHMARK_REF = XCCDFE_RESULT_BENCHMARK, 00135 00136 XCCDFE_END_ 00137 } xccdf_element_t; 00138 00139 const char *xccdf_element_to_str(xccdf_element_t element); 00140 xccdf_element_t xccdf_element_get(xmlTextReaderPtr reader); 00141 00142 #define XCCDF_ASSERT_ELEMENT(reader, element) do { if (xccdf_element_get(reader) != element) { oscap_seterr(OSCAP_EFAMILY_XCCDF, "Find element '%s' while expecting element: '%s'", xccdf_element_to_str((xccdf_element_get(reader))), xccdf_element_to_str(element)); return false; } } while(false) 00143 00144 typedef enum { 00145 XCCDFA_NONE, 00146 XCCDFA_ABSTRACT, 00147 XCCDFA_AUTHENTICATED, 00148 XCCDFA_AUTHORITY, 00149 XCCDFA_CATEGORY, 00150 XCCDFA_CLUSTER_ID, 00151 XCCDFA_COMPLEXITY, 00152 XCCDFA_CONTEXT, 00153 XCCDFA_DATE, 00154 XCCDFA_DISRUPTION, 00155 XCCDFA_END_TIME, 00156 XCCDFA_EXPORT_NAME, 00157 XCCDFA_EXTENDS, 00158 XCCDFA_FIXREF, 00159 XCCDFA_HIDDEN, 00160 XCCDFA_HREF, 00161 XCCDFA_ID, 00162 XCCDFA_IDREF, 00163 XCCDFA_IID, 00164 XCCDFA_IMPORT_NAME, 00165 XCCDFA_IMPORT_XPATH, 00166 XCCDFA_INTERACTIVE, 00167 XCCDFA_INTERFACEHINT, 00168 XCCDFA_MAXIMUM, 00169 XCCDFA_MULTICHECK, 00170 XCCDFA_MULTIPLE, 00171 XCCDFA_MUSTMATCH, 00172 XCCDFA_NAME, 00173 XCCDFA_NEGATE, 00174 XCCDFA_NOTE_TAG, 00175 XCCDFA_OPERATOR, 00176 XCCDFA_OVERRIDE, 00177 XCCDFA_PARENTCONTEXT, 00178 XCCDFA_PLATFORM, 00179 XCCDFA_PRIVILEDGED, 00180 XCCDFA_PROHIBITCHANGES, 00181 XCCDFA_REBOOT, 00182 XCCDFA_RESOLVED, 00183 XCCDFA_ROLE, 00184 XCCDFA_SELECTED, 00185 XCCDFA_SELECTOR, 00186 XCCDFA_SEVERITY, 00187 XCCDFA_START_TIME, 00188 XCCDFA_STRATEGY, 00189 XCCDFA_STYLE, 00190 XCCDFA_STYLE_HREF, 00191 XCCDFA_SYSTEM, 00192 XCCDFA_TAG, 00193 XCCDFA_TEST_SYSTEM, 00194 XCCDFA_TIME, 00195 XCCDFA_TYPE, 00196 XCCDFA_UPDATE, 00197 XCCDFA_URI, 00198 XCCDFA_VALUE_ID, 00199 XCCDFA_VERSION, 00200 XCCDFA_WEIGHT, 00201 XCCDFA_END_ 00202 } xccdf_attribute_t; 00203 00204 bool xccdf_attribute_has(xmlTextReaderPtr reader, xccdf_attribute_t attr); 00205 const char *xccdf_attribute_get(xmlTextReaderPtr reader, xccdf_attribute_t attr); 00206 char *xccdf_attribute_copy(xmlTextReaderPtr reader, xccdf_attribute_t attr); 00207 bool xccdf_attribute_get_bool(xmlTextReaderPtr reader, xccdf_attribute_t attr); 00208 int xccdf_attribute_get_int(xmlTextReaderPtr reader, xccdf_attribute_t attr); 00209 float xccdf_attribute_get_float(xmlTextReaderPtr reader, xccdf_attribute_t attr); 00210 00211 extern const struct oscap_string_map XCCDF_BOOL_MAP[]; 00212 00213 void xccdf_print_depth(int depth); 00214 void xccdf_print_max(const char *str, int max, const char *ellipsis); 00215 void xccdf_print_max_text(const struct oscap_text *txt, int max, const char *ellipsis); 00216 void xccdf_print_textlist(struct oscap_text_iterator *txt, int depth, int max, const char *ellipsis); 00217 00218 xmlNs *lookup_xccdf_ns(xmlDoc *doc, xmlNode *parent, const struct xccdf_version_info *version_info); 00219 00220 const struct xccdf_version_info *xccdf_version_info_find(const char *version); 00221 00222 OSCAP_HIDDEN_END; 00223 00224 #endif
1.7.3