Open SCAP Library: elements.h Source File

Open SCAP Library

XCCDF/elements.h
1 /*
2 * Copyright 2009 Red Hat Inc., Durham, North Carolina.
3 * All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Authors:
20 * Lukas Kuklinek <lkuklinek@redhat.com>
21 */
22
23 #ifndef XCCDF_ELEMENTS_H_
24 #define XCCDF_ELEMENTS_H_
25
26 #include <stdbool.h>
27 #include <time.h>
28
29 #include "common/util.h"
30 #include "common/elements.h"
31 #include "common/_error.h"
32
33 #include <libxml/xmlreader.h>
34
35 OSCAP_HIDDEN_START;
36
42 const struct xccdf_version_info* xccdf_detect_version_parser(xmlTextReaderPtr reader);
43
49 char *xccdf_detect_version_priv(xmlTextReader *reader);
50
54 bool xccdf_is_supported_namespace(xmlNs *ns);
55 int xccdf_version_cmp(const struct xccdf_version_info *actual, const char *desired);
56
57 typedef enum {
58 XCCDFE_ERROR = -1,
59 XCCDFE_UNMATCHED = 0,
60
61 // XCCDF 1.1+ elements
62 XCCDFE_BENCHMARK,
63 XCCDFE_GROUP,
64 XCCDFE_RULE,
65 XCCDFE_VALUE,
66 XCCDFE_PROFILE,
67 XCCDFE_TESTRESULT,
68 XCCDFE_RESULT_BENCHMARK,
69 XCCDFE_CHECK,
70 XCCDFE_CHECK_IMPORT,
71 XCCDFE_CHECK_EXPORT,
72 XCCDFE_CHECK_CONTENT,
73 XCCDFE_CHECK_CONTENT_REF,
74 XCCDFE_CHOICES,
75 XCCDFE_CHOICE,
76 XCCDFE_COMPLEX_CHECK,
77 XCCDFE_CONFLICTS,
78 XCCDFE_CPE_LIST,
79 XCCDFE_DC_STATUS,
80 XCCDFE_DEFAULT,
81 XCCDFE_DESCRIPTION,
82 XCCDFE_FACT,
83 XCCDFE_FIX,
84 XCCDFE_FIXTEXT,
85 XCCDFE_FRONT_MATTER,
86 XCCDFE_IDENT,
87 XCCDFE_IDENTITY,
88 XCCDFE_IMPACT_METRIC,
89 XCCDFE_INSTANCE,
90 XCCDFE_LOWER_BOUND,
91 XCCDFE_MATCH,
92 XCCDFE_MESSAGE,
93 XCCDFE_METADATA,
94 XCCDFE_MODEL,
95 XCCDFE_NEW_RESULT,
96 XCCDFE_NOTICE,
97 XCCDFE_OLD_RESULT,
98 XCCDFE_ORGANIZATION,
99 XCCDFE_OVERRIDE,
100 XCCDFE_PARAM,
101 XCCDFE_PLAIN_TEXT,
102 XCCDFE_PLATFORM,
103 XCCDFE_CPE2_PLATFORMSPEC,
104 XCCDFE_RESULT_PROFILE,
105 XCCDFE_PROFILE_NOTE,
106 XCCDFE_QUESTION,
107 XCCDFE_RATIONALE,
108 XCCDFE_REAR_MATTER,
109 XCCDFE_REFERENCE,
110 XCCDFE_REFINE_RULE,
111 XCCDFE_REFINE_VALUE,
112 XCCDFE_REMARK,
113 XCCDFE_REQUIRES,
114 XCCDFE_RESULT,
115 XCCDFE_RULE_RESULT,
116 XCCDFE_SCORE,
117 XCCDFE_SELECT,
118 XCCDFE_SET_VALUE,
119 XCCDFE_SIGNATURE,
120 XCCDFE_SOURCE,
121 XCCDFE_STATUS,
122 XCCDFE_SUB,
123 XCCDFE_TAILORING,
124 XCCDFE_TARGET,
125 XCCDFE_TARGET_ADDRESS,
126 XCCDFE_TARGET_FACTS,
127 XCCDFE_TARGET_IDENTIFIER,
128 XCCDFE_TITLE,
129 XCCDFE_UPPER_BOUND,
130 XCCDFE_VALUE_VAL,
131 XCCDFE_VERSION,
132 XCCDFE_WARNING,
134 XCCDFE_BENCHMARK_REF = XCCDFE_RESULT_BENCHMARK,
135
136 XCCDFE_END_
137 } xccdf_element_t;
138
139 const char *xccdf_element_to_str(xccdf_element_t element);
140 xccdf_element_t xccdf_element_get(xmlTextReaderPtr reader);
141
142 #define XCCDF_ASSERT_ELEMENT(reader, element) \
143 do { \
144 if (xccdf_element_get(reader) != element) { \
145 const char *found, *expected; \
146 \
147 found = xccdf_element_to_str((xccdf_element_get(reader))); \
148 expected = xccdf_element_to_str(element); \
149 oscap_seterr( \
150 OSCAP_EFAMILY_XCCDF, \
151 "Find element '%s' while expecting element: '%s'", \
152 found != NULL ? found : "(null)", \
153 expected != NULL ? expected : "(null)"); \
154 return false; \
155 } \
156 } while (false)
157
158 typedef enum {
159 XCCDFA_NONE,
160 XCCDFA_ABSTRACT,
161 XCCDFA_AUTHENTICATED,
162 XCCDFA_AUTHORITY,
163 XCCDFA_CATEGORY,
164 XCCDFA_CLUSTER_ID,
165 XCCDFA_COMPLEXITY,
166 XCCDFA_CONTEXT,
167 XCCDFA_DATE,
168 XCCDFA_DISRUPTION,
169 XCCDFA_END_TIME,
170 XCCDFA_EXPORT_NAME,
171 XCCDFA_EXTENDS,
172 XCCDFA_FIXREF,
173 XCCDFA_HIDDEN,
174 XCCDFA_HREF,
175 XCCDFA_ID,
176 XCCDFA_IDREF,
177 XCCDFA_IID,
178 XCCDFA_IMPORT_NAME,
179 XCCDFA_IMPORT_XPATH,
180 XCCDFA_INTERACTIVE,
181 XCCDFA_INTERFACEHINT,
182 XCCDFA_MAXIMUM,
183 XCCDFA_MULTICHECK,
184 XCCDFA_MULTIPLE,
185 XCCDFA_MUSTMATCH,
186 XCCDFA_NAME,
187 XCCDFA_NEGATE,
188 XCCDFA_NOTE_TAG,
189 XCCDFA_OPERATOR,
190 XCCDFA_OVERRIDE,
191 XCCDFA_PARENTCONTEXT,
192 XCCDFA_PLATFORM,
193 XCCDFA_PRIVILEDGED,
194 XCCDFA_PROHIBITCHANGES,
195 XCCDFA_REBOOT,
196 XCCDFA_RESOLVED,
197 XCCDFA_ROLE,
198 XCCDFA_SELECTED,
199 XCCDFA_SELECTOR,
200 XCCDFA_SEVERITY,
201 XCCDFA_START_TIME,
202 XCCDFA_STRATEGY,
203 XCCDFA_STYLE,
204 XCCDFA_STYLE_HREF,
205 XCCDFA_SYSTEM,
206 XCCDFA_TAG,
207 XCCDFA_TEST_SYSTEM,
208 XCCDFA_TIME,
209 XCCDFA_TYPE,
210 XCCDFA_UPDATE,
211 XCCDFA_URI,
212 XCCDFA_VALUE_ID,
213 XCCDFA_VERSION,
214 XCCDFA_WEIGHT,
215 XCCDFA_END_
216 } xccdf_attribute_t;
217
218 bool xccdf_attribute_has(xmlTextReaderPtr reader, xccdf_attribute_t attr);
219 const char *xccdf_attribute_get(xmlTextReaderPtr reader, xccdf_attribute_t attr);
220 char *xccdf_attribute_copy(xmlTextReaderPtr reader, xccdf_attribute_t attr);
221 bool xccdf_attribute_get_bool(xmlTextReaderPtr reader, xccdf_attribute_t attr);
222 int xccdf_attribute_get_int(xmlTextReaderPtr reader, xccdf_attribute_t attr);
223 float xccdf_attribute_get_float(xmlTextReaderPtr reader, xccdf_attribute_t attr);
224
225 extern const struct oscap_string_map XCCDF_BOOL_MAP[];
226
227 void xccdf_print_depth(int depth);
228 void xccdf_print_max(const char *str, int max, const char *ellipsis);
229 void xccdf_print_max_text(const struct oscap_text *txt, int max, const char *ellipsis);
230 void xccdf_print_textlist(struct oscap_text_iterator *txt, int depth, int max, const char *ellipsis);
231
232 xmlNs *lookup_xccdf_ns(xmlDoc *doc, xmlNode *parent, const struct xccdf_version_info *version_info);
233
234 const struct xccdf_version_info *xccdf_version_info_find(const char *version);
235
236 OSCAP_HIDDEN_END;
237
238 #endif
oscap_string_map
Define mapping between symbolic constant and its string representation.
Definition: util.h:310
xccdf_version_info
Definition: XCCDF/elements.c:43
oscap_text_iterator
Internationalized string iterator.
xccdf_version_info::version
const char * version
MAJOR.MINOR, for example "1.1" or "1.2".
Definition: XCCDF/elements.c:44
oscap_text
Representation of internationalizable character strings.
Definition: text_priv.h:47