Debian Codegraph @

src/OVAL/oval_directives.c

raw symbols SCIP
1 /**
2 * @file oval_directives.c
3 * \brief Open Vulnerability and Assessment Language
4 *
5 * See more details at http://oval.mitre.org/
6 * @cond
7 */
8
9 /*
10 * Copyright 2011--2014 Red Hat Inc., Durham, North Carolina.
11 * All Rights Reserved.
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 *
27 * Authors:
28 * "Peter Vrabec" <[email protected]>
29 */
30
31 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
32 #include <config.h>cxx . . $ `<file>/build/config.h`/
33 #endif
34
35 #include <stdlib.h>
36 #include <stdio.h>
37 #include <stdbool.h>
38 #include <string.h>
39
40 #include "oval_directives_impl.h"cxx . . $ `<file>/src/OVAL/oval_directives_impl.h`/
41 #include "adt/oval_collection_impl.h"cxx . . $ `<file>/src/OVAL/adt/oval_collection_impl.h`/
42 #include "oval_parser_impl.h"cxx . . $ `<file>/src/OVAL/oval_parser_impl.h`/
43
44 #include "common/util.h"cxx . . $ `<file>/src/common/util.h`/
45 #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/
46 #include "common/_error.h"cxx . . $ `<file>/src/common/_error.h`/
47 #include "common/elements.h"cxx . . $ `<file>/src/common/elements.h`/
48 #include "oscap_source.h"cxx . . $ `<file>/src/source/public/oscap_source.h`/
49 #include "source/oscap_source_priv.h"cxx . . $ `<file>/src/source/oscap_source_priv.h`/
50
51 #define NUMBER_OF_RESULTScxx . . $ `src/OVAL/oval_directives.c:51:9`! 6
52 #define NUMBER_OF_CLASSEScxx . . $ `src/OVAL/oval_directives.c:52:9`! 5
53
54
55 struct oval_result_directivescxx . . $ oval_result_directives# {
56 structcxx . . $ oval_result_directives#$anonymous_type_0# {
57 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! reportedcxx . . $ oval_result_directives#$anonymous_type_0#reported.;
58 oval_result_directive_content_tcxx . . $ oval_result_directive_content_t# contentcxx . . $ oval_result_directives#$anonymous_type_0#content.;
59 } directivecxx . . $ oval_result_directives#directive.[NUMBER_OF_RESULTScxx . . $ `src/OVAL/oval_directives.c:51:9`!];
60 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! inc_definitionscxx . . $ oval_result_directives#inc_definitions.;
61 };
62
63 struct oval_directives_modelcxx . . $ oval_directives_model# {
64 struct oval_generatorcxx . . $ oval_generator# *generatorcxx . . $ oval_directives_model#generator.;
65 struct oval_result_directivescxx . . $ oval_result_directives# * def_directivescxx . . $ oval_directives_model#def_directives.;
66 struct oval_result_directivescxx . . $ oval_result_directives# * class_directivescxx . . $ oval_directives_model#class_directives.[NUMBER_OF_CLASSEScxx . . $ `src/OVAL/oval_directives.c:52:9`!];
67 };
68
69
70 static int oval_directives_model_parsecxx . . $ oval_directives_model_parse(b61d4daae99e998a).(xmlTextReaderPtrcxx . . $ xmlTextReaderPtr#, struct oval_parser_contextcxx . . $ oval_parser_context# *);
71
72 struct oval_directives_modelcxx . . $ oval_directives_model# *oval_directives_model_newcxx . . $ oval_directives_model_new(3f85e657173754f7).(void) {
73
74 struct oval_directives_modelcxx . . $ oval_directives_model# * new_model = (struct oval_directives_modelcxx . . $ oval_directives_model# *)
75 malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct oval_directives_modelcxx . . $ oval_directives_model#));
76
77 new_model->generatorcxx . . $ oval_directives_model#generator. = oval_generator_newcxx . . $ oval_generator_new(1db813de85019778).();
78 new_model->def_directivescxx . . $ oval_directives_model#def_directives. = oval_result_directives_newcxx . . $ oval_result_directives_new(eca706299e9b42ea).();
79
80 /* no class directives */
81 for(int i=0; i<NUMBER_OF_CLASSEScxx . . $ `src/OVAL/oval_directives.c:52:9`!; i++)
82 new_model->class_directivescxx . . $ oval_directives_model#class_directives.[i] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
83
84 return new_model;
85 }
86
87 void oval_directives_model_freecxx . . $ oval_directives_model_free(89931e7170a08f7).(struct oval_directives_modelcxx . . $ oval_directives_model# *model) {
88 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(model);
89
90 for(int i=0; i<NUMBER_OF_CLASSEScxx . . $ `src/OVAL/oval_directives.c:52:9`!; i++) {
91 if (model->class_directivescxx . . $ oval_directives_model#class_directives.[i]) {
92 freecxx . . $ free(5d22bdacc48458e8).(model->class_directivescxx . . $ oval_directives_model#class_directives.[i]);
93 model->class_directivescxx . . $ oval_directives_model#class_directives.[i]=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
94 }
95 }
96
97 freecxx . . $ free(5d22bdacc48458e8).(model->def_directivescxx . . $ oval_directives_model#def_directives.);
98 model->def_directivescxx . . $ oval_directives_model#def_directives.=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
99
100 oval_generator_freecxx . . $ oval_generator_free(645b75e3a0637956).(model->generatorcxx . . $ oval_directives_model#generator.);
101 model->generatorcxx . . $ oval_directives_model#generator.=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
102
103 freecxx . . $ free(5d22bdacc48458e8).(model);
104 }
105
106 int oval_directives_model_import_sourcecxx . . $ oval_directives_model_import_source(a58cf06db02a42f2).(struct oval_directives_modelcxx . . $ oval_directives_model# *model, struct oscap_sourcecxx . . $ oscap_source# *source)
107 {
108 int ret = 0;
109 char *tagname = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
110 char *namespace = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
111
112 /* setup context */
113 struct oval_parser_contextcxx . . $ oval_parser_context# context;
114 context.readercxx . . $ oval_parser_context#reader. = oscap_source_get_xmlTextReadercxx . . $ oscap_source_get_xmlTextReader(9a7ef22a0934f79d).(source);
115 if (context.readercxx . . $ oval_parser_context#reader. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
116 return -1;
117 }
118 context.directives_modelcxx . . $ oval_parser_context#directives_model. = model;
119 context.user_datacxx . . $ oval_parser_context#user_data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
120 /* jump into oval_system_characteristics */
121 xmlTextReaderReadcxx . . $ xmlTextReaderRead(82a242a19623f75).(context.readercxx . . $ oval_parser_context#reader.);
122
123 /* make sure this is a right schema and tag */
124 tagname = (char *)xmlTextReaderLocalNamecxx . . $ xmlTextReaderLocalName(3322afb275581432).(context.readercxx . . $ oval_parser_context#reader.);
125 namespace = (char *)xmlTextReaderNamespaceUricxx . . $ xmlTextReaderNamespaceUri(3322afb275581432).(context.readercxx . . $ oval_parser_context#reader.);
126 int is_ovaldir = 0;
127 if (namespace != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
128 is_ovaldir = strcmpcxx . . $ strcmp(5ae29d726ae57f88).((const char *)OVAL_DIRECTIVES_NAMESPACEcxx . . $ `src/OVAL/oval_agent_api_impl.h:59:9`!, namespace) == 0;
129 }
130 /* start parsing */
131 if (is_ovaldir && (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(tagname, OVAL_ROOT_ELM_DIRECTIVEScxx . . $ `src/OVAL/oval_parser_impl.h:39:9`!) == 0)) {
132 ret = oval_directives_model_parsecxx . . $ oval_directives_model_parse(b61d4daae99e998a).(context.readercxx . . $ oval_parser_context#reader., &context);
133 } else {
134 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_OSCAPcxx . . $ `src/common/public/oscap_error.h:60:9`!, "Missing \"oval_directives\" element");
135 ret = -1;
136 }
137
138 freecxx . . $ free(5d22bdacc48458e8).(tagname);
139 freecxx . . $ free(5d22bdacc48458e8).(namespace);
140 xmlFreeTextReadercxx . . $ xmlFreeTextReader(724dbfdba9ec3ce8).(context.readercxx . . $ oval_parser_context#reader.);
141 return ret;
142 }
143
144 int oval_directives_model_exportcxx . . $ oval_directives_model_export(d96ae1760460c3db).(struct oval_directives_modelcxx . . $ oval_directives_model# *model, const char *file) {
145 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(model);
146
147 xmlDocPtrcxx . . $ xmlDocPtr# doc;
148
149 doc = xmlNewDoccxx . . $ xmlNewDoc(6ad5ddcc52642397).(BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "1.0");
150 if (doc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
151 oscap_setxmlerrcxx . . $ `src/common/_error.h:36:9`!(xmlGetLastError());
152 return -1;
153 }
154
155 oval_directives_model_to_domcxx . . $ oval_directives_model_to_dom(d16ba60d06e3d86a).(model, doc, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
156 return oscap_xml_save_filename_freecxx . . $ oscap_xml_save_filename_free(4641885591a9fcee).(file, doc);
157 }
158
159
160
161 struct oval_generatorcxx . . $ oval_generator# *oval_directives_model_get_generatorcxx . . $ oval_directives_model_get_generator(ef8b8402b584ad04).(struct oval_directives_modelcxx . . $ oval_directives_model# *model)
162 {
163 return model->generatorcxx . . $ oval_directives_model#generator.;
164 }
165
166 struct oval_result_directivescxx . . $ oval_result_directives# *oval_directives_model_get_defdirscxx . . $ oval_directives_model_get_defdirs(3cbe8edfdf311cf3).(struct oval_directives_modelcxx . . $ oval_directives_model# *model)
167 {
168 return model->def_directivescxx . . $ oval_directives_model#def_directives.;
169 }
170
171 struct oval_result_directivescxx . . $ oval_result_directives# *oval_directives_model_get_classdircxx . . $ oval_directives_model_get_classdir(93bd734342fe4274).(struct oval_directives_modelcxx . . $ oval_directives_model# *model, oval_definition_class_tcxx . . $ oval_definition_class_t# classdir)
172 {
173 /* enum -> index */
174 int classind = --classdir;
175
176 if (classind < NUMBER_OF_CLASSEScxx . . $ `src/OVAL/oval_directives.c:52:9`!)
177 return model->class_directivescxx . . $ oval_directives_model#class_directives.[classind];
178
179 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
180 }
181
182 struct oval_result_directivescxx . . $ oval_result_directives# *oval_directives_model_get_new_classdircxx . . $ oval_directives_model_get_new_classdir(93bd734342fe4274).(struct oval_directives_modelcxx . . $ oval_directives_model# *model, oval_definition_class_tcxx . . $ oval_definition_class_t# classdir)
183 {
184 int classind = --classdir;
185
186 if (classind < NUMBER_OF_CLASSEScxx . . $ `src/OVAL/oval_directives.c:52:9`!) {
187 if (model->class_directivescxx . . $ oval_directives_model#class_directives.[classind] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
188 model->class_directivescxx . . $ oval_directives_model#class_directives.[classind] = oval_result_directives_newcxx . . $ oval_result_directives_new(eca706299e9b42ea).();
189
190 return model->class_directivescxx . . $ oval_directives_model#class_directives.[classind];
191 }
192
193 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
194 }
195
196
197 struct oval_result_directivescxx . . $ oval_result_directives# *oval_result_directives_newcxx . . $ oval_result_directives_new(eca706299e9b42ea).(void)
198 {
199 struct oval_result_directivescxx . . $ oval_result_directives# *directives = (struct oval_result_directivescxx . . $ oval_result_directives# *)
200 malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct oval_result_directivescxx . . $ oval_result_directives#));
201 if (directives == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
202 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
203
204 /* full report by default */
205 oval_result_directives_set_reportedcxx . . $ oval_result_directives_set_reported(a356a24a443d853f).(directives,
206 OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE. | OVAL_RESULT_FALSEcxx . . $ OVAL_RESULT_FALSE. |
207 OVAL_RESULT_UNKNOWNcxx . . $ OVAL_RESULT_UNKNOWN. | OVAL_RESULT_NOT_EVALUATEDcxx . . $ OVAL_RESULT_NOT_EVALUATED. |
208 OVAL_RESULT_ERRORcxx . . $ OVAL_RESULT_ERROR. | OVAL_RESULT_NOT_APPLICABLEcxx . . $ OVAL_RESULT_NOT_APPLICABLE.,
209 truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
210
211 oval_result_directives_set_contentcxx . . $ oval_result_directives_set_content(d6d0d72a2ce41db6).(directives,
212 OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE. | OVAL_RESULT_FALSEcxx . . $ OVAL_RESULT_FALSE. |
213 OVAL_RESULT_UNKNOWNcxx . . $ OVAL_RESULT_UNKNOWN. | OVAL_RESULT_NOT_EVALUATEDcxx . . $ OVAL_RESULT_NOT_EVALUATED. |
214 OVAL_RESULT_NOT_APPLICABLEcxx . . $ OVAL_RESULT_NOT_APPLICABLE. | OVAL_RESULT_ERRORcxx . . $ OVAL_RESULT_ERROR.,
215 OVAL_DIRECTIVE_CONTENT_FULLcxx . . $ OVAL_DIRECTIVE_CONTENT_FULL.);
216 /* default value */
217 directives->inc_definitionscxx . . $ oval_result_directives#inc_definitions.=truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
218
219 return directives;
220 }
221
222 void oval_result_directives_freecxx . . $ oval_result_directives_free(bf73806cd118afa0).(struct oval_result_directivescxx . . $ oval_result_directives# *directives)
223 {
224 freecxx . . $ free(5d22bdacc48458e8).(directives);
225 }
226
227 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oval_result_directives_get_reportedcxx . . $ oval_result_directives_get_reported(64ecf079a82735de).(struct oval_result_directivescxx . . $ oval_result_directives# *directives, oval_result_tcxx . . $ oval_result_t# type) {
228 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(directives);
229
230 int i=-1;
231 while (type) {
232 i = i + 1;
233 type = type >> 1;
234 }
235
236 if (i < 0 || i >= NUMBER_OF_RESULTScxx . . $ `src/OVAL/oval_directives.c:51:9`!) {
237 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
238 }
239
240 return directives->directivecxx . . $ oval_result_directives#directive.[i].reportedcxx . . $ oval_result_directives#$anonymous_type_0#reported.;
241 }
242
243 oval_result_directive_content_tcxx . . $ oval_result_directive_content_t# oval_result_directives_get_contentcxx . . $ oval_result_directives_get_content(51a0845ec490b4fd).
244 (struct oval_result_directivescxx . . $ oval_result_directives# * directives, oval_result_tcxx . . $ oval_result_t# type) {
245 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(directives);
246
247 int i=-1;
248 while (type) {
249 i = i + 1;
250 type = type >> 1;
251 }
252
253 if (i < 0 || i >= NUMBER_OF_RESULTScxx . . $ `src/OVAL/oval_directives.c:51:9`!) {
254 return OVAL_DIRECTIVE_CONTENT_UNKNOWNcxx . . $ OVAL_DIRECTIVE_CONTENT_UNKNOWN.;
255 }
256
257 return directives->directivecxx . . $ oval_result_directives#directive.[i].contentcxx . . $ oval_result_directives#$anonymous_type_0#content.;
258 }
259
260 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oval_result_directives_get_includedcxx . . $ oval_result_directives_get_included(beefd4b42613e69d).(struct oval_result_directivescxx . . $ oval_result_directives# *directives) {
261 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(directives);
262
263 return directives->inc_definitionscxx . . $ oval_result_directives#inc_definitions.;
264 }
265
266 void oval_result_directives_set_includedcxx . . $ oval_result_directives_set_included(893d47be619453d2).(struct oval_result_directivescxx . . $ oval_result_directives# *directives, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! val) {
267 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(directives);
268
269 directives->inc_definitionscxx . . $ oval_result_directives#inc_definitions. = val;
270 }
271
272 void oval_result_directives_set_reportedcxx . . $ oval_result_directives_set_reported(a356a24a443d853f).(struct oval_result_directivescxx . . $ oval_result_directives# *directives, int flag, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! val) {
273 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(directives);
274
275 int i=0;
276 while (flag>>i) {
277 if( flag & (1 << i) )
278 directives->directivecxx . . $ oval_result_directives#directive.[i].reportedcxx . . $ oval_result_directives#$anonymous_type_0#reported. = val;
279 i = i + 1;
280 }
281 }
282
283 void oval_result_directives_set_contentcxx . . $ oval_result_directives_set_content(d6d0d72a2ce41db6).(struct oval_result_directivescxx . . $ oval_result_directives# *directives, int flag, oval_result_directive_content_tcxx . . $ oval_result_directive_content_t# content)
284 {
285 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(directives);
286 int i=0;
287 while (flag>>i) {
288 if( flag & (1 << i) )
289 directives->directivecxx . . $ oval_result_directives#directive.[i].contentcxx . . $ oval_result_directives#$anonymous_type_0#content. = content;
290 i = i + 1;
291 }
292 }
293
294
295 static int oval_directives_model_parsecxx . . $ oval_directives_model_parse(b61d4daae99e998a).(xmlTextReaderPtrcxx . . $ xmlTextReaderPtr# reader, struct oval_parser_contextcxx . . $ oval_parser_context# *context)
296 {
297 int depth = xmlTextReaderDepthcxx . . $ xmlTextReaderDepth(82a242a19623f75).(reader);
298 int ret = 0;
299
300 xmlTextReaderReadcxx . . $ xmlTextReaderRead(82a242a19623f75).(reader);
301 while ((xmlTextReaderDepthcxx . . $ xmlTextReaderDepth(82a242a19623f75).(reader) > depth) && (ret != -1 )) {
302 if (xmlTextReaderNodeTypecxx . . $ xmlTextReaderNodeType(82a242a19623f75).(reader) == XML_READER_TYPE_ELEMENTcxx . . $ XML_READER_TYPE_ELEMENT.) {
303 char *tagname = (char *)xmlTextReaderLocalNamecxx . . $ xmlTextReaderLocalName(3322afb275581432).(reader);
304 char *namespace = (char *)xmlTextReaderNamespaceUricxx . . $ xmlTextReaderNamespaceUri(3322afb275581432).(reader);
305
306 int is_ovaldir = 0;
307 if (namespace != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
308 is_ovaldir = strcmpcxx . . $ strcmp(5ae29d726ae57f88).((const char*)OVAL_DIRECTIVES_NAMESPACEcxx . . $ `src/OVAL/oval_agent_api_impl.h:59:9`!, namespace) == 0;
309 }
310 if (is_ovaldir && (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(tagname, "generator") == 0)) {
311 struct oval_generatorcxx . . $ oval_generator# *gen;
312 gen = oval_directives_model_get_generatorcxx . . $ oval_directives_model_get_generator(ef8b8402b584ad04).(context->directives_modelcxx . . $ oval_parser_context#directives_model.);
313 ret = oval_parser_parse_tagcxx . . $ oval_parser_parse_tag(4eaaf867ce26f59b).(reader, context, &oval_generator_parse_tagcxx . . $ oval_generator_parse_tag(cf369959597901d1)., gen);
314 } else if (is_ovaldir && (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(tagname, "directives") == 0)) {
315 struct oval_result_directivescxx . . $ oval_result_directives# *def_dirs;
316 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! val;
317 def_dirs = oval_directives_model_get_defdirscxx . . $ oval_directives_model_get_defdirs(3cbe8edfdf311cf3).(context->directives_modelcxx . . $ oval_parser_context#directives_model.);
318 val=oval_parser_boolean_attributecxx . . $ oval_parser_boolean_attribute(a53adaee35698733).(reader, "include_source_definitions", 1);
319 oval_result_directives_set_includedcxx . . $ oval_result_directives_set_included(893d47be619453d2).(def_dirs, val);
320 ret = oval_parser_parse_tagcxx . . $ oval_parser_parse_tag(4eaaf867ce26f59b).(reader, context, &oval_result_directives_parse_tagcxx . . $ oval_result_directives_parse_tag(cf369959597901d1)., def_dirs);
321 } else if (is_ovaldir && (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(tagname, "class_directives") == 0)) {
322 struct oval_result_directivescxx . . $ oval_result_directives# *class_dir;
323 oval_definition_class_tcxx . . $ oval_definition_class_t# class_type;
324 char *class_str = (char *)xmlTextReaderGetAttributecxx . . $ xmlTextReaderGetAttribute(6d056300a6ef2116).(reader, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "class");
325 class_type = oval_definition_class_enumcxx . . $ oval_definition_class_enum(3bb3c9d9c15377c1).(class_str);
326 class_dir = oval_directives_model_get_new_classdircxx . . $ oval_directives_model_get_new_classdir(93bd734342fe4274).(context->directives_modelcxx . . $ oval_parser_context#directives_model., class_type);
327 ret = oval_parser_parse_tagcxx . . $ oval_parser_parse_tag(4eaaf867ce26f59b).(reader, context, &oval_result_directives_parse_tagcxx . . $ oval_result_directives_parse_tag(cf369959597901d1)., class_dir);
328 freecxx . . $ free(5d22bdacc48458e8).(class_str);
329 } else {
330 dWcxx . . $ `src/common/debug_priv.h:62:9`!("Unprocessed tag: <%s:%s>.", namespace, tagname);
331 oval_parser_skip_tagcxx . . $ oval_parser_skip_tag(b61d4daae99e998a).(reader, context);
332 }
333
334 freecxx . . $ free(5d22bdacc48458e8).(tagname);
335 freecxx . . $ free(5d22bdacc48458e8).(namespace);
336 } else {
337 if (xmlTextReaderReadcxx . . $ xmlTextReaderRead(82a242a19623f75).(reader) != XML_READER_TYPE_ELEMENTcxx . . $ XML_READER_TYPE_ELEMENT.) {
338 ret = -1;
339 break;
340 }
341 }
342 }
343
344 return ret;
345 }
346
347 static const struct oscap_string_mapcxx . . $ oscap_string_map# OVAL_DIRECTIVE_MAPcxx . . $ OVAL_DIRECTIVE_MAP.[] = {
348 {OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE., "definition_true"},
349 {OVAL_RESULT_FALSEcxx . . $ OVAL_RESULT_FALSE., "definition_false"},
350 {OVAL_RESULT_UNKNOWNcxx . . $ OVAL_RESULT_UNKNOWN., "definition_unknown"},
351 {OVAL_RESULT_ERRORcxx . . $ OVAL_RESULT_ERROR., "definition_error"},
352 {OVAL_RESULT_NOT_EVALUATEDcxx . . $ OVAL_RESULT_NOT_EVALUATED., "definition_not_evaluated"},
353 {OVAL_RESULT_NOT_APPLICABLEcxx . . $ OVAL_RESULT_NOT_APPLICABLE., "definition_not_applicable"},
354 {OVAL_ENUMERATION_INVALIDcxx . . $ `src/OVAL/oval_agent_api_impl.h:36:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!}
355 };
356
357 int oval_result_directives_parse_tagcxx . . $ oval_result_directives_parse_tag(cf369959597901d1).(xmlTextReaderPtrcxx . . $ xmlTextReaderPtr# reader, struct oval_parser_contextcxx . . $ oval_parser_context# *context, void *usr) {
358 struct oval_result_directivescxx . . $ oval_result_directives# *directives = (struct oval_result_directivescxx . . $ oval_result_directives# *)usr;
359 int retcode = 0;
360
361 xmlCharcxx . . $ xmlChar# *name = xmlTextReaderLocalNamecxx . . $ xmlTextReaderLocalName(3322afb275581432).(reader);
362 oval_result_tcxx . . $ oval_result_t# type = oscap_string_to_enumcxx . . $ oscap_string_to_enum(851d6ce10579b7d8).(OVAL_DIRECTIVE_MAPcxx . . $ OVAL_DIRECTIVE_MAP., (const char *)name);
363
364 if ( (int) type != OVAL_ENUMERATION_INVALIDcxx . . $ `src/OVAL/oval_agent_api_impl.h:36:9`!) {
365 /*reported */
366 xmlCharcxx . . $ xmlChar# *boolstr = xmlTextReaderGetAttributecxx . . $ xmlTextReaderGetAttribute(6d056300a6ef2116).(reader, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "reported");
367 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! reported = (strcmpcxx . . $ strcmp(5ae29d726ae57f88).((const char *)boolstr, "1") == 0) || (strcmpcxx . . $ strcmp(5ae29d726ae57f88).((const char *)boolstr, "true") == 0);
368 freecxx . . $ free(5d22bdacc48458e8).(boolstr);
369 oval_result_directives_set_reportedcxx . . $ oval_result_directives_set_reported(a356a24a443d853f).(directives, type, reported);
370
371 /*content */
372 xmlCharcxx . . $ xmlChar# *contentstr = xmlTextReaderGetAttributecxx . . $ xmlTextReaderGetAttribute(6d056300a6ef2116).(reader, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "content");
373 oval_result_directive_content_tcxx . . $ oval_result_directive_content_t# content = OVAL_DIRECTIVE_CONTENT_UNKNOWNcxx . . $ OVAL_DIRECTIVE_CONTENT_UNKNOWN.;
374 if (contentstr) {
375 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("thin", (const char *)contentstr) == 0)
376 content = OVAL_DIRECTIVE_CONTENT_THINcxx . . $ OVAL_DIRECTIVE_CONTENT_THIN.;
377 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("full", (const char *)contentstr) == 0)
378 content = OVAL_DIRECTIVE_CONTENT_FULLcxx . . $ OVAL_DIRECTIVE_CONTENT_FULL.;
379
380 if (content != OVAL_DIRECTIVE_CONTENT_UNKNOWNcxx . . $ OVAL_DIRECTIVE_CONTENT_UNKNOWN.) {
381 oval_result_directives_set_contentcxx . . $ oval_result_directives_set_content(d6d0d72a2ce41db6).(directives, type, content);
382 } else {
383 dWcxx . . $ `src/common/debug_priv.h:62:9`!("Cannot resolve @content: \"%s\".", contentstr);
384 retcode = 1;
385 }
386 freecxx . . $ free(5d22bdacc48458e8).(contentstr);
387 } else {
388 content = OVAL_DIRECTIVE_CONTENT_FULLcxx . . $ OVAL_DIRECTIVE_CONTENT_FULL.;
389 }
390 } else {
391 dWcxx . . $ `src/common/debug_priv.h:62:9`!("Cannot resolve <%s>.", name);
392 retcode = 1;
393 }
394 freecxx . . $ free(5d22bdacc48458e8).(name);
395 return retcode;
396 }
397
398 xmlNodecxx . . $ xmlNode# *oval_directives_model_to_domcxx . . $ oval_directives_model_to_dom(d16ba60d06e3d86a).(struct oval_directives_modelcxx . . $ oval_directives_model# *model, xmlDocPtrcxx . . $ xmlDocPtr# doc, xmlNodecxx . . $ xmlNode# * parent)
399 {
400 xmlNodecxx . . $ xmlNode# *root_node;
401 xmlNodecxx . . $ xmlNode# *directives_node;
402 const char *class_str;
403 struct oval_result_directivescxx . . $ oval_result_directives# * dirs;
404
405
406
407 if(parent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { /* standalone OVAL Directives Document */
408 root_node = xmlNewNodecxx . . $ xmlNewNode(cc9f3f2e425bac4).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! OVAL_ROOT_ELM_DIRECTIVEScxx . . $ `src/OVAL/oval_parser_impl.h:39:9`!);
409 xmlDocSetRootElementcxx . . $ xmlDocSetRootElement(ad0e42d5f79fdac5).(doc, root_node);
410
411 /*schemalocation */
412 xmlNewNsPropcxx . . $ xmlNewNsProp(9b3cf13d34b7936f).(root_node, lookup_xsi_nscxx . . $ lookup_xsi_ns(3e517de3a327c4f9).(doc), BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "schemaLocation", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! OVAL_DIR_SCHEMA_LOCATIONcxx . . $ `src/OVAL/oval_agent_api_impl.h:80:9`!);
413
414 /* NS */
415 xmlNscxx . . $ xmlNs# *ns_common = xmlNewNscxx . . $ xmlNewNs(f962c8aae91c9a10).(root_node, OVAL_COMMON_NAMESPACEcxx . . $ `src/OVAL/oval_agent_api_impl.h:40:9`!, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "oval");
416 xmlNscxx . . $ xmlNs# *ns_results = xmlNewNscxx . . $ xmlNewNs(f962c8aae91c9a10).(root_node, OVAL_RESULTS_NAMESPACEcxx . . $ `src/OVAL/oval_agent_api_impl.h:57:9`!, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "oval-res");
417 xmlNscxx . . $ xmlNs# *ns_directives = xmlNewNscxx . . $ xmlNewNs(f962c8aae91c9a10).(root_node, OVAL_DIRECTIVES_NAMESPACEcxx . . $ `src/OVAL/oval_agent_api_impl.h:59:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
418 xmlSetNscxx . . $ xmlSetNs(cd680be8abdf9ad3).(root_node, ns_common);
419 xmlSetNscxx . . $ xmlSetNs(cd680be8abdf9ad3).(root_node, ns_results);
420 xmlSetNscxx . . $ xmlSetNs(cd680be8abdf9ad3).(root_node, ns_directives);
421
422 /* Report generator */
423 oval_generator_to_domcxx . . $ oval_generator_to_dom(56faf3182cb06d7f).(model->generatorcxx . . $ oval_directives_model#generator., doc, root_node);
424 }
425 else { /* Directives are part of OVAL Results Document */
426 root_node = parent;
427 }
428
429
430 /* Report default directives */
431 xmlNscxx . . $ xmlNs# *ns_search = xmlSearchNsByHrefcxx . . $ xmlSearchNsByHref(d0fb0b6b99319c4).(doc, parent, OVAL_RESULTS_NAMESPACEcxx . . $ `src/OVAL/oval_agent_api_impl.h:57:9`!);
432 directives_node = xmlNewTextChildcxx . . $ xmlNewTextChild(4c74f4d7754e7bc8).(root_node, ns_search, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "directives", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
433 dirs = oval_directives_model_get_defdirscxx . . $ oval_directives_model_get_defdirs(3cbe8edfdf311cf3).(model);
434 if(!oval_result_directives_get_includedcxx . . $ oval_result_directives_get_included(beefd4b42613e69d).(dirs))
435 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(directives_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "include_source_definitions", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "false");
436 oval_result_directives_to_domcxx . . $ oval_result_directives_to_dom(edb0188a93e50e1b).(dirs, doc, directives_node);
437
438 /* Report class directives */
439 for(int i=OVAL_CLASS_COMPLIANCEcxx . . $ OVAL_CLASS_COMPLIANCE.; i<=OVAL_CLASS_VULNERABILITYcxx . . $ OVAL_CLASS_VULNERABILITY.; i++) {
440 dirs = oval_directives_model_get_classdircxx . . $ oval_directives_model_get_classdir(93bd734342fe4274).(model, i);
441 if (dirs) {
442 directives_node = xmlNewTextChildcxx . . $ xmlNewTextChild(4c74f4d7754e7bc8).(root_node, ns_search, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "class_directives", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
443 class_str = oval_definition_class_textcxx . . $ oval_definition_class_text(57b08f9c5fa3eb98).(i);
444 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(directives_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "class", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! class_str);
445 oval_result_directives_to_domcxx . . $ oval_result_directives_to_dom(edb0188a93e50e1b).(dirs, doc, directives_node);
446 }
447 }
448
449 return root_node;
450 }
451
452 int oval_result_directives_to_domcxx . . $ oval_result_directives_to_dom(edb0188a93e50e1b).(struct oval_result_directivescxx . . $ oval_result_directives# *directives, xmlDoccxx . . $ xmlDoc# * doc, xmlNodecxx . . $ xmlNode# * parent) {
453 int retcode = 1;
454 xmlNscxx . . $ xmlNs# *ns_results = xmlSearchNsByHrefcxx . . $ xmlSearchNsByHref(d0fb0b6b99319c4).(doc, parent, OVAL_RESULTS_NAMESPACEcxx . . $ `src/OVAL/oval_agent_api_impl.h:57:9`!);
455 xmlNodecxx . . $ xmlNode# *directives_node = parent;
456
457 const struct oscap_string_mapcxx . . $ oscap_string_map# *map;
458 for (map = OVAL_DIRECTIVE_MAPcxx . . $ OVAL_DIRECTIVE_MAP.; map->stringcxx . . $ oscap_string_map#string.; map++) {
459 oval_result_tcxx . . $ oval_result_t# directive = (oval_result_tcxx . . $ oval_result_t#) map->valuecxx . . $ oscap_string_map#value.;
460 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! reported = oval_result_directives_get_reportedcxx . . $ oval_result_directives_get_reported(64ecf079a82735de).(directives, directive);
461 oval_result_directive_content_tcxx . . $ oval_result_directive_content_t# content = oval_result_directives_get_contentcxx . . $ oval_result_directives_get_content(51a0845ec490b4fd).(directives, directive);
462 xmlNodecxx . . $ xmlNode# *directive_node = xmlNewTextChildcxx . . $ xmlNewTextChild(4c74f4d7754e7bc8).(directives_node, ns_results, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`!(map->stringcxx . . $ oscap_string_map#string.), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
463 char *val_reported = (reported) ? "true" : "false";
464 char *val_content = (content == OVAL_DIRECTIVE_CONTENT_FULLcxx . . $ OVAL_DIRECTIVE_CONTENT_FULL.) ? "full" : "thin";
465 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(directive_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "reported", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! val_reported);
466 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(directive_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "content", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! val_content);
467 }
468 return retcode;
469 }
470
471 /**
472 * @endcond
473 */