Debian Codegraph @

src/XCCDF/tailoring.c

raw symbols SCIP
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 * Martin Preisler <[email protected]>
21 */
22
23 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
24 #include <config.h>cxx . . $ `<file>/build/config.h`/
25 #endif
26
27 #include <string.h>
28
29 #include "item.h"cxx . . $ `<file>/src/XCCDF/item.h`/
30 #include "helpers.h"cxx . . $ `<file>/src/XCCDF/helpers.h`/
31 #include "xccdf_impl.h"cxx . . $ `<file>/src/XCCDF/xccdf_impl.h`/
32 #include "common/_error.h"cxx . . $ `<file>/src/common/_error.h`/
33 #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/
34 #include "common/elements.h"cxx . . $ `<file>/src/common/elements.h`/
35 #include "source/oscap_source_priv.h"cxx . . $ `<file>/src/source/oscap_source_priv.h`/
36 #include "source/public/oscap_source.h"cxx . . $ `<file>/src/source/public/oscap_source.h`/
37
38 struct xccdf_tailoringcxx . . $ xccdf_tailoring# *xccdf_tailoring_newcxx . . $ xccdf_tailoring_new(da9ed42e2f0b0463).(void)
39 {
40 struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(struct xccdf_tailoringcxx . . $ xccdf_tailoring#));
41
42 tailoring->idcxx . . $ xccdf_tailoring#id. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
43
44 tailoring->benchmark_refcxx . . $ xccdf_tailoring#benchmark_ref. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
45 tailoring->benchmark_ref_versioncxx . . $ xccdf_tailoring#benchmark_ref_version. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
46
47 tailoring->statusescxx . . $ xccdf_tailoring#statuses. = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).();
48 tailoring->dc_statusescxx . . $ xccdf_tailoring#dc_statuses. = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).();
49
50 tailoring->versioncxx . . $ xccdf_tailoring#version. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
51 tailoring->version_updatecxx . . $ xccdf_tailoring#version_update. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
52 tailoring->version_timecxx . . $ xccdf_tailoring#version_time. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
53
54 tailoring->metadatacxx . . $ xccdf_tailoring#metadata. = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).();
55 tailoring->profilescxx . . $ xccdf_tailoring#profiles. = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).();
56
57 return tailoring;
58 }
59
60 void xccdf_tailoring_freecxx . . $ xccdf_tailoring_free(b4f0b704104bd93e).(struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring)
61 {
62 if (tailoring) {
63 freecxx . . $ free(5d22bdacc48458e8).(tailoring->idcxx . . $ xccdf_tailoring#id.);
64
65 freecxx . . $ free(5d22bdacc48458e8).(tailoring->benchmark_refcxx . . $ xccdf_tailoring#benchmark_ref.);
66 freecxx . . $ free(5d22bdacc48458e8).(tailoring->benchmark_ref_versioncxx . . $ xccdf_tailoring#benchmark_ref_version.);
67
68 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(tailoring->statusescxx . . $ xccdf_tailoring#statuses., (oscap_destruct_funccxx . . $ oscap_destruct_func#) xccdf_status_freecxx . . $ xccdf_status_free(52154eead9f5a465).);
69 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(tailoring->dc_statusescxx . . $ xccdf_tailoring#dc_statuses., (oscap_destruct_funccxx . . $ oscap_destruct_func#) oscap_reference_freecxx . . $ oscap_reference_free(bba9e0e36c035e34).);
70
71 freecxx . . $ free(5d22bdacc48458e8).(tailoring->versioncxx . . $ xccdf_tailoring#version.);
72 freecxx . . $ free(5d22bdacc48458e8).(tailoring->version_updatecxx . . $ xccdf_tailoring#version_update.);
73 freecxx . . $ free(5d22bdacc48458e8).(tailoring->version_timecxx . . $ xccdf_tailoring#version_time.);
74
75 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(tailoring->metadatacxx . . $ xccdf_tailoring#metadata., (oscap_destruct_funccxx . . $ oscap_destruct_func#) freecxx . . $ free(5d22bdacc48458e8).);
76 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(tailoring->profilescxx . . $ xccdf_tailoring#profiles., (oscap_destruct_funccxx . . $ oscap_destruct_func#) xccdf_profile_freecxx . . $ xccdf_profile_free(9e1ae929b010245a).);
77
78 freecxx . . $ free(5d22bdacc48458e8).(tailoring);
79 }
80 }
81
82 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_tailoring_add_profilecxx . . $ xccdf_tailoring_add_profile(b580bdfc97984c8f).(struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring, struct xccdf_profilecxx . . $ xccdf_profile# *profile)
83 {
84 xccdf_profile_set_tailoringcxx . . $ xccdf_profile_set_tailoring(17d838de7b532fe1).(profile, truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
85 return oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(tailoring->profilescxx . . $ xccdf_tailoring#profiles., XITEMcxx . . $ `src/XCCDF/helpers.h:35:9`!(profile));
86 }
87
88 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _list_ptreq_cmpcxx . . $ _list_ptreq_cmp(838b4d1787e4a177).(void *a, void *b)
89 {
90 return a == b;
91 }
92
93 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_tailoring_remove_profilecxx . . $ xccdf_tailoring_remove_profile(b580bdfc97984c8f).(struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring, struct xccdf_profilecxx . . $ xccdf_profile# *profile)
94 {
95 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(xccdf_profile_get_tailoring(profile));
96
97 // We have to make sure there is no other profile in tailoring that inherits
98 // the profile we are about to remove.
99
100 const char *profile_id = xccdf_profile_get_idcxx . . $ xccdf_profile_get_id(d143a4aa05fc37ce).(profile);
101
102 struct xccdf_profile_iteratorcxx . . $ xccdf_profile_iterator#* it = xccdf_tailoring_get_profilescxx . . $ xccdf_tailoring_get_profiles(41ce0c0fc277fbfc).(tailoring);
103 while (xccdf_profile_iterator_has_morecxx . . $ xccdf_profile_iterator_has_more(adef36931cdf4bdd).(it)) {
104 struct xccdf_profilecxx . . $ xccdf_profile#* prof = xccdf_profile_iterator_nextcxx . . $ xccdf_profile_iterator_next(4851320650739603).(it);
105
106 if (prof == profile)
107 continue;
108
109 const char *extends = xccdf_profile_get_extendscxx . . $ xccdf_profile_get_extends(d143a4aa05fc37ce).(prof);
110 if (oscap_strcmpcxx . . $ oscap_strcmp(5ae29d726ae57f88).(profile_id, extends) == 0) {
111 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!,
112 "Can't remove given profile '%s' from tailoring. Other profiles are inheriting from it!",
113 profile_id);
114
115 xccdf_profile_iterator_freecxx . . $ xccdf_profile_iterator_free(e346a4b111941870).(it);
116 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
117 }
118 }
119 xccdf_profile_iterator_freecxx . . $ xccdf_profile_iterator_free(e346a4b111941870).(it);
120
121 return oscap_list_removecxx . . $ oscap_list_remove(7e6762e164fcba91).(tailoring->profilescxx . . $ xccdf_tailoring#profiles., XITEMcxx . . $ `src/XCCDF/helpers.h:35:9`!(profile), (oscap_cmp_funccxx . . $ oscap_cmp_func#)_list_ptreq_cmpcxx . . $ _list_ptreq_cmp(838b4d1787e4a177)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
122 }
123
124 struct xccdf_tailoringcxx . . $ xccdf_tailoring# *xccdf_tailoring_parsecxx . . $ xccdf_tailoring_parse(378ba31ff5d7330e).(xmlTextReaderPtrcxx . . $ xmlTextReaderPtr# reader, struct xccdf_itemcxx . . $ xccdf_item# *benchmark)
125 {
126 XCCDF_ASSERT_ELEMENTcxx . . $ `src/XCCDF/elements.h:141:9`!(reader, XCCDFE_TAILORING);
127
128 struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring = xccdf_tailoring_newcxx . . $ xccdf_tailoring_new(da9ed42e2f0b0463).();
129
130 const char *id = xccdf_attribute_getcxx . . $ xccdf_attribute_get(9e9cd2f6cdd20132).(reader, XCCDFA_IDcxx . . $ XCCDFA_ID.);
131 xccdf_tailoring_set_idcxx . . $ xccdf_tailoring_set_id(c11c6205a3b142d5).(tailoring, id);
132
133 int depth = oscap_element_depthcxx . . $ oscap_element_depth(82a242a19623f75).(reader) + 1;
134
135 // Read to the inside of Tailoring.
136 xmlTextReaderReadcxx . . $ xmlTextReaderRead(82a242a19623f75).(reader);
137
138 while (oscap_to_start_elementcxx . . $ oscap_to_start_element(c0c45fd800596ca5).(reader, depth)) {
139 switch (xccdf_element_getcxx . . $ xccdf_element_get(a5dd71d24d1f6f1).(reader)) {
140 case XCCDFE_BENCHMARK_REFcxx . . $ XCCDFE_BENCHMARK_REF.: {
141 freecxx . . $ free(5d22bdacc48458e8).(tailoring->benchmark_refcxx . . $ xccdf_tailoring#benchmark_ref.);
142 tailoring->benchmark_refcxx . . $ xccdf_tailoring#benchmark_ref. = 0;
143
144 freecxx . . $ free(5d22bdacc48458e8).(tailoring->benchmark_ref_versioncxx . . $ xccdf_tailoring#benchmark_ref_version.);
145 tailoring->benchmark_ref_versioncxx . . $ xccdf_tailoring#benchmark_ref_version. = 0;
146
147 const char *ref = xccdf_attribute_getcxx . . $ xccdf_attribute_get(9e9cd2f6cdd20132).(reader, XCCDFA_HREFcxx . . $ XCCDFA_HREF.);
148 if (ref)
149 tailoring->benchmark_refcxx . . $ xccdf_tailoring#benchmark_ref. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(ref);
150
151 const char *ref_version = xccdf_attribute_getcxx . . $ xccdf_attribute_get(9e9cd2f6cdd20132).(reader, XCCDFA_VERSIONcxx . . $ XCCDFA_VERSION.);
152 if (ref_version)
153 tailoring->benchmark_ref_versioncxx . . $ xccdf_tailoring#benchmark_ref_version. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(ref_version);
154
155 break;
156 }
157 case XCCDFE_STATUScxx . . $ XCCDFE_STATUS.: {
158 const char *date = xccdf_attribute_getcxx . . $ xccdf_attribute_get(9e9cd2f6cdd20132).(reader, XCCDFA_DATEcxx . . $ XCCDFA_DATE.);
159 char *str = oscap_element_string_copycxx . . $ oscap_element_string_copy(93c99f8009311dd0).(reader);
160 struct xccdf_statuscxx . . $ xccdf_status# *status = xccdf_status_new_fillcxx . . $ xccdf_status_new_fill(5b01defcf5797517).(str, date);
161 freecxx . . $ free(5d22bdacc48458e8).(str);
162 oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(tailoring->statusescxx . . $ xccdf_tailoring#statuses., status);
163 break;
164 }
165 case XCCDFE_DC_STATUScxx . . $ XCCDFE_DC_STATUS.:
166 oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(tailoring->dc_statusescxx . . $ xccdf_tailoring#dc_statuses., oscap_reference_new_parsecxx . . $ oscap_reference_new_parse(9bd5dfebdc33e03e).(reader));
167 break;
168 case XCCDFE_VERSIONcxx . . $ XCCDFE_VERSION.: {
169 xmlNodecxx . . $ xmlNode# *ver = xmlTextReaderExpandcxx . . $ xmlTextReaderExpand(ed6f36f6605b4589).(reader);
170 /* optional attributes */
171 tailoring->version_timecxx . . $ xccdf_tailoring#version_time. = (char*) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(ver, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "time");
172 tailoring->version_updatecxx . . $ xccdf_tailoring#version_update. = (char*) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(ver, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "update");
173 /* content */
174 tailoring->versioncxx . . $ xccdf_tailoring#version. = (char *) xmlNodeGetContentcxx . . $ xmlNodeGetContent(cadd6f62b3cc3aeb).(ver);
175 if (oscap_streqcxx . . $ oscap_streq(b7a7aa4a824b7595).(tailoring->versioncxx . . $ xccdf_tailoring#version., "")) {
176 freecxx . . $ free(5d22bdacc48458e8).(tailoring->versioncxx . . $ xccdf_tailoring#version.);
177 tailoring->versioncxx . . $ xccdf_tailoring#version. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
178 }
179 break;
180 }
181 case XCCDFE_METADATAcxx . . $ XCCDFE_METADATA.: {
182 char* xml = oscap_get_xmlcxx . . $ oscap_get_xml(93c99f8009311dd0).(reader);
183 oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(tailoring->metadatacxx . . $ xccdf_tailoring#metadata., oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(xml));
184 freecxx . . $ free(5d22bdacc48458e8).(xml);
185 break;
186 }
187 case XCCDFE_PROFILEcxx . . $ XCCDFE_PROFILE.: {
188 if (benchmark != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
189 dIcxx . . $ `src/common/debug_priv.h:61:9`!("Parsing Tailoring Profiles without reference to Benchmark");
190 }
191 struct xccdf_itemcxx . . $ xccdf_item# *item = xccdf_profile_parsecxx . . $ xccdf_profile_parse(8cf60c58117f1f7b).(reader, benchmark);
192 if (!xccdf_tailoring_add_profilecxx . . $ xccdf_tailoring_add_profile(b580bdfc97984c8f).(tailoring, XPROFILEcxx . . $ `src/XCCDF/helpers.h:32:9`!(item))) {
193 dWcxx . . $ `src/common/debug_priv.h:62:9`!("Failed to add profile to tailoring while parsing!");
194 }
195 break;
196 }
197 default:
198 dWcxx . . $ `src/common/debug_priv.h:62:9`!("Encountered an unknown element '%s' while parsing XCCDF Tailoring element.",
199 xmlTextReaderConstLocalName(reader));
200 }
201 xmlTextReaderReadcxx . . $ xmlTextReaderRead(82a242a19623f75).(reader);
202 }
203
204 return tailoring;
205 }
206
207 struct xccdf_tailoringcxx . . $ xccdf_tailoring# *xccdf_tailoring_import_sourcecxx . . $ xccdf_tailoring_import_source(725401c546835d49).(struct oscap_sourcecxx . . $ oscap_source# *source, struct xccdf_benchmarkcxx . . $ xccdf_benchmark# *benchmark)
208 {
209 xmlTextReaderPtrcxx . . $ xmlTextReaderPtr# reader = oscap_source_get_xmlTextReadercxx . . $ oscap_source_get_xmlTextReader(9a7ef22a0934f79d).(source);
210 if (!reader) {
211 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
212 }
213
214 while (xmlTextReaderReadcxx . . $ xmlTextReaderRead(82a242a19623f75).(reader) == 1 && xmlTextReaderNodeTypecxx . . $ xmlTextReaderNodeType(82a242a19623f75).(reader) != XML_READER_TYPE_ELEMENTcxx . . $ XML_READER_TYPE_ELEMENT.) ;
215 struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring = xccdf_tailoring_parsecxx . . $ xccdf_tailoring_parse(378ba31ff5d7330e).(reader, XITEMcxx . . $ `src/XCCDF/helpers.h:35:9`!(benchmark));
216 xmlFreeTextReadercxx . . $ xmlFreeTextReader(724dbfdba9ec3ce8).(reader);
217 if (!tailoring) { // parsing fatal error
218 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Failed to parse tailoring from '%s'.", oscap_source_readable_origin(source));
219 }
220 return tailoring;
221 }
222
223 xmlNodePtrcxx . . $ xmlNodePtr# xccdf_tailoring_to_domcxx . . $ xccdf_tailoring_to_dom(31d45adc3aaec44).(struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring, xmlDocPtrcxx . . $ xmlDocPtr# doc, xmlNodePtrcxx . . $ xmlNodePtr# parent, const struct xccdf_version_infocxx . . $ xccdf_version_info# *version_info)
224 {
225 xmlNscxx . . $ xmlNs# *ns_tailoring = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
226
227 xmlNodecxx . . $ xmlNode# *tailoring_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`! "Tailoring");
228
229 const char *xccdf_version = xccdf_version_info_get_versioncxx . . $ xccdf_version_info_get_version(1e170957141ea993).(version_info);
230 #ifdef __USE_GNUcxx . . $ `<external>/18206667465210621810/features.h:430:10`!
231 if (strverscmpcxx . . $ strverscmp(5ae29d726ae57f88).(xccdf_version, "1.1") >= 0 && strverscmpcxx . . $ strverscmp(5ae29d726ae57f88).(xccdf_version, "1.2") < 0) {
232 #else
233 if (strcmp(xccdf_version, "1.1") >= 0 && strcmp(xccdf_version, "1.2") < 0) {
234 #endif
235 // XCCDF 1.1 does not support Tailoring!
236 // However we will allow Tailoring export if it is done to an external
237 // file. The namespace will be our custom xccdf-1.1-tailoring extension
238 // namespace.
239
240 if (parent != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
241 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "XCCDF 1.1 does not support embedded Tailoring elements!");
242 xmlFreeNodecxx . . $ xmlFreeNode(5712c9d4a25253).(tailoring_node);
243 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
244 }
245
246 ns_tailoring = xmlNewNscxx . . $ xmlNewNs(f962c8aae91c9a10).(tailoring_node,
247 BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "http://open-scap.org/page/Xccdf-1.1-tailoring",
248 BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "cdf-11-tailoring"
249 );
250 }
251 #ifdef __USE_GNUcxx . . $ `<external>/18206667465210621810/features.h:430:10`!
252 else if (strverscmpcxx . . $ strverscmp(5ae29d726ae57f88).(xccdf_version, "1.1") < 0) {
253 #else
254 else if (strcmp(xccdf_version, "1.1") < 0) {
255 #endif
256 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "XCCDF Tailoring isn't supported in XCCDF version '%s',"
257 "nor does openscap have a custom extension for this scenario. "
258 "XCCDF Tailoring requires XCCDF 1.1 and higher, 1.2 is recommended.",
259 xccdf_version);
260
261 xmlFreeNodecxx . . $ xmlFreeNode(5712c9d4a25253).(tailoring_node);
262 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
263 }
264
265 xmlNscxx . . $ xmlNs# *ns_xccdf = parent != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? lookup_xccdf_nscxx . . $ lookup_xccdf_ns(145fb009c13e3a1).(doc, parent, version_info) : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
266 if (!ns_xccdf) {
267 // In cases where tailoring ends up being the root node we have to create
268 // a namespace at the node itself.
269 ns_xccdf = xmlNewNscxx . . $ xmlNewNs(f962c8aae91c9a10).(tailoring_node,
270 BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! xccdf_version_info_get_namespace_uricxx . . $ xccdf_version_info_get_namespace_uri(1e170957141ea993).(version_info),
271 BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "xccdf");
272 }
273
274 if (!ns_tailoring)
275 ns_tailoring = ns_xccdf;
276
277 // We intentionally set the wrong namespace here since children of tailoring
278 // will reuse it and we want them to have the xccdf namespace, the namespace
279 // is set to the proper namespace before returning the tailoring.
280 xmlSetNscxx . . $ xmlSetNs(cd680be8abdf9ad3).(tailoring_node, ns_xccdf);
281
282 if (parent)
283 xmlAddChildcxx . . $ xmlAddChild(93e65f4d4ebd68bd).(parent, tailoring_node);
284 else
285 xmlDocSetRootElementcxx . . $ xmlDocSetRootElement(ad0e42d5f79fdac5).(doc, tailoring_node);
286
287 if (tailoring->idcxx . . $ xccdf_tailoring#id.) {
288 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(tailoring_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! tailoring->idcxx . . $ xccdf_tailoring#id.);
289 }
290
291 if (tailoring->benchmark_refcxx . . $ xccdf_tailoring#benchmark_ref. || tailoring->benchmark_ref_versioncxx . . $ xccdf_tailoring#benchmark_ref_version.) {
292 xmlNodePtrcxx . . $ xmlNodePtr# benchmark_ref_node = xmlNewChildcxx . . $ xmlNewChild(4c74f4d7754e7bc8).(tailoring_node, ns_tailoring, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "benchmark", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
293
294 if (tailoring->benchmark_refcxx . . $ xccdf_tailoring#benchmark_ref.)
295 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(benchmark_ref_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "href", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! tailoring->benchmark_refcxx . . $ xccdf_tailoring#benchmark_ref.);
296
297 if (tailoring->benchmark_ref_versioncxx . . $ xccdf_tailoring#benchmark_ref_version.)
298 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(benchmark_ref_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "version", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! tailoring->benchmark_ref_versioncxx . . $ xccdf_tailoring#benchmark_ref_version.);
299 }
300
301 struct xccdf_status_iteratorcxx . . $ xccdf_status_iterator# *statuses = xccdf_tailoring_get_statusescxx . . $ xccdf_tailoring_get_statuses(2e50d5a66302f077).(tailoring);
302 while (xccdf_status_iterator_has_morecxx . . $ xccdf_status_iterator_has_more(5b19601e9ed40d49).(statuses)) {
303 struct xccdf_statuscxx . . $ xccdf_status# *status = xccdf_status_iterator_nextcxx . . $ xccdf_status_iterator_next(fbe046a6f69752f4).(statuses);
304 xccdf_status_to_domcxx . . $ xccdf_status_to_dom(cdfa0c980d5210a9).(status, doc, tailoring_node, version_info);
305 }
306 xccdf_status_iterator_freecxx . . $ xccdf_status_iterator_free(2da3bd6d542af8d3).(statuses);
307
308 struct oscap_reference_iteratorcxx . . $ oscap_reference_iterator# *dc_statuses = xccdf_tailoring_get_dc_statusescxx . . $ xccdf_tailoring_get_dc_statuses(db58623d3dff8a6c).(tailoring);
309 while (oscap_reference_iterator_has_morecxx . . $ oscap_reference_iterator_has_more(3902913d46f91173).(dc_statuses)) {
310 struct oscap_referencecxx . . $ oscap_reference# *ref = oscap_reference_iterator_nextcxx . . $ oscap_reference_iterator_next(81bc9a067126085c).(dc_statuses);
311 oscap_reference_to_domcxx . . $ oscap_reference_to_dom(a070737ff3168a5e).(ref, tailoring_node, doc, "dc-status");
312 }
313 oscap_reference_iterator_freecxx . . $ oscap_reference_iterator_free(3e07142178288e0).(dc_statuses);
314
315 /* version and attributes */
316 const char *version = xccdf_tailoring_get_versioncxx . . $ xccdf_tailoring_get_version(8db670c91c6a1b30).(tailoring);
317 if (version) {
318 xmlNodecxx . . $ xmlNode#* version_node = xmlNewTextChildcxx . . $ xmlNewTextChild(4c74f4d7754e7bc8).(tailoring_node, ns_tailoring, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "version", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! version);
319
320 const char *version_update = xccdf_tailoring_get_version_updatecxx . . $ xccdf_tailoring_get_version_update(8db670c91c6a1b30).(tailoring);
321 if (version_update)
322 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(version_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "update", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! version_update);
323
324 const char *version_time = xccdf_tailoring_get_version_timecxx . . $ xccdf_tailoring_get_version_time(8db670c91c6a1b30).(tailoring);
325 if (version_time)
326 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(version_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "time", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! version_time);
327 }
328
329 struct oscap_string_iteratorcxx . . $ oscap_string_iterator#* metadata = xccdf_tailoring_get_metadatacxx . . $ xccdf_tailoring_get_metadata(e4dafec89ab82417).(tailoring);
330 while (oscap_string_iterator_has_morecxx . . $ oscap_string_iterator_has_more(3724f2faf2515a82).(metadata))
331 {
332 const char* meta = oscap_string_iterator_nextcxx . . $ oscap_string_iterator_next(1f2a9ae2534eef34).(metadata);
333 xmlNodecxx . . $ xmlNode# *m = oscap_xmlstr_to_domcxx . . $ oscap_xmlstr_to_dom(5514c3fae3f75267).(tailoring_node, "metadata", meta);
334 xmlSetNscxx . . $ xmlSetNs(cd680be8abdf9ad3).(m, ns_xccdf);
335 }
336 oscap_string_iterator_freecxx . . $ oscap_string_iterator_free(41a77e9ce361f406).(metadata);
337
338 struct xccdf_profile_iteratorcxx . . $ xccdf_profile_iterator# *profiles = xccdf_tailoring_get_profilescxx . . $ xccdf_tailoring_get_profiles(41ce0c0fc277fbfc).(tailoring);
339 while (xccdf_profile_iterator_has_morecxx . . $ xccdf_profile_iterator_has_more(adef36931cdf4bdd).(profiles)) {
340 struct xccdf_profilecxx . . $ xccdf_profile# *profile = xccdf_profile_iterator_nextcxx . . $ xccdf_profile_iterator_next(4851320650739603).(profiles);
341 xccdf_item_to_domcxx . . $ xccdf_item_to_dom(974faac3a53a529f).(XITEMcxx . . $ `src/XCCDF/helpers.h:35:9`!(profile), doc, tailoring_node, version_info);
342 }
343 xccdf_profile_iterator_freecxx . . $ xccdf_profile_iterator_free(e346a4b111941870).(profiles);
344
345 xmlSetNscxx . . $ xmlSetNs(cd680be8abdf9ad3).(tailoring_node, ns_tailoring);
346
347 return tailoring_node;
348 }
349
350 int xccdf_tailoring_exportcxx . . $ xccdf_tailoring_export(bbb87727e34e1339).(struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring, const char *file, const struct xccdf_version_infocxx . . $ xccdf_version_info# *version_info)
351 {
352 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(file);
353
354 LIBXML_TEST_VERSIONcxx . . $ `<external>/12558958530574576205/xmlversion.h:40:9`!;
355
356 xmlDocPtrcxx . . $ xmlDocPtr# doc = xmlNewDoccxx . . $ xmlNewDoc(6ad5ddcc52642397).(BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "1.0");
357 if (doc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
358 oscap_setxmlerrcxx . . $ `src/common/_error.h:36:9`!(xmlGetLastError());
359 return -1;
360 }
361
362 xccdf_tailoring_to_domcxx . . $ xccdf_tailoring_to_dom(31d45adc3aaec44).(tailoring, doc, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, version_info);
363
364 return oscap_xml_save_filename_freecxx . . $ oscap_xml_save_filename_free(4641885591a9fcee).(file, doc);
365 }
366
367 const char *xccdf_tailoring_get_idcxx . . $ xccdf_tailoring_get_id(8db670c91c6a1b30).(const struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring)
368 {
369 return tailoring->idcxx . . $ xccdf_tailoring#id.;
370 }
371
372 const char *xccdf_tailoring_get_versioncxx . . $ xccdf_tailoring_get_version(8db670c91c6a1b30).(const struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring)
373 {
374 return tailoring->versioncxx . . $ xccdf_tailoring#version.;
375 }
376
377 const char *xccdf_tailoring_get_version_updatecxx . . $ xccdf_tailoring_get_version_update(8db670c91c6a1b30).(const struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring)
378 {
379 return tailoring->version_updatecxx . . $ xccdf_tailoring#version_update.;
380 }
381
382 const char *xccdf_tailoring_get_version_timecxx . . $ xccdf_tailoring_get_version_time(8db670c91c6a1b30).(const struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring)
383 {
384 return tailoring->version_timecxx . . $ xccdf_tailoring#version_time.;
385 }
386
387 const char *xccdf_tailoring_get_benchmark_refcxx . . $ xccdf_tailoring_get_benchmark_ref(8db670c91c6a1b30).(const struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring)
388 {
389 return tailoring->benchmark_refcxx . . $ xccdf_tailoring#benchmark_ref.;
390 }
391
392 const char *xccdf_tailoring_get_benchmark_ref_versioncxx . . $ xccdf_tailoring_get_benchmark_ref_version(8db670c91c6a1b30).(const struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring)
393 {
394 return tailoring->benchmark_ref_versioncxx . . $ xccdf_tailoring#benchmark_ref_version.;
395 }
396
397 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_tailoring_set_idcxx . . $ xccdf_tailoring_set_id(c11c6205a3b142d5).(struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring, const char* newval)
398 {
399 if (tailoring->idcxx . . $ xccdf_tailoring#id.)
400 freecxx . . $ free(5d22bdacc48458e8).(tailoring->idcxx . . $ xccdf_tailoring#id.);
401
402 tailoring->idcxx . . $ xccdf_tailoring#id. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(newval);
403 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
404 }
405
406 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_tailoring_set_versioncxx . . $ xccdf_tailoring_set_version(c11c6205a3b142d5).(struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring, const char *newval)
407 {
408 if (tailoring->versioncxx . . $ xccdf_tailoring#version.)
409 freecxx . . $ free(5d22bdacc48458e8).(tailoring->versioncxx . . $ xccdf_tailoring#version.);
410
411 tailoring->versioncxx . . $ xccdf_tailoring#version. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(newval);
412 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
413 }
414
415 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_tailoring_set_version_updatecxx . . $ xccdf_tailoring_set_version_update(c11c6205a3b142d5).(struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring, const char *newval)
416 {
417 if (tailoring->version_updatecxx . . $ xccdf_tailoring#version_update.)
418 freecxx . . $ free(5d22bdacc48458e8).(tailoring->version_updatecxx . . $ xccdf_tailoring#version_update.);
419
420 tailoring->version_updatecxx . . $ xccdf_tailoring#version_update. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(newval);
421 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
422 }
423
424 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_tailoring_set_version_timecxx . . $ xccdf_tailoring_set_version_time(c11c6205a3b142d5).(struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring, const char *newval)
425 {
426 if (tailoring->version_timecxx . . $ xccdf_tailoring#version_time.)
427 freecxx . . $ free(5d22bdacc48458e8).(tailoring->version_timecxx . . $ xccdf_tailoring#version_time.);
428
429 tailoring->version_timecxx . . $ xccdf_tailoring#version_time. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(newval);
430 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
431 }
432
433 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_tailoring_set_benchmark_refcxx . . $ xccdf_tailoring_set_benchmark_ref(c11c6205a3b142d5).(struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring, const char *newval)
434 {
435 if (tailoring->benchmark_refcxx . . $ xccdf_tailoring#benchmark_ref.)
436 freecxx . . $ free(5d22bdacc48458e8).(tailoring->benchmark_refcxx . . $ xccdf_tailoring#benchmark_ref.);
437
438 tailoring->benchmark_refcxx . . $ xccdf_tailoring#benchmark_ref. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(newval);
439 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
440 }
441
442 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_tailoring_set_benchmark_ref_versioncxx . . $ xccdf_tailoring_set_benchmark_ref_version(c11c6205a3b142d5).(struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring, const char *newval)
443 {
444 if (tailoring->benchmark_ref_versioncxx . . $ xccdf_tailoring#benchmark_ref_version.)
445 freecxx . . $ free(5d22bdacc48458e8).(tailoring->benchmark_ref_versioncxx . . $ xccdf_tailoring#benchmark_ref_version.);
446
447 tailoring->benchmark_ref_versioncxx . . $ xccdf_tailoring#benchmark_ref_version. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(newval);
448 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
449 }
450
451 struct oscap_string_iteratorcxx . . $ oscap_string_iterator# *xccdf_tailoring_get_metadatacxx . . $ xccdf_tailoring_get_metadata(e4dafec89ab82417).(const struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring)
452 {
453 return (struct oscap_string_iteratorcxx . . $ oscap_string_iterator#*) oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).(tailoring->metadatacxx . . $ xccdf_tailoring#metadata.);
454 }
455
456 struct xccdf_profile_iteratorcxx . . $ xccdf_profile_iterator# *xccdf_tailoring_get_profilescxx . . $ xccdf_tailoring_get_profiles(41ce0c0fc277fbfc).(const struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring)
457 {
458 return (struct xccdf_profile_iteratorcxx . . $ xccdf_profile_iterator#*) oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).(tailoring->profilescxx . . $ xccdf_tailoring#profiles.);
459 }
460
461 struct xccdf_status_iteratorcxx . . $ xccdf_status_iterator# *xccdf_tailoring_get_statusescxx . . $ xccdf_tailoring_get_statuses(2e50d5a66302f077).(const struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring)
462 {
463 return (struct xccdf_status_iteratorcxx . . $ xccdf_status_iterator#*) oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).(tailoring->statusescxx . . $ xccdf_tailoring#statuses.);
464 }
465
466 struct oscap_reference_iteratorcxx . . $ oscap_reference_iterator# *xccdf_tailoring_get_dc_statusescxx . . $ xccdf_tailoring_get_dc_statuses(db58623d3dff8a6c).(const struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring)
467 {
468 return (struct oscap_reference_iteratorcxx . . $ oscap_reference_iterator#*) oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).(tailoring->dc_statusescxx . . $ xccdf_tailoring#dc_statuses.);
469 }
470
471 struct xccdf_profilecxx . . $ xccdf_profile# *
472 xccdf_tailoring_get_profile_by_idcxx . . $ xccdf_tailoring_get_profile_by_id(a3cce76bafe7a7e1).(const struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring, const char *profile_id)
473 {
474 struct xccdf_profile_iteratorcxx . . $ xccdf_profile_iterator# *profit = xccdf_tailoring_get_profilescxx . . $ xccdf_tailoring_get_profiles(41ce0c0fc277fbfc).(tailoring);
475 while (xccdf_profile_iterator_has_morecxx . . $ xccdf_profile_iterator_has_more(adef36931cdf4bdd).(profit)) {
476 struct xccdf_profilecxx . . $ xccdf_profile# *profile = xccdf_profile_iterator_nextcxx . . $ xccdf_profile_iterator_next(4851320650739603).(profit);
477 if (profile == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
478 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(profile != NULL);
479 continue;
480 }
481 if (oscap_streqcxx . . $ oscap_streq(b7a7aa4a824b7595).(xccdf_profile_get_idcxx . . $ xccdf_profile_get_id(d143a4aa05fc37ce).(profile), profile_id)) {
482 xccdf_profile_iterator_freecxx . . $ xccdf_profile_iterator_free(e346a4b111941870).(profit);
483 return profile;
484 }
485 }
486 xccdf_profile_iterator_freecxx . . $ xccdf_profile_iterator_free(e346a4b111941870).(profit);
487 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
488 }