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 
32 #include <libxml/xmlreader.h>
33 
34 OSCAP_HIDDEN_START;
35 
41 const struct xccdf_version_info* xccdf_detect_version_parser(xmlTextReaderPtr reader);
42 
48 char *xccdf_detect_version_priv(xmlTextReader *reader);
49 
53 bool xccdf_is_supported_namespace(xmlNs *ns);
54 int xccdf_version_cmp(const struct xccdf_version_info *actual, const char *desired);
55 
56 typedef 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 
138 xccdf_element_t xccdf_element_get(xmlTextReaderPtr reader);
139 
140 #define XCCDF_ASSERT_ELEMENT(reader, element) do { if (xccdf_element_get(reader) != element) return false; } while(false)
141 
142 typedef enum {
143  XCCDFA_NONE,
144  XCCDFA_ABSTRACT,
145  XCCDFA_AUTHENTICATED,
146  XCCDFA_AUTHORITY,
147  XCCDFA_CATEGORY,
148  XCCDFA_CLUSTER_ID,
149  XCCDFA_COMPLEXITY,
150  XCCDFA_CONTEXT,
151  XCCDFA_DATE,
152  XCCDFA_DISRUPTION,
153  XCCDFA_END_TIME,
154  XCCDFA_EXPORT_NAME,
155  XCCDFA_EXTENDS,
156  XCCDFA_FIXREF,
157  XCCDFA_HIDDEN,
158  XCCDFA_HREF,
159  XCCDFA_ID,
160  XCCDFA_IDREF,
161  XCCDFA_IID,
162  XCCDFA_IMPORT_NAME,
163  XCCDFA_IMPORT_XPATH,
164  XCCDFA_INTERACTIVE,
165  XCCDFA_INTERFACEHINT,
166  XCCDFA_MAXIMUM,
167  XCCDFA_MULTICHECK,
168  XCCDFA_MULTIPLE,
169  XCCDFA_MUSTMATCH,
170  XCCDFA_NAME,
171  XCCDFA_NEGATE,
172  XCCDFA_NOTE_TAG,
173  XCCDFA_OPERATOR,
174  XCCDFA_OVERRIDE,
175  XCCDFA_PARENTCONTEXT,
176  XCCDFA_PLATFORM,
177  XCCDFA_PRIVILEDGED,
178  XCCDFA_PROHIBITCHANGES,
179  XCCDFA_REBOOT,
180  XCCDFA_RESOLVED,
181  XCCDFA_ROLE,
182  XCCDFA_SELECTED,
183  XCCDFA_SELECTOR,
184  XCCDFA_SEVERITY,
185  XCCDFA_START_TIME,
186  XCCDFA_STRATEGY,
187  XCCDFA_STYLE,
188  XCCDFA_STYLE_HREF,
189  XCCDFA_SYSTEM,
190  XCCDFA_TAG,
191  XCCDFA_TEST_SYSTEM,
192  XCCDFA_TIME,
193  XCCDFA_TYPE,
194  XCCDFA_UPDATE,
195  XCCDFA_URI,
196  XCCDFA_VALUE_ID,
197  XCCDFA_VERSION,
198  XCCDFA_WEIGHT,
199  XCCDFA_END_
200 } xccdf_attribute_t;
201 
202 bool xccdf_attribute_has(xmlTextReaderPtr reader, xccdf_attribute_t attr);
203 const char *xccdf_attribute_get(xmlTextReaderPtr reader, xccdf_attribute_t attr);
204 char *xccdf_attribute_copy(xmlTextReaderPtr reader, xccdf_attribute_t attr);
205 bool xccdf_attribute_get_bool(xmlTextReaderPtr reader, xccdf_attribute_t attr);
206 int xccdf_attribute_get_int(xmlTextReaderPtr reader, xccdf_attribute_t attr);
207 float xccdf_attribute_get_float(xmlTextReaderPtr reader, xccdf_attribute_t attr);
208 
209 extern const struct oscap_string_map XCCDF_BOOL_MAP[];
210 
211 void xccdf_print_depth(int depth);
212 void xccdf_print_max(const char *str, int max, const char *ellipsis);
213 void xccdf_print_max_text(const struct oscap_text *txt, int max, const char *ellipsis);
214 void xccdf_print_textlist(struct oscap_text_iterator *txt, int depth, int max, const char *ellipsis);
215 
216 xmlNs *lookup_xccdf_ns(xmlDoc *doc, xmlNode *parent, const struct xccdf_version_info *version_info);
217 
218 OSCAP_HIDDEN_END;
219 
220 #endif
Define mapping between symbolic constant and its string representation.
Definition: util.h:309
Definition: XCCDF/elements.c:43
Internationalized string iterator.
Representation of internationalizable character strings.
Definition: text_priv.h:47