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