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 
46 bool xccdf_is_supported_namespace(xmlNs *ns);
47 int xccdf_version_cmp(const struct xccdf_version_info *actual, const char *desired);
48 
49 typedef enum {
50  XCCDFE_ERROR = -1,
51  XCCDFE_UNMATCHED = 0,
52 
53  // XCCDF 1.1+ elements
54  XCCDFE_BENCHMARK,
55  XCCDFE_GROUP,
56  XCCDFE_RULE,
57  XCCDFE_VALUE,
58  XCCDFE_PROFILE,
59  XCCDFE_TESTRESULT,
60  XCCDFE_RESULT_BENCHMARK,
61  XCCDFE_CHECK,
62  XCCDFE_CHECK_IMPORT,
63  XCCDFE_CHECK_EXPORT,
64  XCCDFE_CHECK_CONTENT,
65  XCCDFE_CHECK_CONTENT_REF,
66  XCCDFE_CHOICES,
67  XCCDFE_CHOICE,
68  XCCDFE_COMPLEX_CHECK,
69  XCCDFE_CONFLICTS,
70  XCCDFE_CPE_LIST,
71  XCCDFE_DC_STATUS,
72  XCCDFE_DEFAULT,
73  XCCDFE_DESCRIPTION,
74  XCCDFE_FACT,
75  XCCDFE_FIX,
76  XCCDFE_FIXTEXT,
77  XCCDFE_FRONT_MATTER,
78  XCCDFE_IDENT,
79  XCCDFE_IDENTITY,
80  XCCDFE_IMPACT_METRIC,
81  XCCDFE_INSTANCE,
82  XCCDFE_LOWER_BOUND,
83  XCCDFE_MATCH,
84  XCCDFE_MESSAGE,
85  XCCDFE_METADATA,
86  XCCDFE_MODEL,
87  XCCDFE_NEW_RESULT,
88  XCCDFE_NOTICE,
89  XCCDFE_OLD_RESULT,
90  XCCDFE_ORGANIZATION,
91  XCCDFE_OVERRIDE,
92  XCCDFE_PARAM,
93  XCCDFE_PLAIN_TEXT,
94  XCCDFE_PLATFORM,
95  XCCDFE_CPE2_PLATFORMSPEC,
96  XCCDFE_RESULT_PROFILE,
97  XCCDFE_PROFILE_NOTE,
98  XCCDFE_QUESTION,
99  XCCDFE_RATIONALE,
100  XCCDFE_REAR_MATTER,
101  XCCDFE_REFERENCE,
102  XCCDFE_REFINE_RULE,
103  XCCDFE_REFINE_VALUE,
104  XCCDFE_REMARK,
105  XCCDFE_REQUIRES,
106  XCCDFE_RESULT,
107  XCCDFE_RULE_RESULT,
108  XCCDFE_SCORE,
109  XCCDFE_SELECT,
110  XCCDFE_SET_VALUE,
111  XCCDFE_SIGNATURE,
112  XCCDFE_SOURCE,
113  XCCDFE_STATUS,
114  XCCDFE_SUB,
115  XCCDFE_TAILORING,
116  XCCDFE_TARGET,
117  XCCDFE_TARGET_ADDRESS,
118  XCCDFE_TARGET_FACTS,
119  XCCDFE_TARGET_IDENTIFIER,
120  XCCDFE_TITLE,
121  XCCDFE_UPPER_BOUND,
122  XCCDFE_VALUE_VAL,
123  XCCDFE_VERSION,
124  XCCDFE_WARNING,
125  XCCDFE_BENCHMARK_REF,
126 
127  XCCDFE_END_
128 } xccdf_element_t;
129 
130 xccdf_element_t xccdf_element_get(xmlTextReaderPtr reader);
131 
132 #define XCCDF_ASSERT_ELEMENT(reader, element) do { if (xccdf_element_get(reader) != element) return false; } while(false)
133 
134 typedef enum {
135  XCCDFA_NONE,
136  XCCDFA_ABSTRACT,
137  XCCDFA_AUTHENTICATED,
138  XCCDFA_AUTHORITY,
139  XCCDFA_CATEGORY,
140  XCCDFA_CLUSTER_ID,
141  XCCDFA_COMPLEXITY,
142  XCCDFA_CONTEXT,
143  XCCDFA_DATE,
144  XCCDFA_DISRUPTION,
145  XCCDFA_END_TIME,
146  XCCDFA_EXPORT_NAME,
147  XCCDFA_EXTENDS,
148  XCCDFA_FIXREF,
149  XCCDFA_HIDDEN,
150  XCCDFA_HREF,
151  XCCDFA_ID,
152  XCCDFA_IDREF,
153  XCCDFA_IID,
154  XCCDFA_IMPORT_NAME,
155  XCCDFA_IMPORT_XPATH,
156  XCCDFA_INTERACTIVE,
157  XCCDFA_INTERFACEHINT,
158  XCCDFA_MAXIMUM,
159  XCCDFA_MULTICHECK,
160  XCCDFA_MULTIPLE,
161  XCCDFA_MUSTMATCH,
162  XCCDFA_NAME,
163  XCCDFA_NEGATE,
164  XCCDFA_NOTE_TAG,
165  XCCDFA_OPERATOR,
166  XCCDFA_OVERRIDE,
167  XCCDFA_PARENTCONTEXT,
168  XCCDFA_PLATFORM,
169  XCCDFA_PRIVILEDGED,
170  XCCDFA_PROHIBITCHANGES,
171  XCCDFA_REBOOT,
172  XCCDFA_RESOLVED,
173  XCCDFA_ROLE,
174  XCCDFA_SELECTED,
175  XCCDFA_SELECTOR,
176  XCCDFA_SEVERITY,
177  XCCDFA_START_TIME,
178  XCCDFA_STRATEGY,
179  XCCDFA_STYLE,
180  XCCDFA_STYLE_HREF,
181  XCCDFA_SYSTEM,
182  XCCDFA_TAG,
183  XCCDFA_TEST_SYSTEM,
184  XCCDFA_TIME,
185  XCCDFA_TYPE,
186  XCCDFA_UPDATE,
187  XCCDFA_URI,
188  XCCDFA_VALUE_ID,
189  XCCDFA_VERSION,
190  XCCDFA_WEIGHT,
191  XCCDFA_END_
192 } xccdf_attribute_t;
193 
194 bool xccdf_attribute_has(xmlTextReaderPtr reader, xccdf_attribute_t attr);
195 const char *xccdf_attribute_get(xmlTextReaderPtr reader, xccdf_attribute_t attr);
196 char *xccdf_attribute_copy(xmlTextReaderPtr reader, xccdf_attribute_t attr);
197 bool xccdf_attribute_get_bool(xmlTextReaderPtr reader, xccdf_attribute_t attr);
198 int xccdf_attribute_get_int(xmlTextReaderPtr reader, xccdf_attribute_t attr);
199 float xccdf_attribute_get_float(xmlTextReaderPtr reader, xccdf_attribute_t attr);
200 
201 extern const struct oscap_string_map XCCDF_BOOL_MAP[];
202 
203 void xccdf_print_depth(int depth);
204 void xccdf_print_max(const char *str, int max, const char *ellipsis);
205 void xccdf_print_max_text(const struct oscap_text *txt, int max, const char *ellipsis);
206 void xccdf_print_textlist(struct oscap_text_iterator *txt, int depth, int max, const char *ellipsis);
207 
208 OSCAP_HIDDEN_END;
209 
210 #endif