Open SCAP Library
Loading...
Searching...
No Matches
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
41const struct xccdf_version_info* xccdf_detect_version_parser(xmlTextReaderPtr reader);
42
48char *xccdf_detect_version_priv(xmlTextReader *reader);
49
53bool xccdf_is_supported_namespace(xmlNs *ns);
54int xccdf_version_cmp(const struct xccdf_version_info *actual, const char *desired);
55
56typedef enum {
57 XCCDFE_ERROR = -1,
58 XCCDFE_UNMATCHED = 0,
59
60 // XCCDF 1.1+ elements
61 XCCDFE_BENCHMARK,
62 XCCDFE_GROUP,
63 XCCDFE_RULE,
64 XCCDFE_VALUE,
65 XCCDFE_PROFILE,
66 XCCDFE_TESTRESULT,
67 XCCDFE_RESULT_BENCHMARK,
68 XCCDFE_CHECK,
69 XCCDFE_CHECK_IMPORT,
70 XCCDFE_CHECK_EXPORT,
71 XCCDFE_CHECK_CONTENT,
72 XCCDFE_CHECK_CONTENT_REF,
73 XCCDFE_CHOICES,
74 XCCDFE_CHOICE,
75 XCCDFE_COMPLEX_CHECK,
76 XCCDFE_CONFLICTS,
77 XCCDFE_CPE_LIST,
78 XCCDFE_DC_STATUS,
79 XCCDFE_DEFAULT,
80 XCCDFE_DESCRIPTION,
81 XCCDFE_FACT,
82 XCCDFE_FIX,
83 XCCDFE_FIXTEXT,
84 XCCDFE_FRONT_MATTER,
85 XCCDFE_IDENT,
86 XCCDFE_IDENTITY,
87 XCCDFE_IMPACT_METRIC,
88 XCCDFE_INSTANCE,
89 XCCDFE_LOWER_BOUND,
90 XCCDFE_MATCH,
91 XCCDFE_MESSAGE,
92 XCCDFE_METADATA,
93 XCCDFE_MODEL,
94 XCCDFE_NEW_RESULT,
95 XCCDFE_NOTICE,
96 XCCDFE_OLD_RESULT,
97 XCCDFE_ORGANIZATION,
98 XCCDFE_OVERRIDE,
99 XCCDFE_PARAM,
100 XCCDFE_PLAIN_TEXT,
101 XCCDFE_PLATFORM,
102 XCCDFE_CPE2_PLATFORMSPEC,
103 XCCDFE_RESULT_PROFILE,
104 XCCDFE_PROFILE_NOTE,
105 XCCDFE_QUESTION,
106 XCCDFE_RATIONALE,
107 XCCDFE_REAR_MATTER,
108 XCCDFE_REFERENCE,
109 XCCDFE_REFINE_RULE,
110 XCCDFE_REFINE_VALUE,
111 XCCDFE_REMARK,
112 XCCDFE_REQUIRES,
113 XCCDFE_RESULT,
114 XCCDFE_RULE_RESULT,
115 XCCDFE_SCORE,
116 XCCDFE_SELECT,
117 XCCDFE_SET_VALUE,
118 XCCDFE_SIGNATURE,
119 XCCDFE_SOURCE,
120 XCCDFE_STATUS,
121 XCCDFE_SUB,
122 XCCDFE_TAILORING,
123 XCCDFE_TARGET,
124 XCCDFE_TARGET_ADDRESS,
125 XCCDFE_TARGET_FACTS,
126 XCCDFE_TARGET_IDENTIFIER,
127 XCCDFE_TITLE,
128 XCCDFE_UPPER_BOUND,
129 XCCDFE_VALUE_VAL,
130 XCCDFE_VERSION,
131 XCCDFE_WARNING,
133 XCCDFE_BENCHMARK_REF = XCCDFE_RESULT_BENCHMARK,
134
135 XCCDFE_END_
136} xccdf_element_t;
137
138const char *xccdf_element_to_str(xccdf_element_t element);
139xccdf_element_t xccdf_element_get(xmlTextReaderPtr reader);
140
141#define XCCDF_ASSERT_ELEMENT(reader, element) \
142 do { \
143 if (xccdf_element_get(reader) != element) { \
144 const char *found, *expected; \
145 \
146 found = xccdf_element_to_str((xccdf_element_get(reader))); \
147 expected = xccdf_element_to_str(element); \
148 oscap_seterr( \
149 OSCAP_EFAMILY_XCCDF, \
150 "Find element '%s' while expecting element: '%s'", \
151 found != NULL ? found : "(null)", \
152 expected != NULL ? expected : "(null)"); \
153 return false; \
154 } \
155 } while (false)
156
157typedef enum {
158 XCCDFA_NONE,
159 XCCDFA_ABSTRACT,
160 XCCDFA_AUTHENTICATED,
161 XCCDFA_AUTHORITY,
162 XCCDFA_CATEGORY,
163 XCCDFA_CLUSTER_ID,
164 XCCDFA_COMPLEXITY,
165 XCCDFA_CONTEXT,
166 XCCDFA_DATE,
167 XCCDFA_DISRUPTION,
168 XCCDFA_END_TIME,
169 XCCDFA_EXPORT_NAME,
170 XCCDFA_EXTENDS,
171 XCCDFA_FIXREF,
172 XCCDFA_HIDDEN,
173 XCCDFA_HREF,
174 XCCDFA_ID,
175 XCCDFA_IDREF,
176 XCCDFA_IID,
177 XCCDFA_IMPORT_NAME,
178 XCCDFA_IMPORT_XPATH,
179 XCCDFA_INTERACTIVE,
180 XCCDFA_INTERFACEHINT,
181 XCCDFA_MAXIMUM,
182 XCCDFA_MULTICHECK,
183 XCCDFA_MULTIPLE,
184 XCCDFA_MUSTMATCH,
185 XCCDFA_NAME,
186 XCCDFA_NEGATE,
187 XCCDFA_NOTE_TAG,
188 XCCDFA_OPERATOR,
189 XCCDFA_OVERRIDE,
190 XCCDFA_PARENTCONTEXT,
191 XCCDFA_PLATFORM,
192 XCCDFA_PRIVILEDGED,
193 XCCDFA_PROHIBITCHANGES,
194 XCCDFA_REBOOT,
195 XCCDFA_RESOLVED,
196 XCCDFA_ROLE,
197 XCCDFA_SELECTED,
198 XCCDFA_SELECTOR,
199 XCCDFA_SEVERITY,
200 XCCDFA_START_TIME,
201 XCCDFA_STRATEGY,
202 XCCDFA_STYLE,
203 XCCDFA_STYLE_HREF,
204 XCCDFA_SYSTEM,
205 XCCDFA_TAG,
206 XCCDFA_TEST_SYSTEM,
207 XCCDFA_TIME,
208 XCCDFA_TYPE,
209 XCCDFA_UPDATE,
210 XCCDFA_URI,
211 XCCDFA_VALUE_ID,
212 XCCDFA_VERSION,
213 XCCDFA_WEIGHT,
214 XCCDFA_END_
215} xccdf_attribute_t;
216
217bool xccdf_attribute_has(xmlTextReaderPtr reader, xccdf_attribute_t attr);
218const char *xccdf_attribute_get(xmlTextReaderPtr reader, xccdf_attribute_t attr);
219char *xccdf_attribute_copy(xmlTextReaderPtr reader, xccdf_attribute_t attr);
220bool xccdf_attribute_get_bool(xmlTextReaderPtr reader, xccdf_attribute_t attr);
221int xccdf_attribute_get_int(xmlTextReaderPtr reader, xccdf_attribute_t attr);
222float xccdf_attribute_get_float(xmlTextReaderPtr reader, xccdf_attribute_t attr);
223
224extern const struct oscap_string_map XCCDF_BOOL_MAP[];
225
226void xccdf_print_depth(int depth);
227void xccdf_print_max(const char *str, int max, const char *ellipsis);
228void xccdf_print_max_text(const struct oscap_text *txt, int max, const char *ellipsis);
229void xccdf_print_textlist(struct oscap_text_iterator *txt, int depth, int max, const char *ellipsis);
230
231xmlNs *lookup_xccdf_ns(xmlDoc *doc, xmlNode *parent, const struct xccdf_version_info *version_info);
232
233const struct xccdf_version_info *xccdf_version_info_find(const char *version);
234
235
236#endif
Define mapping between symbolic constant and its string representation.
Definition util.h:296
Internationalized string iterator.
Representation of internationalizable character strings.
Definition text_priv.h:46
Definition XCCDF/elements.c:42
const char * version
MAJOR.MINOR, for example "1.1" or "1.2".
Definition XCCDF/elements.c:43