Debian Codegraph @

src/XCCDF_POLICY/xccdf_policy.c

raw symbols SCIP
1 /*
2 * xccdf_policy.c
3 *
4 * Copyright 2009--2014 Red Hat Inc., Durham, North Carolina.
5 * All Rights Reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 *
21 * Created on: Dec 16, 2009
22 * Author: David Niemoller
23 * Maros Barabas <[email protected]>
24 */
25
26 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
27 #include <config.h>cxx . . $ `<file>/build/config.h`/
28 #endif
29
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <string.h>
33
34 #include "xccdf_policy_priv.h"cxx . . $ `<file>/src/XCCDF_POLICY/xccdf_policy_priv.h`/
35 #include "xccdf_policy_model_priv.h"cxx . . $ `<file>/src/XCCDF_POLICY/xccdf_policy_model_priv.h`/
36 #include "xccdf_policy_engine_priv.h"cxx . . $ `<file>/src/XCCDF_POLICY/xccdf_policy_engine_priv.h`/
37 #include "reporter_priv.h"cxx . . $ `<file>/src/XCCDF_POLICY/reporter_priv.h`/
38 #include "public/xccdf_policy.h"cxx . . $ `<file>/src/XCCDF_POLICY/public/xccdf_policy.h`/
39 #include "public/xccdf_session.h"cxx . . $ `<file>/src/XCCDF/public/xccdf_session.h`/
40 #include "public/xccdf_benchmark.h"cxx . . $ `<file>/src/XCCDF/public/xccdf_benchmark.h`/
41 #include "public/oscap_text.h"cxx . . $ `<file>/src/common/public/oscap_text.h`/
42
43 #include "CPE/cpelang_priv.h"cxx . . $ `<file>/src/CPE/cpelang_priv.h`/
44 #include "CPE/cpe_session_priv.h"cxx . . $ `<file>/src/CPE/cpe_session_priv.h`/
45 #include "CPE/cpedict_priv.h"cxx . . $ `<file>/src/CPE/cpedict_priv.h`/
46
47 #include "oscap_source.h"cxx . . $ `<file>/src/source/public/oscap_source.h`/
48 #include "oval_agent_api.h"cxx . . $ `<file>/src/OVAL/public/oval_agent_api.h`/
49
50 #include "item.h"cxx . . $ `<file>/src/XCCDF/item.h`/
51 #include "helpers.h"cxx . . $ `<file>/src/XCCDF/helpers.h`/
52 #include "common/list.h"cxx . . $ `<file>/src/common/list.h`/
53 #include "common/_error.h"cxx . . $ `<file>/src/common/_error.h`/
54 #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/
55 #include "common/text_priv.h"cxx . . $ `<file>/src/common/text_priv.h`/
56 #include "XCCDF/result_scoring_priv.h"cxx . . $ `<file>/src/XCCDF/result_scoring_priv.h`/
57 #include "xccdf_policy_resolve.h"cxx . . $ `<file>/src/XCCDF_POLICY/xccdf_policy_resolve.h`/
58 #include "oscap_helpers.h"cxx . . $ `<file>/src/common/public/oscap_helpers.h`/
59
60 /* Macros to generate iterators, getters and setters */
61 OSCAP_GETTERcxx . . $ `src/common/util.h:111:9`!(struct xccdf_benchmark *, xccdf_policy_model, benchmark)
62 OSCAP_IGETINS_GENcxx . . $ `src/common/util.h:286:9`!(xccdf_policy, xccdf_policy_model, policies, policy)
63
64 /* Macros to generate iterators, getters and setters */
65 OSCAP_GETTERcxx . . $ `src/common/util.h:111:9`!(struct xccdf_policy_model *, xccdf_policy, model)
66 OSCAP_GETTERcxx . . $ `src/common/util.h:111:9`!(struct xccdf_profile *, xccdf_policy, profile)
67 OSCAP_IGETTERcxx . . $ `src/common/util.h:152:9`!(xccdf_select, xccdf_policy, selects)
68 OSCAP_IGETINS_GENcxx . . $ `src/common/util.h:286:9`!(xccdf_value_binding, xccdf_policy, values, value)
69 OSCAP_IGETINScxx . . $ `src/common/util.h:283:9`!(xccdf_result, xccdf_policy, results, result)
70
71 /**
72 * XCCDF value binding structure is binding between Refine values, Set values,
73 * Value element and Check export element of benchmark. These structures are
74 * binded together for exporting values to checking engine.
75 *
76 * These bindings are set during the preprocessing of profile, when policies
77 * are beeing created.
78 */
79 struct xccdf_value_bindingcxx . . $ xccdf_value_binding# {
80
81 char * namecxx . . $ xccdf_value_binding#name.; ///< The name of OVAL Variable
82 xccdf_value_type_tcxx . . $ xccdf_value_type_t# typecxx . . $ xccdf_value_binding#type.; ///< Type of Variable
83 char * valuecxx . . $ xccdf_value_binding#value.; ///< Value of variable
84 char * setvaluecxx . . $ xccdf_value_binding#setvalue.; ///< Set value if defined or NULL
85 xccdf_operator_tcxx . . $ xccdf_operator_t# operatorcxx . . $ xccdf_value_binding#operator.; ///< Operator of Value
86 };
87 /* Macros to generate iterators, getters and setters */
88 OSCAP_GETTERcxx . . $ `src/common/util.h:111:9`!(xccdf_value_type_t, xccdf_value_binding, type)
89 OSCAP_GETTERcxx . . $ `src/common/util.h:111:9`!(char *, xccdf_value_binding, name)
90 OSCAP_GETTERcxx . . $ `src/common/util.h:111:9`!(char *, xccdf_value_binding, value)
91 OSCAP_GETTERcxx . . $ `src/common/util.h:111:9`!(char *, xccdf_value_binding, setvalue)
92 OSCAP_GETTERcxx . . $ `src/common/util.h:111:9`!(xccdf_operator_t, xccdf_value_binding, operator)
93
94 /*==========================================================================*/
95 /* Declaration of static (private to this file) functions
96 * These function shoud not be called from outside. For exporting these
97 * elements has to call parent element's
98 */
99
100 /**
101 * Filter function returning true if the item is selected, false otherwise
102 */
103 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_filter_selectedcxx . . $ xccdf_policy_filter_selected(838b4d1787e4a177).(void *item, void *policy)
104 {
105 struct xccdf_benchmarkcxx . . $ xccdf_benchmark# * benchmark
106 = xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(xccdf_policy_get_modelcxx . . $ xccdf_policy_get_model(f98af4da2524e136).((struct xccdf_policycxx . . $ xccdf_policy# *) policy));
107
108 struct xccdf_itemcxx . . $ xccdf_item# * titem = xccdf_benchmark_get_itemcxx . . $ xccdf_benchmark_get_item(daeed5940f8c8cf2).(benchmark, xccdf_select_get_itemcxx . . $ xccdf_select_get_item(5bca08d84ffaa667).((struct xccdf_selectcxx . . $ xccdf_select# *) item));
109 if (titem == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
110 dEcxx . . $ `src/common/debug_priv.h:63:9`!("Item \"%s\" does not exist. Remove it from Profile !", xccdf_select_get_item((struct xccdf_select *) item));
111 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
112 }
113 return ((xccdf_item_get_typecxx . . $ xccdf_item_get_type(3d8d48c673cd637b).(titem) == XCCDF_RULEcxx . . $ XCCDF_RULE.) &&
114 (xccdf_select_get_selectedcxx . . $ xccdf_select_get_selected(2449d720cc2660cc).((struct xccdf_selectcxx . . $ xccdf_select# *) item)));
115 }
116
117 /**
118 * Get callbacks that match sysname. Call this function to get iterator over list of callbacks
119 * that have the same system name
120 */
121 static struct oscap_iteratorcxx . . $ oscap_iterator# *
122 _xccdf_policy_get_callbacks_by_sysnamecxx . . $ _xccdf_policy_get_callbacks_by_sysname(401d8bb070a80905).(struct xccdf_policycxx . . $ xccdf_policy# * policy, const char * sysname)
123 {
124 return oscap_iterator_new_filtercxx . . $ oscap_iterator_new_filter(412a5e5f37b98023).( policy->modelcxx . . $ xccdf_policy#model.->callbackscxx . . $ xccdf_policy_model#callbacks., (oscap_filter_funccxx . . $ oscap_filter_func#) xccdf_policy_engine_filtercxx . . $ xccdf_policy_engine_filter(90adb2dfb41d6248)., (void *) sysname);
125 }
126
127 /**
128 * Get the checking engines that match the sysname.
129 */
130 static struct oscap_iteratorcxx . . $ oscap_iterator# *_xccdf_policy_get_engines_by_sysnamecxx . . $ _xccdf_policy_get_engines_by_sysname(401d8bb070a80905).(struct xccdf_policycxx . . $ xccdf_policy# *policy, const char *sysname)
131 {
132 return oscap_iterator_new_filtercxx . . $ oscap_iterator_new_filter(412a5e5f37b98023).(policy->modelcxx . . $ xccdf_policy#model.->enginescxx . . $ xccdf_policy_model#engines., (oscap_filter_funccxx . . $ oscap_filter_func#) xccdf_policy_engine_filtercxx . . $ xccdf_policy_engine_filter(90adb2dfb41d6248)., (void *) sysname);
133 }
134
135 static char *_xccdf_policy_get_readable_item_textcxx . . $ _xccdf_policy_get_readable_item_text(af6df71d673e13c9).(struct xccdf_policycxx . . $ xccdf_policy# *policy, struct xccdf_itemcxx . . $ xccdf_item# *item, const char *preferred_lang, struct oscap_text_iteratorcxx . . $ oscap_text_iterator# *it)
136 {
137 struct oscap_textcxx . . $ oscap_text# *unresolved_text = oscap_textlist_get_preferred_textcxx . . $ oscap_textlist_get_preferred_text(92eab71fd95a04a7).(it, preferred_lang);
138 if (!unresolved_text)
139 return oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).("");
140 const char *unresolved = oscap_text_get_textcxx . . $ oscap_text_get_text(ba0993cb6b641422).(unresolved_text);
141 /* Resolve <xccdf:sub> elements */
142 char *resolved = xccdf_policy_substitutecxx . . $ xccdf_policy_substitute(9b374264f47ad06a).(unresolved, policy);
143 /* Get rid of xhtml elements */
144 char *plaintext = _xhtml_to_plaintextcxx . . $ _xhtml_to_plaintext(a8b8e32347182212).(resolved);
145 freecxx . . $ free(5d22bdacc48458e8).(resolved);
146 char *filtered_plaintext = oscap_remove_excess_whitespacecxx . . $ oscap_remove_excess_whitespace(a8b8e32347182212).(plaintext);
147 freecxx . . $ free(5d22bdacc48458e8).(plaintext);
148 return filtered_plaintext;
149 }
150
151 char *xccdf_policy_get_readable_item_titlecxx . . $ xccdf_policy_get_readable_item_title(5539ec35e28150ee).(struct xccdf_policycxx . . $ xccdf_policy# *policy, struct xccdf_itemcxx . . $ xccdf_item# *item, const char *preferred_lang)
152 {
153 struct oscap_text_iteratorcxx . . $ oscap_text_iterator# *title_it = xccdf_item_get_titlecxx . . $ xccdf_item_get_title(6f56deec8ca52984).(item);
154 char *readable_text = _xccdf_policy_get_readable_item_textcxx . . $ _xccdf_policy_get_readable_item_text(af6df71d673e13c9).(policy, item, preferred_lang, title_it);
155 oscap_text_iterator_freecxx . . $ oscap_text_iterator_free(f60c6cfdbf1f29d7).(title_it);
156 return readable_text;
157 }
158
159 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_get_show_rule_detailscxx . . $ xccdf_policy_get_show_rule_details(11f15227c042e923).(struct xccdf_policycxx . . $ xccdf_policy# *policy)
160 {
161 if (policy == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
162 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
163 return policy->show_rule_detailscxx . . $ xccdf_policy#show_rule_details.;
164 }
165
166 char *xccdf_policy_get_readable_item_descriptioncxx . . $ xccdf_policy_get_readable_item_description(5539ec35e28150ee).(struct xccdf_policycxx . . $ xccdf_policy# *policy, struct xccdf_itemcxx . . $ xccdf_item# *item, const char *preferred_lang)
167 {
168 /* Get description in preferred language */
169 struct oscap_text_iteratorcxx . . $ oscap_text_iterator# *description_it = xccdf_item_get_descriptioncxx . . $ xccdf_item_get_description(6f56deec8ca52984).(item);
170 char *readable_text = _xccdf_policy_get_readable_item_textcxx . . $ _xccdf_policy_get_readable_item_text(af6df71d673e13c9).(policy, item, preferred_lang, description_it);
171 oscap_text_iterator_freecxx . . $ oscap_text_iterator_free(f60c6cfdbf1f29d7).(description_it);
172 return readable_text;
173 }
174
175 char *xccdf_policy_get_readable_item_rationalecxx . . $ xccdf_policy_get_readable_item_rationale(5539ec35e28150ee).(struct xccdf_policycxx . . $ xccdf_policy# *policy, struct xccdf_itemcxx . . $ xccdf_item# *item, const char *preferred_lang)
176 {
177 /* Get rationale in preferred language */
178 struct oscap_text_iteratorcxx . . $ oscap_text_iterator# *rat_it = xccdf_item_get_rationalecxx . . $ xccdf_item_get_rationale(6f56deec8ca52984).(item);
179 char *readable_text = _xccdf_policy_get_readable_item_textcxx . . $ _xccdf_policy_get_readable_item_text(af6df71d673e13c9).(policy, item, preferred_lang, rat_it);
180 oscap_text_iterator_freecxx . . $ oscap_text_iterator_free(f60c6cfdbf1f29d7).(rat_it);
181 return readable_text;
182 }
183
184 /**
185 * Get last setvalue from policy that match specified id
186 */
187 static struct xccdf_setvaluecxx . . $ xccdf_setvalue# * xccdf_policy_get_setvaluecxx . . $ xccdf_policy_get_setvalue(9aa79497ff8ede6f).(struct xccdf_policycxx . . $ xccdf_policy# * policy, const char * id)
188 {
189 /* return NULL if id or policy is NULL but don't use
190 * __attribute_not_null__ here, it will cause abort
191 * which is not desired
192 */
193 if (id == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
194 if (policy == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
195
196 struct xccdf_setvalue_iteratorcxx . . $ xccdf_setvalue_iterator# * s_value_it;
197 struct xccdf_setvaluecxx . . $ xccdf_setvalue# * s_value;
198 struct xccdf_profilecxx . . $ xccdf_profile# * profile = xccdf_policy_get_profilecxx . . $ xccdf_policy_get_profile(f562c39304763510).(policy);;
199
200 /* If profile is NULL we don't have setvalue's
201 * and we return NULL, otherwise we could cause SIGSEG
202 * with accessing NULL structure
203 */
204 if (profile == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
205
206 /* We need to return *LAST* setvalue in Profile.
207 * and iterate to the end of setvalue list
208 */
209 struct xccdf_setvaluecxx . . $ xccdf_setvalue# * final = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
210 s_value_it = xccdf_profile_get_setvaluescxx . . $ xccdf_profile_get_setvalues(2858520f7d7fac8c).(profile);
211 while (xccdf_setvalue_iterator_has_morecxx . . $ xccdf_setvalue_iterator_has_more(3ec70e5e2abc17db).(s_value_it)) {
212 s_value = xccdf_setvalue_iterator_nextcxx . . $ xccdf_setvalue_iterator_next(753fc4cd25f5e085).(s_value_it);
213 if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(id, xccdf_setvalue_get_itemcxx . . $ xccdf_setvalue_get_item(b6c7ccbe9a2081b7).(s_value))) {
214 final = s_value;
215 }
216 }
217 xccdf_setvalue_iterator_freecxx . . $ xccdf_setvalue_iterator_free(88ac5f99059bb7a3).(s_value_it);
218
219 return final;
220 }
221
222 static struct xccdf_refine_valuecxx . . $ xccdf_refine_value# * xccdf_policy_get_refine_valuecxx . . $ xccdf_policy_get_refine_value(1c8b16f491002dde).(struct xccdf_policycxx . . $ xccdf_policy# * policy, const char * id)
223 {
224 /* return NULL if id or policy is NULL but don't use
225 * __attribute_not_null__ here, it will cause abort
226 * which is not desired
227 */
228 if (id == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
229 if (policy == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
230
231 struct xccdf_refine_value_iteratorcxx . . $ xccdf_refine_value_iterator# * r_value_it;
232 struct xccdf_refine_valuecxx . . $ xccdf_refine_value# * r_value;
233 struct xccdf_profilecxx . . $ xccdf_profile# * profile = xccdf_policy_get_profilecxx . . $ xccdf_policy_get_profile(f562c39304763510).(policy);;
234
235 /* If profile is NULL we don't have setvalue's
236 * and we return NULL, otherwise we could cause SIGSEG
237 * with accessing NULL structure
238 */
239 if (profile == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
240
241 /* We need to return *LAST* setvalue in Profile.
242 * and iterate to the end of setvalue list
243 */
244 struct xccdf_refine_valuecxx . . $ xccdf_refine_value# * final = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
245 r_value_it = xccdf_profile_get_refine_valuescxx . . $ xccdf_profile_get_refine_values(d46be7e16f877ffa).(profile);
246 while (xccdf_refine_value_iterator_has_morecxx . . $ xccdf_refine_value_iterator_has_more(7ad4a4ce170291e7).(r_value_it)) {
247 r_value = xccdf_refine_value_iterator_nextcxx . . $ xccdf_refine_value_iterator_next(7670134309efdbc5).(r_value_it);
248 if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(id, xccdf_refine_value_get_itemcxx . . $ xccdf_refine_value_get_item(99f8a21d78864a7b).(r_value))) {
249 final = r_value;
250 }
251 }
252 xccdf_refine_value_iterator_freecxx . . $ xccdf_refine_value_iterator_free(699a53bbf99fc3b2).(r_value_it);
253
254 return final;
255 }
256
257 /**
258 * Function resolves two operations:
259 * P - PASS
260 * F - FAIL
261 * U - UNKNOWN
262 * E - ERROR
263 * N - NOT CHECKED, NOT SELECTED, NOT APPLICABLE
264 *
265 * ***************************************************************
266 * AND P F U E N OR P F U E N P F U E N *
267 * P P F U E P P P P P P P neg F P U E N *
268 * F F F F F F F P F U E F *
269 * U U F U U U U P U U U U *
270 * E E F U E E E P E U E E *
271 * N P F U E N N P F U E N *
272 * ***************************************************************
273 *
274 */
275
276 static xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# _resolve_operationcxx . . $ _resolve_operation(2720499277c7fe05).(int A, int B, xccdf_bool_operator_tcxx . . $ xccdf_bool_operator_t# oper)
277 {
278
279 xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# value = 0;
280
281 static const xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# RESULT_TABLE_AND[9][9] = {
282 /* P F E U N K S I */
283 {0, 0, 0, 0, 0, 0, 0, 0, 0},
284 {0, 1, 2, 3, 4, 1, 1, 1, 1}, /* P (pass)*/
285 {0, 2, 2, 2, 2, 2, 2, 2, 2}, /* F (fail) */
286 {0, 4, 2, 4, 4, 4, 4, 4, 4}, /* E (error) */
287 {0, 3, 2, 3, 4, 3, 3, 3, 3}, /* U (unknown) */
288 {0, 1, 2, 3, 4, 5, 5, 5, 5}, /* N (notapplicable) */
289 {0, 1, 2, 3, 4, 5, 6, 6, 6}, /* K (notchecked) */
290 {0, 1, 2, 3, 4, 5, 6, 7, 7}, /* S (notselected) */
291 {0, 1, 2, 3, 4, 5, 6, 7, 8}};/* I (informational) */
292
293 static const xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# RESULT_TABLE_OR[9][9] = {
294 /* P F E U N K S I */
295 {0, 0, 0, 0, 0, 0, 0, 0, 0},
296 {0, 1, 1, 1, 1, 1, 1, 1, 1}, /* P (pass)*/
297 {0, 1, 2, 3, 4, 2, 2, 2, 2}, /* F (fail) */
298 {0, 1, 4, 4, 4, 4, 4, 4, 4}, /* E (error) */
299 {0, 1, 3, 3, 4, 3, 3, 3, 3}, /* U (unknown) */
300 {0, 1, 2, 3, 4, 5, 5, 5, 5}, /* N (notapplicable) */
301 {0, 1, 2, 3, 4, 5, 6, 6, 6}, /* K (notchecked) */
302 {0, 1, 2, 3, 4, 5, 6, 7, 7}, /* S (notselected) */
303 {0, 1, 2, 3, 4, 5, 6, 7, 8}};/* I (informational) */
304
305 /* No test result can end with 0
306 */
307 if ((A == 0) || (B == 0)
308 || A > XCCDF_RESULT_INFORMATIONALcxx . . $ XCCDF_RESULT_INFORMATIONAL. || B > XCCDF_RESULT_INFORMATIONALcxx . . $ XCCDF_RESULT_INFORMATIONAL.) {
309 dEcxx . . $ `src/common/debug_priv.h:63:9`!("Bad test results %d, %d.", A, B);
310 return 0;
311 }
312
313 switch (oper) {
314 case XCCDF_OPERATOR_ANDcxx . . $ XCCDF_OPERATOR_AND.: /* AND */
315 value = (xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t#) RESULT_TABLE_AND[A][B];
316 break;
317
318 case XCCDF_OPERATOR_ORcxx . . $ XCCDF_OPERATOR_OR.: /* OR */
319 value = (xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t#) RESULT_TABLE_OR[A][B];
320 break;
321 default:
322 dEcxx . . $ `src/common/debug_priv.h:63:9`!("Operation not supported.");
323 return 0;
324 break;
325 }
326
327 return value;
328 }
329
330 xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# xccdf_test_result_resolve_and_operationcxx . . $ xccdf_test_result_resolve_and_operation(ca0046ed1809d38d).(xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# A, xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# B)
331 {
332 return _resolve_operationcxx . . $ _resolve_operation(2720499277c7fe05).((int)A, (int)B, XCCDF_OPERATOR_ANDcxx . . $ XCCDF_OPERATOR_AND.);
333 }
334
335 /**
336 * Handle the negation="true" paramter of xccdf:complex-check.
337 * Shall be run only once per a complex-check.
338 */
339 static xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# _resolve_negatecxx . . $ _resolve_negate(7c309ab4c6b863af).(xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# value, const struct xccdf_checkcxx . . $ xccdf_check# *check)
340 {
341 if (xccdf_check_get_negatecxx . . $ xccdf_check_get_negate(ceaafcd79241aa30).(check)) {
342 if (value == XCCDF_RESULT_PASScxx . . $ XCCDF_RESULT_PASS.) return XCCDF_RESULT_FAILcxx . . $ XCCDF_RESULT_FAIL.;
343 else if (value == XCCDF_RESULT_FAILcxx . . $ XCCDF_RESULT_FAIL.) return XCCDF_RESULT_PASScxx . . $ XCCDF_RESULT_PASS.;
344 }
345 return value;
346 }
347
348
349 static void _xccdf_policy_modify_selected_finalcxx . . $ _xccdf_policy_modify_selected_final(9f127fec5573ef3b).(struct xccdf_policycxx . . $ xccdf_policy# *policy, const char *id, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! selected)
350 {
351 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! TRUE0 = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
352 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! FALSE0 = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
353 oscap_htable_detachcxx . . $ oscap_htable_detach(f5c7e8ff6c970cd3).(policy->selected_finalcxx . . $ xccdf_policy#selected_final., id);
354 oscap_htable_addcxx . . $ oscap_htable_add(d9abe78f59fa00eb).(policy->selected_finalcxx . . $ xccdf_policy#selected_final., id, selected ? &TRUE0 : &FALSE0);
355 }
356
357 /**
358 * Resolve the xccdf item. Parameter selected indicates parents selection attribute
359 * It is used to decide the final selection attribute of item
360 *
361 * If parent's group of rule item has attribute selected = FALSE, It should not be processed, neither
362 * its children. This selected attribute is iterativly passed to each child of group to set their selected
363 * attribute to false no matter of profile setting.
364 */
365 static void xccdf_policy_resolve_itemcxx . . $ xccdf_policy_resolve_item(a82616d50c5910f3).(struct xccdf_policycxx . . $ xccdf_policy# * policy, struct xccdf_itemcxx . . $ xccdf_item# * item, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! selected)
366 {
367 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(policy);
368 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(item);
369
370 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! result;
371 const char *id = xccdf_item_get_idcxx . . $ xccdf_item_get_id(b87246382a73d514).(item);
372 if (!selected)
373 result = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
374 else {
375 struct xccdf_selectcxx . . $ xccdf_select# *sel = xccdf_policy_get_select_by_idcxx . . $ xccdf_policy_get_select_by_id(16ffa0f3d08abac0).(policy, id);
376 result = (sel != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) ? xccdf_select_get_selectedcxx . . $ xccdf_select_get_selected(2449d720cc2660cc).(sel) : xccdf_item_get_selectedcxx . . $ xccdf_item_get_selected(5f71c692d176a119).(item);
377 }
378
379 if (xccdf_item_get_typecxx . . $ xccdf_item_get_type(3d8d48c673cd637b).(item) == XCCDF_GROUPcxx . . $ XCCDF_GROUP.) {
380 struct xccdf_item_iteratorcxx . . $ xccdf_item_iterator# *child_it = xccdf_group_get_contentcxx . . $ xccdf_group_get_content(cff1b1d0a9b9d63).((const struct xccdf_groupcxx . . $ xccdf_group# *)item);
381 while (xccdf_item_iterator_has_morecxx . . $ xccdf_item_iterator_has_more(c8a83ac60f16d388).(child_it))
382 xccdf_policy_resolve_itemcxx . . $ xccdf_policy_resolve_item(a82616d50c5910f3).(policy, xccdf_item_iterator_nextcxx . . $ xccdf_item_iterator_next(73e3c3f4fb48321d).(child_it), selected);
383 xccdf_item_iterator_freecxx . . $ xccdf_item_iterator_free(5a27e088a1e93c63).(child_it);
384 }
385 _xccdf_policy_modify_selected_finalcxx . . $ _xccdf_policy_modify_selected_final(9f127fec5573ef3b).(policy, id, result);
386 }
387
388 /**
389 * Evaluate the policy check with given checking system
390 */
391 static int
392 xccdf_policy_evaluate_cbcxx . . $ xccdf_policy_evaluate_cb(bd565cfc0d03a14c).(struct xccdf_policycxx . . $ xccdf_policy# * policy, const char * sysname, const char * content, const char * href,
393 struct oscap_listcxx . . $ oscap_list# * bindings, struct xccdf_check_import_iteratorcxx . . $ xccdf_check_import_iterator# * check_import_it)
394 {
395 xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# retval = XCCDF_RESULT_NOT_CHECKEDcxx . . $ XCCDF_RESULT_NOT_CHECKED.;
396 struct oscap_iteratorcxx . . $ oscap_iterator# * cb_it = _xccdf_policy_get_engines_by_sysnamecxx . . $ _xccdf_policy_get_engines_by_sysname(401d8bb070a80905).(policy, sysname);
397 while (oscap_iterator_has_morecxx . . $ oscap_iterator_has_more(63b1de9a5adb9205).(cb_it)) {
398 struct xccdf_policy_enginecxx . . $ xccdf_policy_engine# *engine = (struct xccdf_policy_enginecxx . . $ xccdf_policy_engine# *) oscap_iterator_nextcxx . . $ oscap_iterator_next(4c75051c806960eb).(cb_it);
399 retval = xccdf_policy_engine_evalcxx . . $ xccdf_policy_engine_eval(a4ba672079ed066f).(engine, policy, content, href, bindings, check_import_it);
400 if (retval != XCCDF_RESULT_NOT_CHECKEDcxx . . $ XCCDF_RESULT_NOT_CHECKED.) break;
401 }
402 oscap_iterator_freecxx . . $ oscap_iterator_free(3cba44c1b7872358).(cb_it);
403
404 return retval;
405 }
406
407 /**
408 * Find all possible names for given check-content-ref/@href, considering also the check/@system.
409 * This is useful for multi-check="true" feature.
410 * @return list of OVAL definitions if the given href found, NULL otherwise.
411 */
412 static struct oscap_listcxx . . $ oscap_list# *_xccdf_policy_get_oval_definitions_for_hrefcxx . . $ _xccdf_policy_get_oval_definitions_for_href(1a006988d006f978).(struct xccdf_policycxx . . $ xccdf_policy# *policy, const char *sysname, const char *href)
413 {
414 struct oscap_iteratorcxx . . $ oscap_iterator# *cb_it = _xccdf_policy_get_engines_by_sysnamecxx . . $ _xccdf_policy_get_engines_by_sysname(401d8bb070a80905).(policy, sysname);
415 struct oscap_listcxx . . $ oscap_list# *result = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
416 while (oscap_iterator_has_morecxx . . $ oscap_iterator_has_more(63b1de9a5adb9205).(cb_it) && result == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
417 struct xccdf_policy_enginecxx . . $ xccdf_policy_engine# *engine = (struct xccdf_policy_enginecxx . . $ xccdf_policy_engine# *) oscap_iterator_nextcxx . . $ oscap_iterator_next(4c75051c806960eb).(cb_it);
418 if (engine == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
419 break;
420 result = xccdf_policy_engine_querycxx . . $ xccdf_policy_engine_query(657864ad0a42fc34).(engine, POLICY_ENGINE_QUERY_OVAL_DEFS_FOR_HREFcxx . . $ POLICY_ENGINE_QUERY_OVAL_DEFS_FOR_HREF., (void *) href);
421 }
422 oscap_iterator_freecxx . . $ oscap_iterator_free(3cba44c1b7872358).(cb_it);
423 return result;
424 }
425
426 int xccdf_policy_report_cbcxx . . $ xccdf_policy_report_cb(2b8150694cbb4259).(struct xccdf_policycxx . . $ xccdf_policy# *policy, const char *sysname, void *rule)
427 {
428 int retval = 0;
429 struct oscap_iteratorcxx . . $ oscap_iterator# * cb_it = _xccdf_policy_get_callbacks_by_sysnamecxx . . $ _xccdf_policy_get_callbacks_by_sysname(401d8bb070a80905).(policy, sysname);
430 while (oscap_iterator_has_morecxx . . $ oscap_iterator_has_more(63b1de9a5adb9205).(cb_it)) {
431 struct reportercxx . . $ reporter# *cb = (struct reportercxx . . $ reporter# *) oscap_iterator_nextcxx . . $ oscap_iterator_next(4c75051c806960eb).(cb_it);
432
433 retval = reporter_send_simplecxx . . $ reporter_send_simple(f04c68df167aa33).(cb, rule);
434
435 /* We still want to stop evaluation if user cancel it
436 * TODO: We should have a way to stop evaluation of current item
437 */
438 if (retval != 0) break;
439 }
440 oscap_iterator_freecxx . . $ oscap_iterator_free(3cba44c1b7872358).(cb_it);
441
442 return retval;
443 }
444
445 static struct oscap_listcxx . . $ oscap_list# * xccdf_policy_check_get_value_bindingscxx . . $ xccdf_policy_check_get_value_bindings(1de90ce7c9c1886f).(struct xccdf_policycxx . . $ xccdf_policy# * policy, struct xccdf_check_export_iteratorcxx . . $ xccdf_check_export_iterator# * check_it)
446 {
447 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(check_it);
448
449 struct xccdf_check_exportcxx . . $ xccdf_check_export# * check;
450 struct xccdf_valuecxx . . $ xccdf_value# * value;
451 struct xccdf_benchmarkcxx . . $ xccdf_benchmark# * benchmark;
452 struct xccdf_value_bindingcxx . . $ xccdf_value_binding# * binding;
453 struct xccdf_policy_modelcxx . . $ xccdf_policy_model# * model;
454 struct xccdf_refine_valuecxx . . $ xccdf_refine_value# * r_value;
455 struct xccdf_setvaluecxx . . $ xccdf_setvalue# * s_value;
456 struct oscap_listcxx . . $ oscap_list# * list = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).();
457
458 model = xccdf_policy_get_modelcxx . . $ xccdf_policy_get_model(f98af4da2524e136).(policy);
459 benchmark = xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(model);
460
461 while (xccdf_check_export_iterator_has_morecxx . . $ xccdf_check_export_iterator_has_more(3993d724912e25ff).(check_it)) {
462 check = xccdf_check_export_iterator_nextcxx . . $ xccdf_check_export_iterator_next(cf6310dcecaef747).(check_it);
463
464 value = (struct xccdf_valuecxx . . $ xccdf_value# *) xccdf_benchmark_get_itemcxx . . $ xccdf_benchmark_get_item(daeed5940f8c8cf2).(benchmark, xccdf_check_export_get_valuecxx . . $ xccdf_check_export_get_value(21fe2b8037eda464).(check));
465 if (value == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
466 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XCCDFcxx . . $ `src/common/public/oscap_error.h:62:9`!, "Value \"%s\" does not exist in benchmark", xccdf_check_export_get_value(check));
467 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(list, freecxx . . $ free(5d22bdacc48458e8).);
468 return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
469 }
470 binding = xccdf_value_binding_newcxx . . $ xccdf_value_binding_new(4ab1590557d95e6a).();
471
472 /* Apply related setvalue from policy profile */
473 s_value = xccdf_policy_get_setvaluecxx . . $ xccdf_policy_get_setvalue(9aa79497ff8ede6f).(policy, xccdf_value_get_idcxx . . $ xccdf_value_get_id(7dce63a6a4cb9377).(value));
474 if (s_value != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) binding->setvaluecxx . . $ xccdf_value_binding#setvalue. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).((char *) xccdf_setvalue_get_valuecxx . . $ xccdf_setvalue_get_value(b6c7ccbe9a2081b7).(s_value));
475
476 /* Apply related refine value from policy profile */
477 const char * selector = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
478 r_value = xccdf_policy_get_refine_valuecxx . . $ xccdf_policy_get_refine_value(1c8b16f491002dde).(policy, xccdf_value_get_idcxx . . $ xccdf_value_get_id(7dce63a6a4cb9377).(value));
479 if (r_value != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
480 selector = xccdf_refine_value_get_selectorcxx . . $ xccdf_refine_value_get_selector(99f8a21d78864a7b).(r_value);
481 /* This refine value changes the value content */
482 if ((int)xccdf_refine_value_get_opercxx . . $ xccdf_refine_value_get_oper(23c4baec40a0964d).(r_value) > 0) {
483 binding->operatorcxx . . $ xccdf_value_binding#operator. = xccdf_refine_value_get_opercxx . . $ xccdf_refine_value_get_oper(23c4baec40a0964d).(r_value);
484 } else binding->operatorcxx . . $ xccdf_value_binding#operator. = xccdf_value_get_opercxx . . $ xccdf_value_get_oper(1af997407da308aa).(value);
485
486 } else binding->operatorcxx . . $ xccdf_value_binding#operator. = xccdf_value_get_opercxx . . $ xccdf_value_get_oper(1af997407da308aa).(value);
487
488 const struct xccdf_value_instancecxx . . $ xccdf_value_instance# * val = xccdf_value_get_instance_by_selectorcxx . . $ xccdf_value_get_instance_by_selector(1c9d6811ccaf1af0).(value, selector);
489 if (val == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
490 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XCCDFcxx . . $ `src/common/public/oscap_error.h:62:9`!, "Attempt to get non-existent selector \"%s\" from variable \"%s\"", selector, xccdf_value_get_id(value));
491 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(list, freecxx . . $ free(5d22bdacc48458e8).);
492 xccdf_value_binding_freecxx . . $ xccdf_value_binding_free(97df0146bfa7ea12).(binding);
493 return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
494 }
495 binding->valuecxx . . $ xccdf_value_binding#value. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(xccdf_value_instance_get_valuecxx . . $ xccdf_value_instance_get_value(fa38e5a18b4e4656).(val));
496 binding->namecxx . . $ xccdf_value_binding#name. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).((char *) xccdf_check_export_get_namecxx . . $ xccdf_check_export_get_name(21fe2b8037eda464).(check));
497 binding->typecxx . . $ xccdf_value_binding#type. = xccdf_value_get_typecxx . . $ xccdf_value_get_type(241bbac253e8107a).(value);
498 oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(list, binding);
499 }
500 xccdf_check_export_iterator_freecxx . . $ xccdf_check_export_iterator_free(a13e44582cbfcb7f).(check_it);
501
502 return list;
503
504 }
505
506 int xccdf_policy_check_evaluatecxx . . $ xccdf_policy_check_evaluate(c0ca4ea0c149fbc3).(struct xccdf_policycxx . . $ xccdf_policy# * policy, struct xccdf_checkcxx . . $ xccdf_check# * check)
507 {
508 struct xccdf_check_iteratorcxx . . $ xccdf_check_iterator# * child_it;
509 struct xccdf_checkcxx . . $ xccdf_check# * child;
510 struct xccdf_check_content_ref_iteratorcxx . . $ xccdf_check_content_ref_iterator# * content_it;
511 struct xccdf_check_content_refcxx . . $ xccdf_check_content_ref# * content;
512 const char * content_name;
513 const char * system_name;
514 const char * href;
515 struct oscap_listcxx . . $ oscap_list# * bindings;
516 int ret = 0;
517 int ret2 = 0;
518
519 /* At least one of check-content or check-content-ref must
520 * appear in each check element. */
521 if (xccdf_check_get_complexcxx . . $ xccdf_check_get_complex(ceaafcd79241aa30).(check)) { /* we have complex subtree */
522 child_it = xccdf_check_get_childrencxx . . $ xccdf_check_get_children(7ed23a48483b6575).(check);
523 while (xccdf_check_iterator_has_morecxx . . $ xccdf_check_iterator_has_more(644a620a92cf84a7).(child_it)) {
524 child = xccdf_check_iterator_nextcxx . . $ xccdf_check_iterator_next(a435bf31c65e745a).(child_it);
525 ret2 = xccdf_policy_check_evaluatecxx . . $ xccdf_policy_check_evaluate(c0ca4ea0c149fbc3).(policy, child);
526 if (ret2 == -1) {
527 xccdf_check_iterator_freecxx . . $ xccdf_check_iterator_free(dcf67c9af31da2e3).(child_it);
528 return -1;
529 }
530 if (ret == 0) ret = ret2;
531 else {
532 ret = (int) _resolve_operationcxx . . $ _resolve_operation(2720499277c7fe05).((xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t#) ret, (xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t#) ret2, xccdf_check_get_opercxx . . $ xccdf_check_get_oper(757f69bbde85fc71).(check));
533 }
534 }
535 xccdf_check_iterator_freecxx . . $ xccdf_check_iterator_free(dcf67c9af31da2e3).(child_it);
536
537 } else { /* This is <check> element */
538 /* It depends on what operation we process - we do only Compliance Check */
539 content_it = xccdf_check_get_content_refscxx . . $ xccdf_check_get_content_refs(5eea252c33793573).(check);
540 system_name = xccdf_check_get_systemcxx . . $ xccdf_check_get_system(698a89d24cc1a492).(check);
541 bindings = xccdf_policy_check_get_value_bindingscxx . . $ xccdf_policy_check_get_value_bindings(1de90ce7c9c1886f).(policy, xccdf_check_get_exportscxx . . $ xccdf_check_get_exports(199e9cedf9301c64).(check));
542 if (bindings == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
543 xccdf_check_content_ref_iterator_freecxx . . $ xccdf_check_content_ref_iterator_free(30690f049257f900).(content_it);
544 return XCCDF_RESULT_UNKNOWNcxx . . $ XCCDF_RESULT_UNKNOWN.;
545 }
546 while (xccdf_check_content_ref_iterator_has_morecxx . . $ xccdf_check_content_ref_iterator_has_more(ad48050a2429bee3).(content_it)) {
547 content = xccdf_check_content_ref_iterator_nextcxx . . $ xccdf_check_content_ref_iterator_next(3e7476af5b698c93).(content_it);
548 content_name = xccdf_check_content_ref_get_namecxx . . $ xccdf_check_content_ref_get_name(18edaaea5423ca08).(content);
549 href = xccdf_check_content_ref_get_hrefcxx . . $ xccdf_check_content_ref_get_href(18edaaea5423ca08).(content);
550
551 struct xccdf_check_import_iteratorcxx . . $ xccdf_check_import_iterator# * check_import_it = xccdf_check_get_importscxx . . $ xccdf_check_get_imports(975feb899e9812f3).(check);
552 ret = xccdf_policy_evaluate_cbcxx . . $ xccdf_policy_evaluate_cb(bd565cfc0d03a14c).(policy, system_name, content_name, href, bindings, check_import_it);
553 // the evaluation has filled check imports at this point, we can simply free the iterator
554 xccdf_check_import_iterator_freecxx . . $ xccdf_check_import_iterator_free(2ae6b52ef2d5345b).(check_import_it);
555
556 // the content references are basically alternatives according to the specification
557 // we should go through them in the order they are defined and we are done as soon
558 // as we process one of them successfully
559 if ((xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t#) ret != XCCDF_RESULT_NOT_CHECKEDcxx . . $ XCCDF_RESULT_NOT_CHECKED.) {
560 xccdf_check_inject_content_refcxx . . $ xccdf_check_inject_content_ref(fa23abb48d445643).(check, content, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
561 break;
562 }
563 }
564 xccdf_check_content_ref_iterator_freecxx . . $ xccdf_check_content_ref_iterator_free(30690f049257f900).(content_it);
565 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(bindings, (oscap_destruct_funccxx . . $ oscap_destruct_func#) xccdf_value_binding_freecxx . . $ xccdf_value_binding_free(97df0146bfa7ea12).);
566 }
567 /* Negate only once */
568 ret = _resolve_negatecxx . . $ _resolve_negate(7c309ab4c6b863af).(ret, check);
569 return ret;
570 }
571
572 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!
573 _xccdf_policy_is_engine_registeredcxx . . $ _xccdf_policy_is_engine_registered(2afad2b1fd1abccf).(struct xccdf_policycxx . . $ xccdf_policy# *policy, char *sysname)
574 {
575 return oscap_list_containscxx . . $ oscap_list_contains(810ee1985baa5ebe).(policy->modelcxx . . $ xccdf_policy#model.->enginescxx . . $ xccdf_policy_model#engines., (void *) sysname, (oscap_cmp_funccxx . . $ oscap_cmp_func#) xccdf_policy_engine_filtercxx . . $ xccdf_policy_engine_filter(90adb2dfb41d6248).);
576 }
577
578 static struct xccdf_checkcxx . . $ xccdf_check# *
579 _xccdf_policy_rule_get_applicable_checkcxx . . $ _xccdf_policy_rule_get_applicable_check(354c20ade8add915).(struct xccdf_policycxx . . $ xccdf_policy# *policy, struct xccdf_itemcxx . . $ xccdf_item# *rule)
580 {
581 // Citations inline come from NISTIR-7275r4.
582 struct xccdf_checkcxx . . $ xccdf_check# *result = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
583 {
584 // If an <xccdf:Rule> contains an <xccdf:complex-check>, then the benchmark consumer MUST process
585 // it and MUST ignore any <xccdf:check> elements that are also contained by the <xccdf:Rule>.
586 struct xccdf_check_iteratorcxx . . $ xccdf_check_iterator# *check_it = xccdf_rule_get_complex_checkscxx . . $ xccdf_rule_get_complex_checks(b4fee8dce785ca5f).(rule);
587 if (xccdf_check_iterator_has_morecxx . . $ xccdf_check_iterator_has_more(644a620a92cf84a7).(check_it))
588 result = xccdf_check_iterator_nextcxx . . $ xccdf_check_iterator_next(a435bf31c65e745a).(check_it);
589 xccdf_check_iterator_freecxx . . $ xccdf_check_iterator_free(dcf67c9af31da2e3).(check_it);
590 }
591 if (result == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
592 // Check Processing Algorithm -- Check.Initialize
593 // Check Processing Algorithm -- Check.Selector
594 struct xccdf_refine_rule_internalcxx . . $ xccdf_refine_rule_internal# *r_rule = xccdf_policy_get_refine_rule_by_itemcxx . . $ xccdf_policy_get_refine_rule_by_item(ef73eac8f5004b34).(policy, rule);
595 char *selector = (r_rule == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) ? NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! : xccdf_refine_rule_internal_get_selectorcxx . . $ xccdf_refine_rule_internal_get_selector(d306425472ace387).(r_rule);
596 struct xccdf_check_iteratorcxx . . $ xccdf_check_iterator# *candidate_it = xccdf_rule_get_checks_filteredcxx . . $ xccdf_rule_get_checks_filtered(d809ddc538ffe32d).(rule, selector);
597 if (selector != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! && !xccdf_check_iterator_has_morecxx . . $ xccdf_check_iterator_has_more(644a620a92cf84a7).(candidate_it)) {
598 xccdf_check_iterator_freecxx . . $ xccdf_check_iterator_free(dcf67c9af31da2e3).(candidate_it);
599 // If the refined selector does not match, checks without selector shall be used.
600 candidate_it = xccdf_rule_get_checks_filteredcxx . . $ xccdf_rule_get_checks_filtered(d809ddc538ffe32d).(rule, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
601 }
602
603 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! print_general_warning = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
604 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! print_oval_warning = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
605 char *warning_check_system = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
606 // Check Processing Algorithm -- Check.System
607 while (xccdf_check_iterator_has_morecxx . . $ xccdf_check_iterator_has_more(644a620a92cf84a7).(candidate_it)) {
608 struct xccdf_checkcxx . . $ xccdf_check# *check = xccdf_check_iterator_nextcxx . . $ xccdf_check_iterator_next(a435bf31c65e745a).(candidate_it);
609 if (_xccdf_policy_is_engine_registeredcxx . . $ _xccdf_policy_is_engine_registered(2afad2b1fd1abccf).(policy, (char *) xccdf_check_get_systemcxx . . $ xccdf_check_get_system(698a89d24cc1a492).(check))) {
610 result = check;
611 char *preferred_engine = getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_PREFERRED_ENGINE");
612 if (preferred_engine) {
613 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCE", preferred_engine) && strcmpcxx . . $ strcmp(5ae29d726ae57f88).("OVAL", preferred_engine)) {
614 dWcxx . . $ `src/common/debug_priv.h:62:9`!("Unknown value of OSCAP_PREFFERED_ENGINE: '%s'. It will be ignored.", preferred_engine);
615 }
616 if ((!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCE", preferred_engine) && !strcmpcxx . . $ strcmp(5ae29d726ae57f88).("http://open-scap.org/page/SCE", check->systemcxx . . $ xccdf_check#system.)) ||
617 (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("OVAL", preferred_engine) && !strcmpcxx . . $ strcmp(5ae29d726ae57f88).("http://oval.mitre.org/XMLSchema/oval-definitions-5", check->systemcxx . . $ xccdf_check#system.))) {
618 break;
619 }
620 }
621 } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("http://oval.mitre.org/XMLSchema/oval-definitions-5", check->systemcxx . . $ xccdf_check#system.) == 0) {
622 print_oval_warning = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
623 } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("http://scap.nist.gov/schema/ocil/2", check->systemcxx . . $ xccdf_check#system.) == 0) {
624 dIcxx . . $ `src/common/debug_priv.h:61:9`!("This rule requires an OCIL check. OCIL checks are not supported by OpenSCAP.");
625 } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("http://open-scap.org/page/SCE", check->systemcxx . . $ xccdf_check#system.) == 0) {
626 dIcxx . . $ `src/common/debug_priv.h:61:9`!("This rule requires a SCE check but the SCE plugin was disabled.");
627 } else {
628 print_general_warning = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
629 warning_check_system = check->systemcxx . . $ xccdf_check#system.;
630 }
631 }
632
633 // Only print a warning if we didn't select a check but could've otherwise.
634 if (print_oval_warning) {
635 dWcxx . . $ `src/common/debug_priv.h:62:9`!("Skipping rule that uses OVAL but is possibly malformed; "
636 "an incorrect content reference prevents this check from being evaluated.\n");
637 } else if (print_general_warning && result == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
638 dWcxx . . $ `src/common/debug_priv.h:62:9`!("Skipping rule that requires an unregistered check system "
639 "or incorrect content reference to evaluate. "
640 "Please consider providing a valid SCAP/OVAL instead of %s\n",
641 warning_check_system);
642 }
643 xccdf_check_iterator_freecxx . . $ xccdf_check_iterator_free(dcf67c9af31da2e3).(candidate_it);
644 }
645 // A tool processing the Benchmark for compliance checking must pick at most one check or
646 // complex-check element to process for each Rule.
647 return result;
648 }
649
650 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!
651 xccdf_policy_is_item_selectedcxx . . $ xccdf_policy_is_item_selected(556e49a57ec3a724).(struct xccdf_policycxx . . $ xccdf_policy# *policy, const char *id)
652 {
653 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! *tmp = (const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!*) oscap_htable_getcxx . . $ oscap_htable_get(f5c7e8ff6c970cd3).(policy->selected_finalcxx . . $ xccdf_policy#selected_final., id);
654 if (tmp == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
655 /* This shall really never happen. All valid IDs of any
656 * xccdf:Item shall be stored in the dictionary. However,
657 * we shall not to segfault. */
658 assertcxx . . $ `/usr/include/assert.h:50:10`!(false);
659 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
660 }
661 return *tmp;
662 }
663
664 int xccdf_policy_get_selected_rules_countcxx . . $ xccdf_policy_get_selected_rules_count(6f00885c5a9cd26).(struct xccdf_policycxx . . $ xccdf_policy# *policy)
665 {
666 int ret = 0;
667 struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model = xccdf_policy_get_modelcxx . . $ xccdf_policy_get_model(f98af4da2524e136).(policy);
668 struct xccdf_benchmarkcxx . . $ xccdf_benchmark# *benchmark = xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(model);
669 struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *it = oscap_htable_iterator_newcxx . . $ oscap_htable_iterator_new(81743c99830972e7).(policy->selected_finalcxx . . $ xccdf_policy#selected_final.);
670
671 while (oscap_htable_iterator_has_morecxx . . $ oscap_htable_iterator_has_more(eba4198ab3388c55).(it)) {
672 const char *key = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
673 void *value = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
674
675 oscap_htable_iterator_next_kvcxx . . $ oscap_htable_iterator_next_kv(6fdd88671b26854e).(it, &key, &value);
676
677 if (!value || !*(boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!*)value)
678 continue;
679
680 if (!key)
681 continue;
682
683 struct xccdf_itemcxx . . $ xccdf_item# *item = xccdf_benchmark_get_membercxx . . $ xccdf_benchmark_get_member(51139a28f6959fd9).(benchmark, XCCDF_ITEMcxx . . $ XCCDF_ITEM., key);
684
685 if (!item)
686 continue;
687
688 if (xccdf_item_get_typecxx . . $ xccdf_item_get_type(3d8d48c673cd637b).(item) == XCCDF_RULEcxx . . $ XCCDF_RULE.)
689 ++ret;
690 }
691
692 oscap_htable_iterator_freecxx . . $ oscap_htable_iterator_free(e07ea5562ff119bd).(it);
693 return ret;
694 }
695
696 static struct xccdf_rule_resultcxx . . $ xccdf_rule_result# * _xccdf_rule_result_new_from_rulecxx . . $ _xccdf_rule_result_new_from_rule(9b826c9d59133cde).(const struct xccdf_policycxx . . $ xccdf_policy# *policy, const struct xccdf_rulecxx . . $ xccdf_rule# *rule,
697 struct xccdf_checkcxx . . $ xccdf_check# *check,
698 xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# eval_result,
699 const char *message)
700 {
701 const char* rule_id = xccdf_rule_get_idcxx . . $ xccdf_rule_get_id(f04cd2d7bd5fa08a).(rule);
702 struct xccdf_rule_resultcxx . . $ xccdf_rule_result# *rule_ritem = xccdf_rule_result_newcxx . . $ xccdf_rule_result_new(8246cd908aadc7ea).();
703 struct xccdf_refine_rule_internalcxx . . $ xccdf_refine_rule_internal#* r_rule = oscap_htable_getcxx . . $ oscap_htable_get(f5c7e8ff6c970cd3).(policy->refine_rules_internalcxx . . $ xccdf_policy#refine_rules_internal., rule_id);
704
705 /* --Set rule-- */
706 xccdf_rule_result_set_resultcxx . . $ xccdf_rule_result_set_result(f5f20b6cb7f23401).(rule_ritem, eval_result);
707 xccdf_rule_result_set_idrefcxx . . $ xccdf_rule_result_set_idref(1e91eec4d988bd18).(rule_ritem, xccdf_rule_get_idcxx . . $ xccdf_rule_get_id(f04cd2d7bd5fa08a).(rule));
708 xccdf_rule_result_set_weightcxx . . $ xccdf_rule_result_set_weight(d26c040703514859).(rule_ritem, xccdf_get_final_weightcxx . . $ xccdf_get_final_weight(d85be097a195422e).(rule, r_rule));
709 xccdf_rule_result_set_versioncxx . . $ xccdf_rule_result_set_version(1e91eec4d988bd18).(rule_ritem, xccdf_rule_get_versioncxx . . $ xccdf_rule_get_version(f04cd2d7bd5fa08a).(rule));
710 xccdf_rule_result_set_severitycxx . . $ xccdf_rule_result_set_severity(7626351a8c364921).(rule_ritem, xccdf_get_final_severitycxx . . $ xccdf_get_final_severity(7e9681ac08864c33).(rule, r_rule));
711 xccdf_rule_result_set_rolecxx . . $ xccdf_rule_result_set_role(d584e28722dd1b3).(rule_ritem, xccdf_get_final_rolecxx . . $ xccdf_get_final_role(170008a3fc9b2297).(rule, r_rule));
712
713 xccdf_rule_result_set_time_currentcxx . . $ xccdf_rule_result_set_time_current(82df6f19f833a849).(rule_ritem);
714
715 /* --Ident-- */
716 struct xccdf_ident_iteratorcxx . . $ xccdf_ident_iterator# * ident_it = xccdf_rule_get_identscxx . . $ xccdf_rule_get_idents(a0e3f5394b5a0b4c).(rule);
717 while (xccdf_ident_iterator_has_morecxx . . $ xccdf_ident_iterator_has_more(9cd00765e4887e1a).(ident_it)){
718 struct xccdf_identcxx . . $ xccdf_ident# * ident = xccdf_ident_iterator_nextcxx . . $ xccdf_ident_iterator_next(980350b3dadb3f34).(ident_it);
719 xccdf_rule_result_add_identcxx . . $ xccdf_rule_result_add_ident(29556db1c63427ec).(rule_ritem, xccdf_ident_clonecxx . . $ xccdf_ident_clone(c4fcf9b271bbac33).(ident));
720 }
721 xccdf_ident_iterator_freecxx . . $ xccdf_ident_iterator_free(24490d322c8816ab).(ident_it);
722 if (check != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
723 xccdf_rule_result_add_checkcxx . . $ xccdf_rule_result_add_check(c03f91ccc1a80771).(rule_ritem, check);
724
725 if (message != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
726 struct xccdf_messagecxx . . $ xccdf_message# *msg = xccdf_message_newcxx . . $ xccdf_message_new(19dd3caa70854cb9).();
727 xccdf_message_set_contentcxx . . $ xccdf_message_set_content(2941e8c3910a009a).(msg, message);
728 xccdf_message_set_severitycxx . . $ xccdf_message_set_severity(176044020f1f6e33).(msg, XCCDF_MSG_INFOcxx . . $ XCCDF_MSG_INFO.);
729 xccdf_rule_result_add_messagecxx . . $ xccdf_rule_result_add_message(fa4d98170a72ab10).(rule_ritem, msg);
730 }
731 return rule_ritem;
732 }
733
734 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _user_specified_rule_modecxx . . $ _user_specified_rule_mode(11f15227c042e923).(struct xccdf_policycxx . . $ xccdf_policy# *policy) {
735 return oscap_htable_itemcountcxx . . $ oscap_htable_itemcount(74d87088304a4a23).(policy->rulescxx . . $ xccdf_policy#rules.) > 0;
736 }
737
738 static int _xccdf_policy_report_rule_resultcxx . . $ _xccdf_policy_report_rule_result(496bb4a8c3e61667).(struct xccdf_policycxx . . $ xccdf_policy# *policy,
739 struct xccdf_resultcxx . . $ xccdf_result# *result,
740 const struct xccdf_rulecxx . . $ xccdf_rule# *rule,
741 struct xccdf_checkcxx . . $ xccdf_check# *check,
742 int res,
743 const char *message)
744 {
745 struct xccdf_rule_resultcxx . . $ xccdf_rule_result# * rule_result = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
746 int ret=0;
747
748 if (res == -1)
749 return res;
750
751 if (result != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
752 /* Add result to policy */
753 /* TODO: instance */
754 rule_result = _xccdf_rule_result_new_from_rulecxx . . $ _xccdf_rule_result_new_from_rule(9b826c9d59133cde).(policy, rule, check, res, message);
755 xccdf_result_add_rule_resultcxx . . $ xccdf_result_add_rule_result(505b28109c51c3dd).(result, rule_result);
756 } else
757 xccdf_check_freecxx . . $ xccdf_check_free(5c0307a75faadf5).(check);
758
759 /* If at least one --rule option has been provided by the user on the
760 * command line skip reporting for the other rules - only the selected
761 * rule(s) will be reported. */
762 if (_user_specified_rule_modecxx . . $ _user_specified_rule_mode(11f15227c042e923).(policy) > 0) {
763 const char* rule_id = xccdf_rule_get_idcxx . . $ xccdf_rule_get_id(f04cd2d7bd5fa08a).(rule);
764 if (oscap_htable_getcxx . . $ oscap_htable_get(f5c7e8ff6c970cd3).(policy->rulescxx . . $ xccdf_policy#rules., rule_id) == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
765 return ret;
766 }
767 ret = xccdf_policy_report_cbcxx . . $ xccdf_policy_report_cb(2b8150694cbb4259).(policy, XCCDF_POLICY_OUTCB_ENDcxx . . $ `src/XCCDF_POLICY/xccdf_policy_model_priv.h:34:9`!, (void *) rule_result);
768 return ret;
769 }
770
771 struct cpe_check_cb_usrcxx . . $ cpe_check_cb_usr#
772 {
773 struct xccdf_policy_modelcxx . . $ xccdf_policy_model#* modelcxx . . $ cpe_check_cb_usr#model.;
774 struct cpe_dict_modelcxx . . $ cpe_dict_model#* dictcxx . . $ cpe_check_cb_usr#dict.;
775 struct cpe_lang_modelcxx . . $ cpe_lang_model#* lang_modelcxx . . $ cpe_check_cb_usr#lang_model.;
776 };
777
778 /**
779 * Return true if path starts with '.' or './'
780 */
781 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! is_path_relative_subdircxx . . $ is_path_relative_subdir(c5f7da30cbc0f4e9).(const char* path) {
782 if ( path[0] == '.' ) {
783 if ( path[1] == '/' || path[1] == '\0' ) return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
784 }
785 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
786 }
787
788 static char *_cpe_get_oval_hrefcxx . . $ _cpe_get_oval_href(9bb0e21e0dcf1ad7).(struct cpe_dict_modelcxx . . $ cpe_dict_model# *dict, struct cpe_lang_modelcxx . . $ cpe_lang_model# *lang_model, const char *oval_relative_href)
789 {
790 char *oval_href = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
791 if (dict != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! || lang_model != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
792 char* origin_file = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
793 const char* origin_file_c = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
794
795 if (dict != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
796 // the href path is relative to the CPE dictionary, we need to figure out
797 // a "prefixed path" to deal with the case where CPE dict is not in CWD
798 origin_file_c = cpe_dict_model_get_origin_filecxx . . $ cpe_dict_model_get_origin_file(ce13055568eecbfc).(dict);
799 } else {
800 // the href path is relative to the CPE2 dictionary, we need to figure out
801 // a "prefixed path" to deal with the case where CPE2 dict is not in CWD
802 origin_file_c = cpe_lang_model_get_origin_filecxx . . $ cpe_lang_model_get_origin_file(45dc8957713def91).(lang_model);
803 }
804
805 // we need to strdup because dirname potentially alters the string
806 origin_file = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(origin_file_c ? origin_file_c : "");
807 char *prefix_dirname = oscap_dirnamecxx . . $ oscap_dirname(7a9722d75b371431).(origin_file);
808 if (is_path_relative_subdircxx . . $ is_path_relative_subdir(c5f7da30cbc0f4e9).(prefix_dirname)) {
809 // The path is relative. Do not overide it.
810 // Chances are that ds_sds_session expects the very same href
811 oval_href = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(oval_relative_href);
812 } else {
813 oval_href = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("%s/%s", prefix_dirname, oval_relative_href);
814 }
815 freecxx . . $ free(5d22bdacc48458e8).(prefix_dirname);
816 freecxx . . $ free(5d22bdacc48458e8).(origin_file);
817 }
818 return oval_href;
819 }
820
821 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _xccdf_policy_cpe_check_cbcxx . . $ _xccdf_policy_cpe_check_cb(4e0524cda4b5fafd).(const char* sys, const char* href, const char* name, void* usr)
822 {
823 // FIXME: Check that sys is OVAL
824
825 struct cpe_check_cb_usrcxx . . $ cpe_check_cb_usr#* cb_usr = (struct cpe_check_cb_usrcxx . . $ cpe_check_cb_usr#*)usr;
826
827 struct xccdf_policy_modelcxx . . $ xccdf_policy_model#* model = cb_usr->modelcxx . . $ cpe_check_cb_usr#model.;
828
829 char* prefixed_href = _cpe_get_oval_hrefcxx . . $ _cpe_get_oval_href(9bb0e21e0dcf1ad7).(cb_usr->dictcxx . . $ cpe_check_cb_usr#dict., cb_usr->lang_modelcxx . . $ cpe_check_cb_usr#lang_model., href);
830 struct oval_agent_sessioncxx . . $ oval_agent_session# *session = cpe_session_lookup_oval_sessioncxx . . $ cpe_session_lookup_oval_session(25b39d22c4ee9fc2).(model->cpecxx . . $ xccdf_policy_model#cpe., prefixed_href);
831 freecxx . . $ free(5d22bdacc48458e8).(prefixed_href);
832 if (session == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
833 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
834 }
835
836 oval_agent_eval_definitioncxx . . $ oval_agent_eval_definition(f96e825d70a43f1e).(session, name);
837 oval_result_tcxx . . $ oval_result_t# result = OVAL_RESULT_NOT_EVALUATEDcxx . . $ OVAL_RESULT_NOT_EVALUATED.;
838 if (oval_agent_get_definition_resultcxx . . $ oval_agent_get_definition_result(16f71d6dbd2ef110).(session, name, &result) != 0)
839 {
840 // error message should already be set in the function
841 }
842
843 return result == OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE.;
844 }
845
846 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _xccdf_policy_cpe_dict_cbcxx . . $ _xccdf_policy_cpe_dict_cb(9e6dc912b132a363).(struct cpe_namecxx . . $ cpe_name#* name, void* usr)
847 {
848 struct cpe_check_cb_usrcxx . . $ cpe_check_cb_usr#* cb_usr = (struct cpe_check_cb_usrcxx . . $ cpe_check_cb_usr#*)usr;
849
850 // We have to check all CPE1 dicts in the model.
851 // cb_usr->dict has nothing to do with this callback! Do NOT touch it here.
852
853 struct xccdf_policy_modelcxx . . $ xccdf_policy_model#* model = cb_usr->modelcxx . . $ cpe_check_cb_usr#model.;
854 struct xccdf_benchmarkcxx . . $ xccdf_benchmark#* benchmark = xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(model);
855
856 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ret = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
857
858 struct cpe_dict_modelcxx . . $ cpe_dict_model#* embedded_dict = xccdf_benchmark_get_cpe_listcxx . . $ xccdf_benchmark_get_cpe_list(4ac24f742972c093).(benchmark);
859 if (embedded_dict != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
860 ret = cpe_name_applicable_dictcxx . . $ cpe_name_applicable_dict(6696ab683acb39a6).(name, embedded_dict, (cpe_check_fncxx . . $ cpe_check_fn#) _xccdf_policy_cpe_check_cbcxx . . $ _xccdf_policy_cpe_check_cb(4e0524cda4b5fafd)., usr);
861 }
862 if (ret)
863 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
864
865 struct oscap_iteratorcxx . . $ oscap_iterator#* dicts = oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).(model->cpecxx . . $ xccdf_policy_model#cpe.->dictscxx . . $ cpe_session#dicts.);
866 while (!ret && oscap_iterator_has_morecxx . . $ oscap_iterator_has_more(63b1de9a5adb9205).(dicts)) {
867 struct cpe_dict_modelcxx . . $ cpe_dict_model# *dict = (struct cpe_dict_modelcxx . . $ cpe_dict_model#*)oscap_iterator_nextcxx . . $ oscap_iterator_next(4c75051c806960eb).(dicts);
868 ret = cpe_name_applicable_dictcxx . . $ cpe_name_applicable_dict(6696ab683acb39a6).(name, dict, (cpe_check_fncxx . . $ cpe_check_fn#) _xccdf_policy_cpe_check_cbcxx . . $ _xccdf_policy_cpe_check_cb(4e0524cda4b5fafd)., usr);
869 }
870 oscap_iterator_freecxx . . $ oscap_iterator_free(3cba44c1b7872358).(dicts);
871 return ret;
872 }
873
874 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_model_platforms_are_applicable_dictcxx . . $ xccdf_policy_model_platforms_are_applicable_dict(b5e9011b1b5c1fe0).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model, struct cpe_dict_modelcxx . . $ cpe_dict_model# *dict, struct oscap_string_iteratorcxx . . $ oscap_string_iterator# *platforms)
875 {
876 // at this point we know that the item has 1 or more platforms specified
877 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ret = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
878
879 while (oscap_string_iterator_has_morecxx . . $ oscap_string_iterator_has_more(3724f2faf2515a82).(platforms))
880 {
881 const char* platform = oscap_string_iterator_nextcxx . . $ oscap_string_iterator_next(1f2a9ae2534eef34).(platforms);
882 // Platform could be a reference to CPE2 platform, skip the ones
883 // that aren't valid CPE names.
884 if (!cpe_name_checkcxx . . $ cpe_name_check(c5f7da30cbc0f4e9).(platform))
885 continue;
886
887 struct cpe_namecxx . . $ cpe_name#* name = cpe_name_newcxx . . $ cpe_name_new(dfbdfc9fcef857b).(platform);
888
889 struct cpe_check_cb_usrcxx . . $ cpe_check_cb_usr#* usr = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct cpe_check_cb_usrcxx . . $ cpe_check_cb_usr#));
890 usr->modelcxx . . $ cpe_check_cb_usr#model. = model;
891 usr->dictcxx . . $ cpe_check_cb_usr#dict. = dict;
892 usr->lang_modelcxx . . $ cpe_check_cb_usr#lang_model. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
893 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! applicable = cpe_name_applicable_dictcxx . . $ cpe_name_applicable_dict(6696ab683acb39a6).(name, dict, (cpe_check_fncxx . . $ cpe_check_fn#) _xccdf_policy_cpe_check_cbcxx . . $ _xccdf_policy_cpe_check_cb(4e0524cda4b5fafd)., usr);
894 freecxx . . $ free(5d22bdacc48458e8).(usr);
895
896 cpe_name_freecxx . . $ cpe_name_free(6799d02d05c0f5d7).(name);
897
898 if (applicable)
899 {
900 ret = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
901
902 if (oscap_htable_getcxx . . $ oscap_htable_get(f5c7e8ff6c970cd3).(model->cpecxx . . $ xccdf_policy_model#cpe.->applicable_platformscxx . . $ cpe_session#applicable_platforms., platform) == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
903 oscap_htable_addcxx . . $ oscap_htable_add(d9abe78f59fa00eb).(model->cpecxx . . $ xccdf_policy_model#cpe.->applicable_platformscxx . . $ cpe_session#applicable_platforms., platform, 0);
904 }
905 }
906 }
907 oscap_string_iterator_resetcxx . . $ oscap_string_iterator_reset(41a77e9ce361f406).(platforms);
908
909 return ret;
910 }
911
912 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_model_platforms_are_applicable_lang_modelcxx . . $ xccdf_policy_model_platforms_are_applicable_lang_model(f3f458ea03cc1257).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model, struct cpe_lang_modelcxx . . $ cpe_lang_model# *lang_model, struct oscap_string_iteratorcxx . . $ oscap_string_iterator# *platforms)
913 {
914 // at this point we know that the item has 1 or more platforms specified
915 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ret = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
916
917 while (oscap_string_iterator_has_morecxx . . $ oscap_string_iterator_has_more(3724f2faf2515a82).(platforms))
918 {
919 const char* platform = oscap_string_iterator_nextcxx . . $ oscap_string_iterator_next(1f2a9ae2534eef34).(platforms);
920 // Specification says that platform should begin with "#" if it is
921 // a reference to a CPE2 platform. However content exists where this
922 // is not strictly followed so we support both with and without "#"
923 // references.
924
925 const char* platform_shifted = platform;
926 if (strlencxx . . $ strlen(751346f8406fd082).(platform_shifted) >= 1 && *platform_shifted == '#')
927 {
928 // skip the "#" character
929 platform_shifted++;
930 }
931
932 struct cpe_check_cb_usrcxx . . $ cpe_check_cb_usr#* usr = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct cpe_check_cb_usrcxx . . $ cpe_check_cb_usr#));
933 usr->modelcxx . . $ cpe_check_cb_usr#model. = model;
934 usr->dictcxx . . $ cpe_check_cb_usr#dict. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
935 usr->lang_modelcxx . . $ cpe_check_cb_usr#lang_model. = lang_model;
936 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! applicable = cpe_platform_applicable_lang_modelcxx . . $ cpe_platform_applicable_lang_model(1e40406a95e00665).(platform_shifted, lang_model, (cpe_check_fncxx . . $ cpe_check_fn#)_xccdf_policy_cpe_check_cbcxx . . $ _xccdf_policy_cpe_check_cb(4e0524cda4b5fafd)., (cpe_dict_fncxx . . $ cpe_dict_fn#)_xccdf_policy_cpe_dict_cbcxx . . $ _xccdf_policy_cpe_dict_cb(9e6dc912b132a363)., usr);
937 freecxx . . $ free(5d22bdacc48458e8).(usr);
938
939 if (applicable)
940 {
941 ret = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
942
943 if (oscap_htable_getcxx . . $ oscap_htable_get(f5c7e8ff6c970cd3).(model->cpecxx . . $ xccdf_policy_model#cpe.->applicable_platformscxx . . $ cpe_session#applicable_platforms., platform) == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
944 oscap_htable_addcxx . . $ oscap_htable_add(d9abe78f59fa00eb).(model->cpecxx . . $ xccdf_policy_model#cpe.->applicable_platformscxx . . $ cpe_session#applicable_platforms., platform, 0);
945 }
946 }
947 }
948 oscap_string_iterator_resetcxx . . $ oscap_string_iterator_reset(41a77e9ce361f406).(platforms);
949
950 return ret;
951 }
952
953 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_model_platforms_are_applicablecxx . . $ xccdf_policy_model_platforms_are_applicable(248655e41eddd5a).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model, struct oscap_string_iteratorcxx . . $ oscap_string_iterator# *platforms)
954 {
955 // we have to check whether the item has any platforms at all, if it has none
956 // it should be applicable to all platforms
957 if (!oscap_string_iterator_has_morecxx . . $ oscap_string_iterator_has_more(3724f2faf2515a82).(platforms))
958 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
959
960 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ret = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
961 // We do not check whether the platform entries are valid platform refs
962 // or CPE names. We let the policy_model methods do that instead.
963 // Therefore we check all 4 (!) places where a platform may match.
964 // CPE2 takes precedence over CPE1 in this implementation. This is not
965 // dictated by the specification, it's an arbitrary choice.
966 struct xccdf_benchmarkcxx . . $ xccdf_benchmark#* benchmark = xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(model);
967 struct cpe_lang_modelcxx . . $ cpe_lang_model# *embedded_lang_model = xccdf_benchmark_get_cpe_lang_modelcxx . . $ xccdf_benchmark_get_cpe_lang_model(abf6c9caef5e0812).(benchmark);
968 if (embedded_lang_model != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
969 if (xccdf_policy_model_platforms_are_applicable_lang_modelcxx . . $ xccdf_policy_model_platforms_are_applicable_lang_model(f3f458ea03cc1257).(model, embedded_lang_model, platforms))
970 ret = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
971 }
972
973 struct oscap_iteratorcxx . . $ oscap_iterator# *lang_models = oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).(model->cpecxx . . $ xccdf_policy_model#cpe.->lang_modelscxx . . $ cpe_session#lang_models.);
974 while (oscap_iterator_has_morecxx . . $ oscap_iterator_has_more(63b1de9a5adb9205).(lang_models)) {
975 struct cpe_lang_modelcxx . . $ cpe_lang_model# *lang_model = (struct cpe_lang_modelcxx . . $ cpe_lang_model# *) oscap_iterator_nextcxx . . $ oscap_iterator_next(4c75051c806960eb).(lang_models);
976 if (xccdf_policy_model_platforms_are_applicable_lang_modelcxx . . $ xccdf_policy_model_platforms_are_applicable_lang_model(f3f458ea03cc1257).(model, lang_model, platforms))
977 ret = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
978 }
979 oscap_iterator_freecxx . . $ oscap_iterator_free(3cba44c1b7872358).(lang_models);
980
981 struct cpe_dict_modelcxx . . $ cpe_dict_model# *embedded_dict = xccdf_benchmark_get_cpe_listcxx . . $ xccdf_benchmark_get_cpe_list(4ac24f742972c093).(benchmark);
982 if (embedded_dict != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
983 if (xccdf_policy_model_platforms_are_applicable_dictcxx . . $ xccdf_policy_model_platforms_are_applicable_dict(b5e9011b1b5c1fe0).(model, embedded_dict, platforms))
984 ret = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
985 }
986
987 struct oscap_iteratorcxx . . $ oscap_iterator# *dicts = oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).(model->cpecxx . . $ xccdf_policy_model#cpe.->dictscxx . . $ cpe_session#dicts.);
988 while (oscap_iterator_has_morecxx . . $ oscap_iterator_has_more(63b1de9a5adb9205).(dicts)) {
989 struct cpe_dict_modelcxx . . $ cpe_dict_model# *dict = (struct cpe_dict_modelcxx . . $ cpe_dict_model# *) oscap_iterator_nextcxx . . $ oscap_iterator_next(4c75051c806960eb).(dicts);
990 if (xccdf_policy_model_platforms_are_applicable_dictcxx . . $ xccdf_policy_model_platforms_are_applicable_dict(b5e9011b1b5c1fe0).(model, dict, platforms))
991 ret = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
992 }
993 oscap_iterator_freecxx . . $ oscap_iterator_free(3cba44c1b7872358).(dicts);
994
995 return ret;
996 }
997
998 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_model_item_is_applicablecxx . . $ xccdf_policy_model_item_is_applicable(a3677b735ed6bb27).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model, struct xccdf_itemcxx . . $ xccdf_item# *item)
999 {
1000 struct xccdf_itemcxx . . $ xccdf_item#* parent = xccdf_item_get_parentcxx . . $ xccdf_item_get_parent(b4a609d518f04b24).(item);
1001 if (!parent || xccdf_policy_model_item_is_applicablecxx . . $ xccdf_policy_model_item_is_applicable(a3677b735ed6bb27).(model, parent))
1002 {
1003 struct oscap_string_iteratorcxx . . $ oscap_string_iterator#* platforms = xccdf_item_get_platformscxx . . $ xccdf_item_get_platforms(aa681965e3ad4ccf).(item);
1004 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ret = xccdf_policy_model_platforms_are_applicablecxx . . $ xccdf_policy_model_platforms_are_applicable(248655e41eddd5a).(model, platforms);
1005 oscap_string_iterator_freecxx . . $ oscap_string_iterator_free(41a77e9ce361f406).(platforms);
1006
1007 return ret;
1008 }
1009 else
1010 {
1011 // parent is not applicable
1012 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1013 }
1014 }
1015
1016 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _xccdf_policy_item_is_in_conflictcxx . . $ _xccdf_policy_item_is_in_conflict(b15fd4f3d86d8a47).(struct xccdf_policycxx . . $ xccdf_policy# *policy, const struct xccdf_itemcxx . . $ xccdf_item# *item) {
1017 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! in_conflict = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1018 struct oscap_string_iteratorcxx . . $ oscap_string_iterator# *item_conflicts_it = xccdf_item_get_conflictscxx . . $ xccdf_item_get_conflicts(aa681965e3ad4ccf).(item);
1019 while (oscap_string_iterator_has_morecxx . . $ oscap_string_iterator_has_more(3724f2faf2515a82).(item_conflicts_it)) {
1020 const char *conflict_id = oscap_string_iterator_nextcxx . . $ oscap_string_iterator_next(1f2a9ae2534eef34).(item_conflicts_it);
1021 if (xccdf_policy_is_item_selectedcxx . . $ xccdf_policy_is_item_selected(556e49a57ec3a724).(policy, conflict_id)) {
1022 in_conflict = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1023 break;
1024 }
1025 }
1026 oscap_string_iterator_freecxx . . $ oscap_string_iterator_free(41a77e9ce361f406).(item_conflicts_it);
1027 return in_conflict;
1028 }
1029
1030 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _xccdf_policy_item_has_all_requirementscxx . . $ _xccdf_policy_item_has_all_requirements(b15fd4f3d86d8a47).(struct xccdf_policycxx . . $ xccdf_policy# *policy, const struct xccdf_itemcxx . . $ xccdf_item# *item) {
1031 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! has_all_requirements = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1032 struct oscap_stringlist_iteratorcxx . . $ oscap_stringlist_iterator# *item_requires_it = xccdf_item_get_requirescxx . . $ xccdf_item_get_requires(4162f05d84d02d26).(item);
1033 while (oscap_stringlist_iterator_has_morecxx . . $ oscap_stringlist_iterator_has_more(36a5096ea135105).(item_requires_it)) {
1034 struct oscap_stringlistcxx . . $ oscap_stringlist# *requires_ids_list = oscap_stringlist_iterator_nextcxx . . $ oscap_stringlist_iterator_next(bc2d458b6c9aa3b8).(item_requires_it);
1035 struct oscap_string_iteratorcxx . . $ oscap_string_iterator# *rule_requires_ids_it = oscap_stringlist_get_stringscxx . . $ oscap_stringlist_get_strings(13be827fcd32d2b9).(requires_ids_list);
1036 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! has_requirements = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1037 while (oscap_string_iterator_has_morecxx . . $ oscap_string_iterator_has_more(3724f2faf2515a82).(rule_requires_ids_it)) {
1038 const char *requires_id = oscap_string_iterator_nextcxx . . $ oscap_string_iterator_next(1f2a9ae2534eef34).(rule_requires_ids_it);
1039 has_requirements = has_requirements || xccdf_policy_is_item_selectedcxx . . $ xccdf_policy_is_item_selected(556e49a57ec3a724).(policy, requires_id);
1040 }
1041 has_all_requirements = has_all_requirements && has_requirements;
1042 oscap_string_iterator_freecxx . . $ oscap_string_iterator_free(41a77e9ce361f406).(rule_requires_ids_it);
1043 }
1044 oscap_stringlist_iterator_freecxx . . $ oscap_stringlist_iterator_free(8dac3ebbe1cd8b03).(item_requires_it);
1045 return has_all_requirements;
1046 }
1047
1048 static void _warn_about_required_rulescxx . . $ _warn_about_required_rules(84a09d125e2faa7e).(const struct xccdf_policycxx . . $ xccdf_policy# *policy, const struct xccdf_rulecxx . . $ xccdf_rule# *rule)
1049 {
1050 struct oscap_stringlist_iteratorcxx . . $ oscap_stringlist_iterator# *requires_it = xccdf_item_get_requirescxx . . $ xccdf_item_get_requires(4162f05d84d02d26).((struct xccdf_itemcxx . . $ xccdf_item# *) rule);
1051 while (oscap_stringlist_iterator_has_morecxx . . $ oscap_stringlist_iterator_has_more(36a5096ea135105).(requires_it)) {
1052 struct oscap_stringlistcxx . . $ oscap_stringlist# *requires_ids_list = oscap_stringlist_iterator_nextcxx . . $ oscap_stringlist_iterator_next(bc2d458b6c9aa3b8).(requires_it);
1053 struct oscap_string_iteratorcxx . . $ oscap_string_iterator# *rule_requires_ids_it = oscap_stringlist_get_stringscxx . . $ oscap_stringlist_get_strings(13be827fcd32d2b9).(requires_ids_list);
1054 while (oscap_string_iterator_has_morecxx . . $ oscap_string_iterator_has_more(3724f2faf2515a82).(rule_requires_ids_it)) {
1055 const char *requires_id = oscap_string_iterator_nextcxx . . $ oscap_string_iterator_next(1f2a9ae2534eef34).(rule_requires_ids_it);
1056 if (oscap_htable_getcxx . . $ oscap_htable_get(f5c7e8ff6c970cd3).(policy->rulescxx . . $ xccdf_policy#rules., requires_id) == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1057 dWcxx . . $ `src/common/debug_priv.h:62:9`!("Rule '%s' requires rule '%s', but it hasn't been specified using the '--rule' option.", xccdf_rule_get_id(rule), requires_id);
1058 }
1059 }
1060 oscap_string_iterator_freecxx . . $ oscap_string_iterator_free(41a77e9ce361f406).(rule_requires_ids_it);
1061 }
1062 oscap_stringlist_iterator_freecxx . . $ oscap_stringlist_iterator_free(8dac3ebbe1cd8b03).(requires_it);
1063 }
1064
1065 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _matches_referencescxx . . $ _matches_references(35980c9029b8d8e6).(struct xccdf_policycxx . . $ xccdf_policy# *policy, const struct xccdf_rulecxx . . $ xccdf_rule# *rule)
1066 {
1067 if (!policy->reference_filtercxx . . $ xccdf_policy#reference_filter..activecxx . . $ xccdf_policy#$anonymous_type_0#active.) {
1068 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1069 }
1070 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! matched = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1071 struct oscap_reference_iteratorcxx . . $ oscap_reference_iterator# *references = xccdf_item_get_referencescxx . . $ xccdf_item_get_references(58b511645be6226a).((struct xccdf_itemcxx . . $ xccdf_item# *)rule);
1072 while (oscap_reference_iterator_has_morecxx . . $ oscap_reference_iterator_has_more(3902913d46f91173).(references) && !matched) {
1073 struct oscap_referencecxx . . $ oscap_reference# *ref = oscap_reference_iterator_nextcxx . . $ oscap_reference_iterator_next(81bc9a067126085c).(references);
1074 const char *href = oscap_reference_get_hrefcxx . . $ oscap_reference_get_href(2a9eef276a992895).(ref);
1075 const char *title = oscap_reference_get_titlecxx . . $ oscap_reference_get_title(2a9eef276a992895).(ref);
1076 if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(href, policy->reference_filtercxx . . $ xccdf_policy#reference_filter..hrefcxx . . $ xccdf_policy#$anonymous_type_0#href.) && !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(title, policy->reference_filtercxx . . $ xccdf_policy#reference_filter..titlecxx . . $ xccdf_policy#$anonymous_type_0#title.)) {
1077 matched = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1078 }
1079 }
1080 oscap_reference_iterator_freecxx . . $ oscap_reference_iterator_free(3e07142178288e0).(references);
1081 return matched;
1082 }
1083
1084 /**
1085 * Evaluate given check which is immediate child of the rule.
1086 * A possibe child checks will be evaluated by xccdf_policy_check_evaluate.
1087 * This duplication is needed to handle @multi-check correctly,
1088 * which is (in general) not predictable in any way.
1089 */
1090 static inline int
1091 _xccdf_policy_rule_evaluatecxx . . $ _xccdf_policy_rule_evaluate(2d5f2e6760955a6e).(struct xccdf_policycxx . . $ xccdf_policy# * policy, const struct xccdf_rulecxx . . $ xccdf_rule# *rule, struct xccdf_resultcxx . . $ xccdf_result# *result, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! parent_selected)
1092 {
1093 const char* rule_id = xccdf_rule_get_idcxx . . $ xccdf_rule_get_id(f04cd2d7bd5fa08a).(rule);
1094 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! is_selected = xccdf_policy_is_item_selectedcxx . . $ xccdf_policy_is_item_selected(556e49a57ec3a724).(policy, rule_id);
1095 const char *message = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1096 int report = 0;
1097
1098 /* If the rule is requested to be skipped by the user using --skip-rule on
1099 * the command line we will skip the evaluation of this rule. */
1100 if (oscap_htable_getcxx . . $ oscap_htable_get(f5c7e8ff6c970cd3).(policy->skip_rulescxx . . $ xccdf_policy#skip_rules., rule_id) != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1101 return _xccdf_policy_report_rule_resultcxx . . $ _xccdf_policy_report_rule_result(496bb4a8c3e61667).(policy, result, rule, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_RESULT_NOT_SELECTEDcxx . . $ XCCDF_RESULT_NOT_SELECTED., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1102 }
1103
1104 /* If user wants to evaluate only specific rules and the rule currently
1105 * being evaluated is not among these rules, do not evaluate it and mark it
1106 * as notselected. */
1107 if (_user_specified_rule_modecxx . . $ _user_specified_rule_mode(11f15227c042e923).(policy) > 0) {
1108 if (oscap_htable_getcxx . . $ oscap_htable_get(f5c7e8ff6c970cd3).(policy->rulescxx . . $ xccdf_policy#rules., rule_id) == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1109 return _xccdf_policy_report_rule_resultcxx . . $ _xccdf_policy_report_rule_result(496bb4a8c3e61667).(policy, result, rule, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_RESULT_NOT_SELECTEDcxx . . $ XCCDF_RESULT_NOT_SELECTED., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1110 }
1111 oscap_htable_addcxx . . $ oscap_htable_add(d9abe78f59fa00eb).(policy->rules_foundcxx . . $ xccdf_policy#rules_found., rule_id, (void *)truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1112 _xccdf_policy_modify_selected_finalcxx . . $ _xccdf_policy_modify_selected_final(9f127fec5573ef3b).(policy, rule_id, truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1113 _warn_about_required_rulescxx . . $ _warn_about_required_rules(84a09d125e2faa7e).(policy, rule);
1114
1115 } else {
1116 /* solve selects only when in --rule mode */
1117 if (!is_selected || !parent_selected)
1118 return _xccdf_policy_report_rule_resultcxx . . $ _xccdf_policy_report_rule_result(496bb4a8c3e61667).(policy, result, rule, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_RESULT_NOT_SELECTEDcxx . . $ XCCDF_RESULT_NOT_SELECTED., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1119
1120 // See section 7.2.3.3.2 (<xccdf:requires> and <xccdf:conflicts> Elements) of the XCCDF specification.
1121 if (_xccdf_policy_item_is_in_conflictcxx . . $ _xccdf_policy_item_is_in_conflict(b15fd4f3d86d8a47).(policy, XITEMcxx . . $ `src/XCCDF/helpers.h:35:9`!(rule)) || !_xccdf_policy_item_has_all_requirementscxx . . $ _xccdf_policy_item_has_all_requirements(b15fd4f3d86d8a47).(policy, XITEMcxx . . $ `src/XCCDF/helpers.h:35:9`!(rule))) {
1122 xccdf_policy_resolve_itemcxx . . $ xccdf_policy_resolve_item(a82616d50c5910f3).(policy, XITEMcxx . . $ `src/XCCDF/helpers.h:35:9`!(rule), falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!);
1123 return _xccdf_policy_report_rule_resultcxx . . $ _xccdf_policy_report_rule_result(496bb4a8c3e61667).(policy, result, rule, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_RESULT_NOT_SELECTEDcxx . . $ XCCDF_RESULT_NOT_SELECTED., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1124 }
1125 }
1126
1127 if (!_matches_referencescxx . . $ _matches_references(35980c9029b8d8e6).(policy, rule)) {
1128 return _xccdf_policy_report_rule_resultcxx . . $ _xccdf_policy_report_rule_result(496bb4a8c3e61667).(policy, result, rule, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_RESULT_NOT_SELECTEDcxx . . $ XCCDF_RESULT_NOT_SELECTED., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1129 }
1130
1131 /* Otherwise start reporting */
1132 report = xccdf_policy_report_cbcxx . . $ xccdf_policy_report_cb(2b8150694cbb4259).(policy, XCCDF_POLICY_OUTCB_STARTcxx . . $ `src/XCCDF_POLICY/xccdf_policy_model_priv.h:33:9`!, (void *) rule);
1133 if (report)
1134 return report;
1135
1136 struct xccdf_refine_rule_internalcxx . . $ xccdf_refine_rule_internal#* r_rule = oscap_htable_getcxx . . $ oscap_htable_get(f5c7e8ff6c970cd3).(policy->refine_rules_internalcxx . . $ xccdf_policy#refine_rules_internal., rule_id);
1137 xccdf_role_tcxx . . $ xccdf_role_t# role = xccdf_get_final_rolecxx . . $ xccdf_get_final_role(170008a3fc9b2297).(rule, r_rule);
1138
1139 dIcxx . . $ `src/common/debug_priv.h:61:9`!("Evaluating XCCDF rule '%s'.", rule_id);
1140
1141 if (role == XCCDF_ROLE_UNCHECKEDcxx . . $ XCCDF_ROLE_UNCHECKED.)
1142 return _xccdf_policy_report_rule_resultcxx . . $ _xccdf_policy_report_rule_result(496bb4a8c3e61667).(policy, result, rule, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_RESULT_NOT_CHECKEDcxx . . $ XCCDF_RESULT_NOT_CHECKED., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1143
1144 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! is_applicable = xccdf_policy_model_item_is_applicablecxx . . $ xccdf_policy_model_item_is_applicable(a3677b735ed6bb27).(policy->modelcxx . . $ xccdf_policy#model., (struct xccdf_itemcxx . . $ xccdf_item#*)rule);
1145 if (!is_applicable) {
1146 dIcxx . . $ `src/common/debug_priv.h:61:9`!("Rule '%s' is not applicable.", rule_id);
1147 return _xccdf_policy_report_rule_resultcxx . . $ _xccdf_policy_report_rule_result(496bb4a8c3e61667).(policy, result, rule, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_RESULT_NOT_APPLICABLEcxx . . $ XCCDF_RESULT_NOT_APPLICABLE., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1148 }
1149
1150 const struct xccdf_checkcxx . . $ xccdf_check# *orig_check = _xccdf_policy_rule_get_applicable_checkcxx . . $ _xccdf_policy_rule_get_applicable_check(354c20ade8add915).(policy, (struct xccdf_itemcxx . . $ xccdf_item# *) rule);
1151 if (orig_check == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
1152 // No candidate or applicable check found.
1153 return _xccdf_policy_report_rule_resultcxx . . $ _xccdf_policy_report_rule_result(496bb4a8c3e61667).(policy, result, rule, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_RESULT_NOT_CHECKEDcxx . . $ XCCDF_RESULT_NOT_CHECKED., "No candidate or applicable check found.");
1154
1155 // we need to clone the check to avoid changing the original content
1156 struct xccdf_checkcxx . . $ xccdf_check# *check = xccdf_check_clonecxx . . $ xccdf_check_clone(9079e062377838d0).(orig_check);
1157 if (xccdf_check_get_complexcxx . . $ xccdf_check_get_complex(ceaafcd79241aa30).(check))
1158 return _xccdf_policy_report_rule_resultcxx . . $ _xccdf_policy_report_rule_result(496bb4a8c3e61667).(policy, result, rule, check, xccdf_policy_check_evaluatecxx . . $ xccdf_policy_check_evaluate(c0ca4ea0c149fbc3).(policy, check), NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1159
1160 // Now we are evaluating single simple xccdf:check within xccdf:rule.
1161 // Since the fact that a check will yield multi-check is not predictable in general
1162 // we will evaluate the check here. (A link between rule and its only check is
1163 // somewhat tigher that the one between checks in complex-check tree).
1164 //
1165 // Important: if touching this code, please revisit also xccdf_policy_check_evaluate.
1166 const char *system_name = xccdf_check_get_systemcxx . . $ xccdf_check_get_system(698a89d24cc1a492).(check);
1167 struct oscap_listcxx . . $ oscap_list# *bindings = xccdf_policy_check_get_value_bindingscxx . . $ xccdf_policy_check_get_value_bindings(1de90ce7c9c1886f).(policy, xccdf_check_get_exportscxx . . $ xccdf_check_get_exports(199e9cedf9301c64).(check));
1168 if (bindings == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
1169 return _xccdf_policy_report_rule_resultcxx . . $ _xccdf_policy_report_rule_result(496bb4a8c3e61667).(policy, result, rule, check, XCCDF_RESULT_UNKNOWNcxx . . $ XCCDF_RESULT_UNKNOWN., "Value bindings not found.");
1170
1171
1172 struct xccdf_check_content_ref_iteratorcxx . . $ xccdf_check_content_ref_iterator# *content_it = xccdf_check_get_content_refscxx . . $ xccdf_check_get_content_refs(5eea252c33793573).(check);
1173 struct xccdf_check_content_refcxx . . $ xccdf_check_content_ref# *content;
1174 const char *content_name;
1175 const char *href;
1176 int ret = XCCDF_RESULT_NOT_CHECKEDcxx . . $ XCCDF_RESULT_NOT_CHECKED.; // initialized for the case of no check-content-refs present
1177 while (xccdf_check_content_ref_iterator_has_morecxx . . $ xccdf_check_content_ref_iterator_has_more(ad48050a2429bee3).(content_it)) {
1178 message = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1179 content = xccdf_check_content_ref_iterator_nextcxx . . $ xccdf_check_content_ref_iterator_next(3e7476af5b698c93).(content_it);
1180 content_name = xccdf_check_content_ref_get_namecxx . . $ xccdf_check_content_ref_get_name(18edaaea5423ca08).(content);
1181 href = xccdf_check_content_ref_get_hrefcxx . . $ xccdf_check_content_ref_get_href(18edaaea5423ca08).(content);
1182
1183 if (content_name == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! && xccdf_check_get_multicheckcxx . . $ xccdf_check_get_multicheck(ceaafcd79241aa30).(check)) {
1184 // parent element is Rule, @multi-check is required
1185 struct oscap_listcxx . . $ oscap_list# *oval_definition_list = _xccdf_policy_get_oval_definitions_for_hrefcxx . . $ _xccdf_policy_get_oval_definitions_for_href(1a006988d006f978).(policy, system_name, href);
1186 if (oval_definition_list != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1187 // multi-check is supported by checking-engine
1188 struct oscap_iteratorcxx . . $ oscap_iterator# *oval_definition_iterator = oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).(oval_definition_list);
1189 if (!oscap_iterator_has_morecxx . . $ oscap_iterator_has_more(63b1de9a5adb9205).(oval_definition_iterator)) {
1190 // Super special case when oval file contains no definitions
1191 // thus multi-check shall yield zero rule-results.
1192 report = _xccdf_policy_report_rule_resultcxx . . $ _xccdf_policy_report_rule_result(496bb4a8c3e61667).(policy, result, rule, check, XCCDF_RESULT_UNKNOWNcxx . . $ XCCDF_RESULT_UNKNOWN., "No definitions found for @multi-check.");
1193 oscap_iterator_freecxx . . $ oscap_iterator_free(3cba44c1b7872358).(oval_definition_iterator);
1194 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(oval_definition_list, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1195 xccdf_check_content_ref_iterator_freecxx . . $ xccdf_check_content_ref_iterator_free(30690f049257f900).(content_it);
1196 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(bindings, (oscap_destruct_funccxx . . $ oscap_destruct_func#) xccdf_value_binding_freecxx . . $ xccdf_value_binding_free(97df0146bfa7ea12).);
1197 return report;
1198 }
1199 while (oscap_iterator_has_morecxx . . $ oscap_iterator_has_more(63b1de9a5adb9205).(oval_definition_iterator)) {
1200 struct oval_definitioncxx . . $ oval_definition# *oval_definition = oscap_iterator_nextcxx . . $ oscap_iterator_next(4c75051c806960eb).(oval_definition_iterator);
1201 if ((report = xccdf_policy_report_cbcxx . . $ xccdf_policy_report_cb(2b8150694cbb4259).(policy, XCCDF_POLICY_OUTCB_MULTICHECKcxx . . $ `src/XCCDF_POLICY/xccdf_policy_model_priv.h:35:9`!, (void *) oval_definition)) != 0) {
1202 break;
1203 }
1204 struct xccdf_checkcxx . . $ xccdf_check# *cloned_check = xccdf_check_clonecxx . . $ xccdf_check_clone(9079e062377838d0).(check);
1205 xccdf_check_inject_content_refcxx . . $ xccdf_check_inject_content_ref(fa23abb48d445643).(cloned_check, content, oval_definition_get_idcxx . . $ oval_definition_get_id(293cc7080a5789e2).(oval_definition));
1206 int inner_ret = xccdf_policy_check_evaluatecxx . . $ xccdf_policy_check_evaluate(c0ca4ea0c149fbc3).(policy, cloned_check);
1207 if (inner_ret == -1) {
1208 xccdf_check_freecxx . . $ xccdf_check_free(5c0307a75faadf5).(cloned_check);
1209 report = inner_ret;
1210 break;
1211 }
1212 if ((report = _xccdf_policy_report_rule_resultcxx . . $ _xccdf_policy_report_rule_result(496bb4a8c3e61667).(policy, result, rule, cloned_check, inner_ret, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)) != 0)
1213 break;
1214 if (oscap_iterator_has_morecxx . . $ oscap_iterator_has_more(63b1de9a5adb9205).(oval_definition_iterator)) {
1215 if ((report = xccdf_policy_report_cbcxx . . $ xccdf_policy_report_cb(2b8150694cbb4259).(policy, XCCDF_POLICY_OUTCB_STARTcxx . . $ `src/XCCDF_POLICY/xccdf_policy_model_priv.h:33:9`!, (void *) rule)) != 0)
1216 break;
1217 }
1218 }
1219 oscap_iterator_freecxx . . $ oscap_iterator_free(3cba44c1b7872358).(oval_definition_iterator);
1220 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(oval_definition_list, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1221 xccdf_check_content_ref_iterator_freecxx . . $ xccdf_check_content_ref_iterator_free(30690f049257f900).(content_it);
1222 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(bindings, (oscap_destruct_funccxx . . $ oscap_destruct_func#) xccdf_value_binding_freecxx . . $ xccdf_value_binding_free(97df0146bfa7ea12).);
1223 xccdf_check_freecxx . . $ xccdf_check_free(5c0307a75faadf5).(check);
1224 return report;
1225 }
1226 else
1227 message = "Checking engine does not support multi-check; falling back to multi-check='false'";
1228 }
1229
1230 struct xccdf_check_import_iteratorcxx . . $ xccdf_check_import_iterator# *check_import_it = xccdf_check_get_importscxx . . $ xccdf_check_get_imports(975feb899e9812f3).(check);
1231 ret = xccdf_policy_evaluate_cbcxx . . $ xccdf_policy_evaluate_cb(bd565cfc0d03a14c).(policy, system_name, content_name, href, bindings, check_import_it);
1232 // the evaluation has filled check imports at this point, we can simply free the iterator
1233 xccdf_check_import_iterator_freecxx . . $ xccdf_check_import_iterator_free(2ae6b52ef2d5345b).(check_import_it);
1234
1235 // the content references are basically alternatives according to the specification
1236 // we should go through them in the order they are defined and we are done as soon
1237 // as we process one of them successfully
1238 if ((xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t#) ret != XCCDF_RESULT_NOT_CHECKEDcxx . . $ XCCDF_RESULT_NOT_CHECKED.) {
1239 xccdf_check_inject_content_refcxx . . $ xccdf_check_inject_content_ref(fa23abb48d445643).(check, content, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1240 break;
1241 }
1242 }
1243 if ((xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t#) ret == XCCDF_RESULT_NOT_CHECKEDcxx . . $ XCCDF_RESULT_NOT_CHECKED.)
1244 message = "None of the check-content-ref elements was resolvable.";
1245
1246 if (role == XCCDF_ROLE_UNSCOREDcxx . . $ XCCDF_ROLE_UNSCORED.)
1247 ret = XCCDF_RESULT_INFORMATIONALcxx . . $ XCCDF_RESULT_INFORMATIONAL.;
1248
1249 xccdf_check_content_ref_iterator_freecxx . . $ xccdf_check_content_ref_iterator_free(30690f049257f900).(content_it);
1250 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(bindings, (oscap_destruct_funccxx . . $ oscap_destruct_func#) xccdf_value_binding_freecxx . . $ xccdf_value_binding_free(97df0146bfa7ea12).);
1251 /* Negate only once */
1252 ret = _resolve_negatecxx . . $ _resolve_negate(7c309ab4c6b863af).(ret, check);
1253 return _xccdf_policy_report_rule_resultcxx . . $ _xccdf_policy_report_rule_result(496bb4a8c3e61667).(policy, result, rule, check, ret, message);
1254 }
1255
1256 /**
1257 * Evaluate the XCCDF item. If it is group, start recursive cycle, otherwise get XCCDF check
1258 * and evaluate it.
1259 * Name collision with xccdf_item -> changed to xccdf_policy_item
1260 */
1261 static int xccdf_policy_item_evaluatecxx . . $ xccdf_policy_item_evaluate(605795c9928edfc2).(struct xccdf_policycxx . . $ xccdf_policy# * policy, struct xccdf_itemcxx . . $ xccdf_item# * item, struct xccdf_resultcxx . . $ xccdf_result# * result, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! parent_selected)
1262 {
1263 struct xccdf_item_iteratorcxx . . $ xccdf_item_iterator# * child_it;
1264 struct xccdf_itemcxx . . $ xccdf_item# * child;
1265 int ret = 0;
1266
1267 xccdf_type_tcxx . . $ xccdf_type_t# itype = xccdf_item_get_typecxx . . $ xccdf_item_get_type(3d8d48c673cd637b).(item);
1268
1269 switch (itype) {
1270 case XCCDF_RULEcxx . . $ XCCDF_RULE.:{
1271 return _xccdf_policy_rule_evaluatecxx . . $ _xccdf_policy_rule_evaluate(2d5f2e6760955a6e).(policy, (struct xccdf_rulecxx . . $ xccdf_rule# *) item, result, parent_selected);
1272 } break;
1273
1274 case XCCDF_GROUPcxx . . $ XCCDF_GROUP.:{
1275 child_it = xccdf_group_get_contentcxx . . $ xccdf_group_get_content(cff1b1d0a9b9d63).((const struct xccdf_groupcxx . . $ xccdf_group# *)item);
1276 while (xccdf_item_iterator_has_morecxx . . $ xccdf_item_iterator_has_more(c8a83ac60f16d388).(child_it)) {
1277 child = xccdf_item_iterator_nextcxx . . $ xccdf_item_iterator_next(73e3c3f4fb48321d).(child_it);
1278 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! is_selected = xccdf_policy_is_item_selectedcxx . . $ xccdf_policy_is_item_selected(556e49a57ec3a724).(policy, xccdf_item_get_idcxx . . $ xccdf_item_get_id(b87246382a73d514).(item));
1279 if (is_selected) {
1280 // See section 7.2.3.3.2 (<xccdf:requires> and <xccdf:conflicts> Elements) of the XCCDF specification.
1281 if (_xccdf_policy_item_is_in_conflictcxx . . $ _xccdf_policy_item_is_in_conflict(b15fd4f3d86d8a47).(policy, item) || !_xccdf_policy_item_has_all_requirementscxx . . $ _xccdf_policy_item_has_all_requirements(b15fd4f3d86d8a47).(policy, item)) {
1282 xccdf_policy_resolve_itemcxx . . $ xccdf_policy_resolve_item(a82616d50c5910f3).(policy, item, falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!);
1283 is_selected = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1284 }
1285 }
1286 ret = xccdf_policy_item_evaluatecxx . . $ xccdf_policy_item_evaluate(605795c9928edfc2).(policy, child, result, parent_selected && is_selected);
1287 if (ret != 0)
1288 break;
1289 }
1290 xccdf_item_iterator_freecxx . . $ xccdf_item_iterator_free(5a27e088a1e93c63).(child_it);
1291 } break;
1292
1293 default:
1294 /* TODO: set warning bad argument and return ? */
1295 assertcxx . . $ `/usr/include/assert.h:50:10`!(false);
1296 return -1;
1297 break;
1298 }
1299
1300 return ret;
1301 }
1302
1303 struct oscap_file_entrycxx . . $ oscap_file_entry# {
1304 char* system_namecxx . . $ oscap_file_entry#system_name.;
1305 char* filecxx . . $ oscap_file_entry#file.;
1306 };
1307
1308 struct oscap_file_entrycxx . . $ oscap_file_entry# *oscap_file_entry_newcxx . . $ oscap_file_entry_new(3941fd61f0563fff).(void)
1309 {
1310 struct oscap_file_entrycxx . . $ oscap_file_entry# *ret = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(struct oscap_file_entrycxx . . $ oscap_file_entry#));
1311 return ret;
1312 }
1313
1314 struct oscap_file_entrycxx . . $ oscap_file_entry# *oscap_file_entry_dupcxx . . $ oscap_file_entry_dup(569301557fcd8d5d).(struct oscap_file_entrycxx . . $ oscap_file_entry# * file_entry)
1315 {
1316 struct oscap_file_entrycxx . . $ oscap_file_entry# *source = (struct oscap_file_entrycxx . . $ oscap_file_entry# *) file_entry;
1317
1318 struct oscap_file_entrycxx . . $ oscap_file_entry# *ret = oscap_file_entry_newcxx . . $ oscap_file_entry_new(3941fd61f0563fff).();
1319 ret->system_namecxx . . $ oscap_file_entry#system_name. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(source->system_namecxx . . $ oscap_file_entry#system_name.);
1320 ret->filecxx . . $ oscap_file_entry#file. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(source->filecxx . . $ oscap_file_entry#file.);
1321
1322 return ret;
1323 }
1324
1325 void oscap_file_entry_freecxx . . $ oscap_file_entry_free(4314c354a27354a7).(struct oscap_file_entrycxx . . $ oscap_file_entry# * entry)
1326 {
1327 freecxx . . $ free(5d22bdacc48458e8).(entry->system_namecxx . . $ oscap_file_entry#system_name.);
1328 freecxx . . $ free(5d22bdacc48458e8).(entry->filecxx . . $ oscap_file_entry#file.);
1329 freecxx . . $ free(5d22bdacc48458e8).(entry);
1330 }
1331
1332 const char* oscap_file_entry_get_systemcxx . . $ oscap_file_entry_get_system(7827612c21abd21f).(struct oscap_file_entrycxx . . $ oscap_file_entry#* entry)
1333 {
1334 return entry->system_namecxx . . $ oscap_file_entry#system_name.;
1335 }
1336
1337 const char* oscap_file_entry_get_filecxx . . $ oscap_file_entry_get_file(7827612c21abd21f).(struct oscap_file_entrycxx . . $ oscap_file_entry#* entry)
1338 {
1339 return entry->filecxx . . $ oscap_file_entry#file.;
1340 }
1341
1342 const struct oscap_file_entrycxx . . $ oscap_file_entry# *oscap_file_entry_iterator_nextcxx . . $ oscap_file_entry_iterator_next(2dd8621e704b2d0b).(struct oscap_file_entry_iteratorcxx . . $ oscap_file_entry_iterator# *it)
1343 {
1344 return oscap_iterator_nextcxx . . $ oscap_iterator_next(4c75051c806960eb).((struct oscap_iteratorcxx . . $ oscap_iterator# *)it);
1345 }
1346
1347 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oscap_file_entry_iterator_has_morecxx . . $ oscap_file_entry_iterator_has_more(126961f4f01d6b48).(struct oscap_file_entry_iteratorcxx . . $ oscap_file_entry_iterator# *it)
1348 {
1349 return oscap_iterator_has_morecxx . . $ oscap_iterator_has_more(63b1de9a5adb9205).((struct oscap_iteratorcxx . . $ oscap_iterator# *)it);
1350 }
1351
1352 void oscap_file_entry_iterator_freecxx . . $ oscap_file_entry_iterator_free(9fa52656bc957f51).(struct oscap_file_entry_iteratorcxx . . $ oscap_file_entry_iterator# *it)
1353 {
1354 oscap_iterator_freecxx . . $ oscap_iterator_free(3cba44c1b7872358).((struct oscap_iteratorcxx . . $ oscap_iterator# *)it);
1355 }
1356
1357 void oscap_file_entry_iterator_resetcxx . . $ oscap_file_entry_iterator_reset(9fa52656bc957f51).(struct oscap_file_entry_iteratorcxx . . $ oscap_file_entry_iterator# *it)
1358 {
1359 oscap_iterator_resetcxx . . $ oscap_iterator_reset(3cba44c1b7872358).((struct oscap_iteratorcxx . . $ oscap_iterator# *)it);
1360 }
1361
1362 struct oscap_file_entry_listcxx . . $ oscap_file_entry_list#* oscap_file_entry_list_newcxx . . $ oscap_file_entry_list_new(bb2a731635899c19).(void)
1363 {
1364 return (struct oscap_file_entry_listcxx . . $ oscap_file_entry_list# *) oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).();
1365 }
1366
1367 static void oscap_file_entry_list_item_destructorcxx . . $ oscap_file_entry_list_item_destructor(5d22bdacc48458e8).(void* item)
1368 {
1369 oscap_file_entry_freecxx . . $ oscap_file_entry_free(4314c354a27354a7).(item);
1370 }
1371
1372 void oscap_file_entry_list_freecxx . . $ oscap_file_entry_list_free(46f5db83064d09fb).(struct oscap_file_entry_listcxx . . $ oscap_file_entry_list#* list)
1373 {
1374 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).((struct oscap_listcxx . . $ oscap_list# *) list, oscap_file_entry_list_item_destructorcxx . . $ oscap_file_entry_list_item_destructor(5d22bdacc48458e8).);
1375 }
1376
1377 struct oscap_file_entry_iteratorcxx . . $ oscap_file_entry_iterator#* oscap_file_entry_list_get_filescxx . . $ oscap_file_entry_list_get_files(f5aaec2ea5fc982f).(struct oscap_file_entry_listcxx . . $ oscap_file_entry_list#* list)
1378 {
1379 return (struct oscap_file_entry_iteratorcxx . . $ oscap_file_entry_iterator# *) oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).((struct oscap_listcxx . . $ oscap_list# *) list);
1380 }
1381
1382 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_file_entry_cmp_funccxx . . $ xccdf_file_entry_cmp_func(838b4d1787e4a177).(void *e1, void *e2)
1383 {
1384 struct oscap_file_entrycxx . . $ oscap_file_entry# *entry1 = (struct oscap_file_entrycxx . . $ oscap_file_entry# *) e1;
1385 struct oscap_file_entrycxx . . $ oscap_file_entry# *entry2 = (struct oscap_file_entrycxx . . $ oscap_file_entry# *) e2;
1386
1387 if (oscap_strcmpcxx . . $ oscap_strcmp(5ae29d726ae57f88).(entry1->system_namecxx . . $ oscap_file_entry#system_name., entry2->system_namecxx . . $ oscap_file_entry#system_name.))
1388 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1389
1390 if (oscap_strcmpcxx . . $ oscap_strcmp(5ae29d726ae57f88).(entry1->filecxx . . $ oscap_file_entry#file., entry2->filecxx . . $ oscap_file_entry#file.))
1391 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1392
1393 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1394 }
1395
1396 static struct oscap_file_entry_listcxx . . $ oscap_file_entry_list# * xccdf_check_get_systems_and_filescxx . . $ xccdf_check_get_systems_and_files(e58349dbf5fb8bf5).(struct xccdf_checkcxx . . $ xccdf_check# * check)
1397 {
1398 struct xccdf_check_iteratorcxx . . $ xccdf_check_iterator# * child_it;
1399 struct xccdf_checkcxx . . $ xccdf_check# * child;
1400 struct xccdf_check_content_ref_iteratorcxx . . $ xccdf_check_content_ref_iterator# * content_it;
1401 struct xccdf_check_content_refcxx . . $ xccdf_check_content_ref# * content;
1402 struct oscap_file_entrycxx . . $ oscap_file_entry# * file_entry;
1403 char * href;
1404 char * system_name;
1405 struct oscap_file_entry_listcxx . . $ oscap_file_entry_list# * files;
1406 struct oscap_file_entry_listcxx . . $ oscap_file_entry_list# * sub_files;
1407
1408 system_name = (char *) xccdf_check_get_systemcxx . . $ xccdf_check_get_system(698a89d24cc1a492).(check);
1409
1410 files = oscap_file_entry_list_newcxx . . $ oscap_file_entry_list_new(bb2a731635899c19).();
1411 if (xccdf_check_get_complexcxx . . $ xccdf_check_get_complex(ceaafcd79241aa30).(check)) {
1412 child_it = xccdf_check_get_childrencxx . . $ xccdf_check_get_children(7ed23a48483b6575).(check);
1413 while (xccdf_check_iterator_has_morecxx . . $ xccdf_check_iterator_has_more(644a620a92cf84a7).(child_it)) {
1414 child = xccdf_check_iterator_nextcxx . . $ xccdf_check_iterator_next(a435bf31c65e745a).(child_it);
1415 sub_files = xccdf_check_get_systems_and_filescxx . . $ xccdf_check_get_systems_and_files(e58349dbf5fb8bf5).(child);
1416
1417 struct oscap_file_entry_iteratorcxx . . $ oscap_file_entry_iterator# *file_it = oscap_file_entry_list_get_filescxx . . $ oscap_file_entry_list_get_files(f5aaec2ea5fc982f).(sub_files);
1418 while (oscap_file_entry_iterator_has_morecxx . . $ oscap_file_entry_iterator_has_more(126961f4f01d6b48).(file_it)) {
1419 file_entry = (struct oscap_file_entrycxx . . $ oscap_file_entry# *) oscap_file_entry_iterator_nextcxx . . $ oscap_file_entry_iterator_next(2dd8621e704b2d0b).(file_it);
1420
1421 if (!oscap_list_containscxx . . $ oscap_list_contains(810ee1985baa5ebe).((struct oscap_listcxx . . $ oscap_list# *)files, (void *) file_entry, (oscap_cmp_funccxx . . $ oscap_cmp_func#) xccdf_file_entry_cmp_funccxx . . $ xccdf_file_entry_cmp_func(838b4d1787e4a177).))
1422 oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).((struct oscap_listcxx . . $ oscap_list# *)files, oscap_file_entry_dupcxx . . $ oscap_file_entry_dup(569301557fcd8d5d).(file_entry));
1423 }
1424 oscap_file_entry_iterator_freecxx . . $ oscap_file_entry_iterator_free(9fa52656bc957f51).(file_it);
1425 oscap_file_entry_list_freecxx . . $ oscap_file_entry_list_free(46f5db83064d09fb).(sub_files);
1426 }
1427 xccdf_check_iterator_freecxx . . $ xccdf_check_iterator_free(dcf67c9af31da2e3).(child_it);
1428 } else {
1429 content_it = xccdf_check_get_content_refscxx . . $ xccdf_check_get_content_refs(5eea252c33793573).(check);
1430 while (xccdf_check_content_ref_iterator_has_morecxx . . $ xccdf_check_content_ref_iterator_has_more(ad48050a2429bee3).(content_it)) {
1431 content = xccdf_check_content_ref_iterator_nextcxx . . $ xccdf_check_content_ref_iterator_next(3e7476af5b698c93).(content_it);
1432 href = (char *) xccdf_check_content_ref_get_hrefcxx . . $ xccdf_check_content_ref_get_href(18edaaea5423ca08).(content);
1433
1434 file_entry = (struct oscap_file_entrycxx . . $ oscap_file_entry# *) oscap_file_entry_newcxx . . $ oscap_file_entry_new(3941fd61f0563fff).();
1435 file_entry->system_namecxx . . $ oscap_file_entry#system_name. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(system_name);
1436 file_entry->filecxx . . $ oscap_file_entry#file. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(href);
1437
1438 if (!oscap_list_containscxx . . $ oscap_list_contains(810ee1985baa5ebe).((struct oscap_listcxx . . $ oscap_list# *) files, file_entry, (oscap_cmp_funccxx . . $ oscap_cmp_func#) xccdf_file_entry_cmp_funccxx . . $ xccdf_file_entry_cmp_func(838b4d1787e4a177).))
1439 oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).((struct oscap_listcxx . . $ oscap_list# *) files, (void *) file_entry);
1440 else
1441 oscap_file_entry_freecxx . . $ oscap_file_entry_free(4314c354a27354a7).((void *) file_entry);
1442 }
1443 xccdf_check_content_ref_iterator_freecxx . . $ xccdf_check_content_ref_iterator_free(30690f049257f900).(content_it);
1444 }
1445
1446 return files;
1447 }
1448
1449 struct oscap_file_entry_listcxx . . $ oscap_file_entry_list# * xccdf_item_get_systems_and_filescxx . . $ xccdf_item_get_systems_and_files(6e7c065411dc8fc2).(struct xccdf_itemcxx . . $ xccdf_item# * item)
1450 {
1451
1452 struct xccdf_item_iteratorcxx . . $ xccdf_item_iterator# * child_it;
1453 struct xccdf_itemcxx . . $ xccdf_item# * child;
1454 struct xccdf_check_iteratorcxx . . $ xccdf_check_iterator# * check_it;
1455 struct xccdf_checkcxx . . $ xccdf_check# * check;
1456 struct oscap_file_entry_listcxx . . $ oscap_file_entry_list# * files;
1457 struct oscap_file_entry_listcxx . . $ oscap_file_entry_list# * sub_files;
1458 struct oscap_file_entrycxx . . $ oscap_file_entry# * file_entry;
1459
1460 xccdf_type_tcxx . . $ xccdf_type_t# itype = xccdf_item_get_typecxx . . $ xccdf_item_get_type(3d8d48c673cd637b).(item);
1461 files = oscap_file_entry_list_newcxx . . $ oscap_file_entry_list_new(bb2a731635899c19).();
1462
1463 switch (itype) {
1464 case XCCDF_RULEcxx . . $ XCCDF_RULE.:
1465 check_it = xccdf_rule_get_checkscxx . . $ xccdf_rule_get_checks(ae88bd66bcaa297a).((struct xccdf_rulecxx . . $ xccdf_rule# *) item);
1466 while(xccdf_check_iterator_has_morecxx . . $ xccdf_check_iterator_has_more(644a620a92cf84a7).(check_it)) {
1467 check = xccdf_check_iterator_nextcxx . . $ xccdf_check_iterator_next(a435bf31c65e745a).(check_it);
1468 sub_files = xccdf_check_get_systems_and_filescxx . . $ xccdf_check_get_systems_and_files(e58349dbf5fb8bf5).(check);
1469
1470 struct oscap_file_entry_iteratorcxx . . $ oscap_file_entry_iterator# *file_it = oscap_file_entry_list_get_filescxx . . $ oscap_file_entry_list_get_files(f5aaec2ea5fc982f).(sub_files);
1471 while (oscap_file_entry_iterator_has_morecxx . . $ oscap_file_entry_iterator_has_more(126961f4f01d6b48).(file_it)) {
1472 file_entry = (struct oscap_file_entrycxx . . $ oscap_file_entry# *) oscap_file_entry_iterator_nextcxx . . $ oscap_file_entry_iterator_next(2dd8621e704b2d0b).(file_it);
1473 if (!oscap_list_containscxx . . $ oscap_list_contains(810ee1985baa5ebe).((struct oscap_listcxx . . $ oscap_list# *) files, file_entry, (oscap_cmp_funccxx . . $ oscap_cmp_func#) xccdf_file_entry_cmp_funccxx . . $ xccdf_file_entry_cmp_func(838b4d1787e4a177).))
1474 oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).((struct oscap_listcxx . . $ oscap_list# *) files, oscap_file_entry_dupcxx . . $ oscap_file_entry_dup(569301557fcd8d5d).(file_entry));
1475 }
1476 oscap_file_entry_iterator_freecxx . . $ oscap_file_entry_iterator_free(9fa52656bc957f51).(file_it);
1477 oscap_file_entry_list_freecxx . . $ oscap_file_entry_list_free(46f5db83064d09fb).(sub_files);
1478 }
1479 xccdf_check_iterator_freecxx . . $ xccdf_check_iterator_free(dcf67c9af31da2e3).(check_it);
1480 break;
1481
1482 case XCCDF_BENCHMARKcxx . . $ XCCDF_BENCHMARK.:
1483 case XCCDF_GROUPcxx . . $ XCCDF_GROUP.:
1484 if (itype == XCCDF_GROUPcxx . . $ XCCDF_GROUP.) child_it = xccdf_group_get_contentcxx . . $ xccdf_group_get_content(cff1b1d0a9b9d63).((const struct xccdf_groupcxx . . $ xccdf_group# *)item);
1485 else child_it = xccdf_benchmark_get_contentcxx . . $ xccdf_benchmark_get_content(630a032521212bb1).((const struct xccdf_benchmarkcxx . . $ xccdf_benchmark# *)item);
1486 while (xccdf_item_iterator_has_morecxx . . $ xccdf_item_iterator_has_more(c8a83ac60f16d388).(child_it)) {
1487 child = xccdf_item_iterator_nextcxx . . $ xccdf_item_iterator_next(73e3c3f4fb48321d).(child_it);
1488 sub_files = xccdf_item_get_systems_and_filescxx . . $ xccdf_item_get_systems_and_files(6e7c065411dc8fc2).(child);
1489
1490 struct oscap_file_entry_iteratorcxx . . $ oscap_file_entry_iterator# *file_it = oscap_file_entry_list_get_filescxx . . $ oscap_file_entry_list_get_files(f5aaec2ea5fc982f).(sub_files);
1491 while (oscap_file_entry_iterator_has_morecxx . . $ oscap_file_entry_iterator_has_more(126961f4f01d6b48).(file_it)) {
1492 file_entry = (struct oscap_file_entrycxx . . $ oscap_file_entry# *) oscap_file_entry_iterator_nextcxx . . $ oscap_file_entry_iterator_next(2dd8621e704b2d0b).(file_it);
1493
1494 if (!oscap_list_containscxx . . $ oscap_list_contains(810ee1985baa5ebe).((struct oscap_listcxx . . $ oscap_list# *) files, file_entry, (oscap_cmp_funccxx . . $ oscap_cmp_func#) xccdf_file_entry_cmp_funccxx . . $ xccdf_file_entry_cmp_func(838b4d1787e4a177).))
1495 oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).((struct oscap_listcxx . . $ oscap_list# *) files, oscap_file_entry_dupcxx . . $ oscap_file_entry_dup(569301557fcd8d5d).(file_entry));
1496 }
1497 oscap_file_entry_iterator_freecxx . . $ oscap_file_entry_iterator_free(9fa52656bc957f51).(file_it);
1498 oscap_file_entry_list_freecxx . . $ oscap_file_entry_list_free(46f5db83064d09fb).(sub_files);
1499 }
1500 xccdf_item_iterator_freecxx . . $ xccdf_item_iterator_free(5a27e088a1e93c63).(child_it);
1501 break;
1502
1503 default:
1504 oscap_file_entry_list_freecxx . . $ oscap_file_entry_list_free(46f5db83064d09fb).(files);
1505 files = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1506 break;
1507 }
1508
1509 return files;
1510 }
1511
1512 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_cmp_funccxx . . $ xccdf_cmp_func(b7a7aa4a824b7595).(const char *s1, const char *s2)
1513 {
1514 return !oscap_strcmpcxx . . $ oscap_strcmp(5ae29d726ae57f88).(s1, s2);
1515 }
1516
1517 static struct oscap_stringlistcxx . . $ oscap_stringlist# * xccdf_check_get_filescxx . . $ xccdf_check_get_files(2174d8acca3680d).(struct xccdf_checkcxx . . $ xccdf_check# * check)
1518 {
1519 struct xccdf_check_iteratorcxx . . $ xccdf_check_iterator# * child_it;
1520 struct xccdf_checkcxx . . $ xccdf_check# * child;
1521 struct xccdf_check_content_ref_iteratorcxx . . $ xccdf_check_content_ref_iterator# * content_it;
1522 struct xccdf_check_content_refcxx . . $ xccdf_check_content_ref# * content;
1523 char * href;
1524 struct oscap_stringlistcxx . . $ oscap_stringlist# * names;
1525 struct oscap_stringlistcxx . . $ oscap_stringlist# * sub_names;
1526
1527 names = oscap_stringlist_newcxx . . $ oscap_stringlist_new(22a991cfbca9a1c).();
1528 if (xccdf_check_get_complexcxx . . $ xccdf_check_get_complex(ceaafcd79241aa30).(check)) {
1529 child_it = xccdf_check_get_childrencxx . . $ xccdf_check_get_children(7ed23a48483b6575).(check);
1530 while (xccdf_check_iterator_has_morecxx . . $ xccdf_check_iterator_has_more(644a620a92cf84a7).(child_it)) {
1531 child = xccdf_check_iterator_nextcxx . . $ xccdf_check_iterator_next(a435bf31c65e745a).(child_it);
1532 sub_names = xccdf_check_get_filescxx . . $ xccdf_check_get_files(2174d8acca3680d).(child);
1533
1534 struct oscap_string_iteratorcxx . . $ oscap_string_iterator# *name_it = oscap_stringlist_get_stringscxx . . $ oscap_stringlist_get_strings(13be827fcd32d2b9).(sub_names);
1535 while (oscap_string_iterator_has_morecxx . . $ oscap_string_iterator_has_more(3724f2faf2515a82).(name_it)) {
1536 href = (char *) oscap_string_iterator_nextcxx . . $ oscap_string_iterator_next(1f2a9ae2534eef34).(name_it);
1537 if (!oscap_list_containscxx . . $ oscap_list_contains(810ee1985baa5ebe).((struct oscap_listcxx . . $ oscap_list# *) names, (void *) href, (oscap_cmp_funccxx . . $ oscap_cmp_func#) xccdf_cmp_funccxx . . $ xccdf_cmp_func(b7a7aa4a824b7595).))
1538 oscap_stringlist_add_stringcxx . . $ oscap_stringlist_add_string(80c12aaea9c014af).(names, href);
1539 }
1540 oscap_string_iterator_freecxx . . $ oscap_string_iterator_free(41a77e9ce361f406).(name_it);
1541 oscap_stringlist_freecxx . . $ oscap_stringlist_free(7df8e35292df4dfb).(sub_names);
1542 }
1543 xccdf_check_iterator_freecxx . . $ xccdf_check_iterator_free(dcf67c9af31da2e3).(child_it);
1544 } else {
1545 content_it = xccdf_check_get_content_refscxx . . $ xccdf_check_get_content_refs(5eea252c33793573).(check);
1546 while (xccdf_check_content_ref_iterator_has_morecxx . . $ xccdf_check_content_ref_iterator_has_more(ad48050a2429bee3).(content_it)) {
1547 content = xccdf_check_content_ref_iterator_nextcxx . . $ xccdf_check_content_ref_iterator_next(3e7476af5b698c93).(content_it);
1548 href = (char *) xccdf_check_content_ref_get_hrefcxx . . $ xccdf_check_content_ref_get_href(18edaaea5423ca08).(content);
1549 if (!oscap_list_containscxx . . $ oscap_list_contains(810ee1985baa5ebe).((struct oscap_listcxx . . $ oscap_list# *) names, href, (oscap_cmp_funccxx . . $ oscap_cmp_func#) xccdf_cmp_funccxx . . $ xccdf_cmp_func(b7a7aa4a824b7595).))
1550 oscap_stringlist_add_stringcxx . . $ oscap_stringlist_add_string(80c12aaea9c014af).(names, href);
1551 }
1552 xccdf_check_content_ref_iterator_freecxx . . $ xccdf_check_content_ref_iterator_free(30690f049257f900).(content_it);
1553 }
1554
1555 return names;
1556 }
1557
1558 struct oscap_stringlistcxx . . $ oscap_stringlist# * xccdf_item_get_filescxx . . $ xccdf_item_get_files(87bb2e49d8fada07).(struct xccdf_itemcxx . . $ xccdf_item# * item)
1559 {
1560
1561 struct xccdf_item_iteratorcxx . . $ xccdf_item_iterator# * child_it;
1562 struct xccdf_itemcxx . . $ xccdf_item# * child;
1563 struct xccdf_check_iteratorcxx . . $ xccdf_check_iterator# * check_it;
1564 struct xccdf_checkcxx . . $ xccdf_check# * check;
1565 struct oscap_stringlistcxx . . $ oscap_stringlist# * names;
1566 struct oscap_stringlistcxx . . $ oscap_stringlist# * sub_names;
1567 char * href;
1568
1569 xccdf_type_tcxx . . $ xccdf_type_t# itype = xccdf_item_get_typecxx . . $ xccdf_item_get_type(3d8d48c673cd637b).(item);
1570 names = oscap_stringlist_newcxx . . $ oscap_stringlist_new(22a991cfbca9a1c).();
1571
1572 switch (itype) {
1573 case XCCDF_RULEcxx . . $ XCCDF_RULE.:
1574 check_it = xccdf_rule_get_checkscxx . . $ xccdf_rule_get_checks(ae88bd66bcaa297a).((struct xccdf_rulecxx . . $ xccdf_rule# *) item);
1575 while(xccdf_check_iterator_has_morecxx . . $ xccdf_check_iterator_has_more(644a620a92cf84a7).(check_it)) {
1576 check = xccdf_check_iterator_nextcxx . . $ xccdf_check_iterator_next(a435bf31c65e745a).(check_it);
1577 sub_names = xccdf_check_get_filescxx . . $ xccdf_check_get_files(2174d8acca3680d).(check);
1578
1579 struct oscap_string_iteratorcxx . . $ oscap_string_iterator# *name_it = oscap_stringlist_get_stringscxx . . $ oscap_stringlist_get_strings(13be827fcd32d2b9).(sub_names);
1580 while (oscap_string_iterator_has_morecxx . . $ oscap_string_iterator_has_more(3724f2faf2515a82).(name_it)) {
1581 href = (char *) oscap_string_iterator_nextcxx . . $ oscap_string_iterator_next(1f2a9ae2534eef34).(name_it);
1582 if (!oscap_list_containscxx . . $ oscap_list_contains(810ee1985baa5ebe).((struct oscap_listcxx . . $ oscap_list# *)names, href, (oscap_cmp_funccxx . . $ oscap_cmp_func#) xccdf_cmp_funccxx . . $ xccdf_cmp_func(b7a7aa4a824b7595).))
1583 oscap_stringlist_add_stringcxx . . $ oscap_stringlist_add_string(80c12aaea9c014af).(names, href);
1584 }
1585 oscap_string_iterator_freecxx . . $ oscap_string_iterator_free(41a77e9ce361f406).(name_it);
1586 oscap_stringlist_freecxx . . $ oscap_stringlist_free(7df8e35292df4dfb).(sub_names);
1587 }
1588 xccdf_check_iterator_freecxx . . $ xccdf_check_iterator_free(dcf67c9af31da2e3).(check_it);
1589 break;
1590
1591 case XCCDF_BENCHMARKcxx . . $ XCCDF_BENCHMARK.:
1592 case XCCDF_GROUPcxx . . $ XCCDF_GROUP.:
1593 if (itype == XCCDF_GROUPcxx . . $ XCCDF_GROUP.) child_it = xccdf_group_get_contentcxx . . $ xccdf_group_get_content(cff1b1d0a9b9d63).((const struct xccdf_groupcxx . . $ xccdf_group# *)item);
1594 else child_it = xccdf_benchmark_get_contentcxx . . $ xccdf_benchmark_get_content(630a032521212bb1).((const struct xccdf_benchmarkcxx . . $ xccdf_benchmark# *)item);
1595 while (xccdf_item_iterator_has_morecxx . . $ xccdf_item_iterator_has_more(c8a83ac60f16d388).(child_it)) {
1596 child = xccdf_item_iterator_nextcxx . . $ xccdf_item_iterator_next(73e3c3f4fb48321d).(child_it);
1597 sub_names = xccdf_item_get_filescxx . . $ xccdf_item_get_files(87bb2e49d8fada07).(child);
1598
1599 struct oscap_string_iteratorcxx . . $ oscap_string_iterator# *name_it = oscap_stringlist_get_stringscxx . . $ oscap_stringlist_get_strings(13be827fcd32d2b9).(sub_names);
1600 while (oscap_string_iterator_has_morecxx . . $ oscap_string_iterator_has_more(3724f2faf2515a82).(name_it)) {
1601 href = (char *) oscap_string_iterator_nextcxx . . $ oscap_string_iterator_next(1f2a9ae2534eef34).(name_it);
1602 if (!oscap_list_containscxx . . $ oscap_list_contains(810ee1985baa5ebe).((struct oscap_listcxx . . $ oscap_list# *)names, href, (oscap_cmp_funccxx . . $ oscap_cmp_func#) xccdf_cmp_funccxx . . $ xccdf_cmp_func(b7a7aa4a824b7595).))
1603 oscap_stringlist_add_stringcxx . . $ oscap_stringlist_add_string(80c12aaea9c014af).(names, href);
1604 }
1605 oscap_string_iterator_freecxx . . $ oscap_string_iterator_free(41a77e9ce361f406).(name_it);
1606 oscap_stringlist_freecxx . . $ oscap_stringlist_free(7df8e35292df4dfb).(sub_names);
1607 }
1608 xccdf_item_iterator_freecxx . . $ xccdf_item_iterator_free(5a27e088a1e93c63).(child_it);
1609 break;
1610
1611 default:
1612 oscap_stringlist_freecxx . . $ oscap_stringlist_free(7df8e35292df4dfb).(names);
1613 names = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1614 break;
1615 }
1616
1617 return names;
1618 }
1619
1620 /***************************************************************************/
1621 /* Public functions.
1622 */
1623
1624 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_model_set_tailoringcxx . . $ xccdf_policy_model_set_tailoring(8231a1379b761ce0).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model, struct xccdf_tailoringcxx . . $ xccdf_tailoring# *tailoring)
1625 {
1626 // Clear cached policies, because we (might) have to resolve differently
1627 // with Tailoring element in place.
1628 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(model->policiescxx . . $ xccdf_policy_model#policies., (oscap_destruct_funccxx . . $ oscap_destruct_func#) xccdf_policy_freecxx . . $ xccdf_policy_free(d81e5bae50d670c2).);
1629 model->policiescxx . . $ xccdf_policy_model#policies. = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).();
1630
1631 xccdf_tailoring_freecxx . . $ xccdf_tailoring_free(b4f0b704104bd93e).(model->tailoringcxx . . $ xccdf_policy_model#tailoring.);
1632 model->tailoringcxx . . $ xccdf_policy_model#tailoring. = tailoring;
1633
1634 if (tailoring)
1635 xccdf_tailoring_resolvecxx . . $ xccdf_tailoring_resolve(371749af73702ffe).(tailoring, xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(model));
1636
1637 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1638 }
1639
1640 struct xccdf_tailoringcxx . . $ xccdf_tailoring# *xccdf_policy_model_get_tailoringcxx . . $ xccdf_policy_model_get_tailoring(635dafb53c61c9dd).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model)
1641 {
1642 return model->tailoringcxx . . $ xccdf_policy_model#tailoring.;
1643 }
1644
1645 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_model_add_cpe_dict_sourcecxx . . $ xccdf_policy_model_add_cpe_dict_source(d030e1cb5de4cb10).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# * model, struct oscap_sourcecxx . . $ oscap_source# *source)
1646 {
1647 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(model);
1648 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(source);
1649
1650 return cpe_session_add_cpe_dict_sourcecxx . . $ cpe_session_add_cpe_dict_source(4af268f3de6d9870).(model->cpecxx . . $ xccdf_policy_model#cpe., source);
1651 }
1652
1653 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_model_add_cpe_dictcxx . . $ xccdf_policy_model_add_cpe_dict(9b4ca63f6c01ad7a).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model, const char * cpe_dict)
1654 {
1655 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(model);
1656 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(cpe_dict);
1657
1658 struct oscap_sourcecxx . . $ oscap_source# *source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(cpe_dict);
1659 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ret = cpe_session_add_cpe_dict_sourcecxx . . $ cpe_session_add_cpe_dict_source(4af268f3de6d9870).(model->cpecxx . . $ xccdf_policy_model#cpe., source);
1660 oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source);
1661 return ret;
1662 }
1663
1664 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_model_add_cpe_lang_model_sourcecxx . . $ xccdf_policy_model_add_cpe_lang_model_source(d030e1cb5de4cb10).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model, struct oscap_sourcecxx . . $ oscap_source# *source)
1665 {
1666 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(model);
1667 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(source);
1668
1669 return cpe_session_add_cpe_lang_model_sourcecxx . . $ cpe_session_add_cpe_lang_model_source(4af268f3de6d9870).(model->cpecxx . . $ xccdf_policy_model#cpe., source);
1670 }
1671
1672 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_model_add_cpe_autodetect_sourcecxx . . $ xccdf_policy_model_add_cpe_autodetect_source(d030e1cb5de4cb10).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model, struct oscap_sourcecxx . . $ oscap_source# *source)
1673 {
1674 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(model);
1675 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(source);
1676
1677 return cpe_session_add_cpe_autodetect_sourcecxx . . $ cpe_session_add_cpe_autodetect_source(4af268f3de6d9870).(model->cpecxx . . $ xccdf_policy_model#cpe., source);
1678 }
1679
1680 struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *xccdf_policy_model_get_cpe_oval_sessionscxx . . $ xccdf_policy_model_get_cpe_oval_sessions(9b554956ed04d75e).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model)
1681 {
1682 return oscap_htable_iterator_newcxx . . $ oscap_htable_iterator_new(81743c99830972e7).(model->cpecxx . . $ xccdf_policy_model#cpe.->oval_sessionscxx . . $ cpe_session#oval_sessions.);
1683 }
1684
1685 struct cpe_sessioncxx . . $ cpe_session# *xccdf_policy_model_get_cpe_sessioncxx . . $ xccdf_policy_model_get_cpe_session(cfdce5f2ac9d5b55).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model)
1686 {
1687 return model->cpecxx . . $ xccdf_policy_model#cpe.;
1688 }
1689
1690 /**
1691 * Get ID of XCCDF Profile that belongs to XCCDF Policy
1692 */
1693 const char * xccdf_policy_get_idcxx . . $ xccdf_policy_get_id(6eb33604fdb7ae98).(struct xccdf_policycxx . . $ xccdf_policy# * policy)
1694 {
1695 if (policy->profilecxx . . $ xccdf_policy#profile. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
1696 return xccdf_profile_get_idcxx . . $ xccdf_profile_get_id(d143a4aa05fc37ce).(xccdf_policy_get_profilecxx . . $ xccdf_policy_get_profile(f562c39304763510).(policy));
1697 else return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1698 }
1699
1700 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!
1701 xccdf_policy_model_register_engine_and_query_callbackcxx . . $ xccdf_policy_model_register_engine_and_query_callback(7fef2e0a0392b6d3).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model, char *sys, xccdf_policy_engine_eval_fncxx . . $ xccdf_policy_engine_eval_fn# eval_fn, void *usr, xccdf_policy_engine_query_fncxx . . $ xccdf_policy_engine_query_fn# query_fn)
1702 {
1703 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(model);
1704 struct xccdf_policy_enginecxx . . $ xccdf_policy_engine# *engine = xccdf_policy_engine_newcxx . . $ xccdf_policy_engine_new(54b196a8acbffd20).(sys, eval_fn, usr, query_fn);
1705 return oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(model->enginescxx . . $ xccdf_policy_model#engines., engine);
1706 }
1707
1708 void xccdf_policy_model_unregister_enginescxx . . $ xccdf_policy_model_unregister_engines(7c84e7be56876a5f).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model, const char *sys)
1709 {
1710 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(model);
1711 if (sys == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
1712 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(model->enginescxx . . $ xccdf_policy_model#engines., (oscap_destruct_funccxx . . $ oscap_destruct_func#) freecxx . . $ free(5d22bdacc48458e8).);
1713 else {
1714 struct oscap_listcxx . . $ oscap_list# *rest = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).();
1715 struct oscap_iteratorcxx . . $ oscap_iterator# *cb_it = oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).(model->enginescxx . . $ xccdf_policy_model#engines.);
1716 while (oscap_iterator_has_morecxx . . $ oscap_iterator_has_more(63b1de9a5adb9205).(cb_it)) {
1717 struct xccdf_policy_enginecxx . . $ xccdf_policy_engine# *engine = oscap_iterator_nextcxx . . $ oscap_iterator_next(4c75051c806960eb).(cb_it);
1718 if (xccdf_policy_engine_filtercxx . . $ xccdf_policy_engine_filter(90adb2dfb41d6248).(engine, sys))
1719 freecxx . . $ free(5d22bdacc48458e8).(engine);
1720 else
1721 oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(rest, engine);
1722 }
1723 oscap_iterator_freecxx . . $ oscap_iterator_free(3cba44c1b7872358).(cb_it);
1724 oscap_list_free0cxx . . $ oscap_list_free0(27ed2064e5aec1b1).(model->enginescxx . . $ xccdf_policy_model#engines.);
1725 model->enginescxx . . $ xccdf_policy_model#engines. = rest;
1726 }
1727 }
1728
1729 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_model_register_start_callbackcxx . . $ xccdf_policy_model_register_start_callback(d5afe8b86bd96298).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# * model, policy_reporter_startcxx . . $ policy_reporter_start# func, void * usr)
1730 {
1731
1732 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(model);
1733 struct reportercxx . . $ reporter# *reporter = reporter_newcxx . . $ reporter_new(862f20392162f96e).(XCCDF_POLICY_OUTCB_STARTcxx . . $ `src/XCCDF_POLICY/xccdf_policy_model_priv.h:33:9`!, func, usr);
1734 return oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(model->callbackscxx . . $ xccdf_policy_model#callbacks., reporter);
1735 }
1736
1737 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_model_register_output_callbackcxx . . $ xccdf_policy_model_register_output_callback(98f486fd53d366e9).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# * model, policy_reporter_outputcxx . . $ policy_reporter_output# func, void * usr)
1738 {
1739
1740 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(model);
1741 struct reportercxx . . $ reporter# *reporter = reporter_newcxx . . $ reporter_new(862f20392162f96e).(XCCDF_POLICY_OUTCB_ENDcxx . . $ `src/XCCDF_POLICY/xccdf_policy_model_priv.h:34:9`!, func, usr);
1742 return oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(model->callbackscxx . . $ xccdf_policy_model#callbacks., reporter);
1743 }
1744
1745 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_model_register_multicheck_callbackcxx . . $ xccdf_policy_model_register_multicheck_callback(89b80f19bc5bc578).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model, policy_reporter_multicheckcxx . . $ policy_reporter_multicheck# func, void *usr)
1746 {
1747 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(model);
1748 struct reportercxx . . $ reporter# *reporter = reporter_newcxx . . $ reporter_new(862f20392162f96e).(XCCDF_POLICY_OUTCB_MULTICHECKcxx . . $ `src/XCCDF_POLICY/xccdf_policy_model_priv.h:35:9`!, func, usr);
1749 return oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(model->callbackscxx . . $ xccdf_policy_model#callbacks., reporter);
1750 }
1751
1752 struct xccdf_resultcxx . . $ xccdf_result# * xccdf_policy_get_result_by_idcxx . . $ xccdf_policy_get_result_by_id(bb71306f61267cbc).(struct xccdf_policycxx . . $ xccdf_policy# * policy, const char * id) {
1753
1754 struct xccdf_result_iteratorcxx . . $ xccdf_result_iterator# * result_it;
1755 struct xccdf_resultcxx . . $ xccdf_result# * result;
1756
1757 result_it = xccdf_policy_get_resultscxx . . $ xccdf_policy_get_results(abcd967dc22e59db).(policy);
1758 while (xccdf_result_iterator_has_morecxx . . $ xccdf_result_iterator_has_more(43a2a759dd12fb20).(result_it)){
1759 result = xccdf_result_iterator_nextcxx . . $ xccdf_result_iterator_next(70fb5f80ce5b82b1).(result_it);
1760 if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(xccdf_result_get_idcxx . . $ xccdf_result_get_id(9b243840ec21a788).(result), id) ){
1761 xccdf_result_iterator_freecxx . . $ xccdf_result_iterator_free(fd5dfb6e0ed10cd3).(result_it);
1762 return result;
1763 }
1764 }
1765 xccdf_result_iterator_freecxx . . $ xccdf_result_iterator_free(fd5dfb6e0ed10cd3).(result_it);
1766 return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1767 }
1768
1769 /***************************************************************************/
1770 /* Constructors of XCCDF POLICY structures xccdf_policy_*<structure>*_new()
1771 * More info in representive header file.
1772 * returns the type of <structure>
1773 */
1774
1775 /**
1776 * New XCCDF Policy model. Create new structure and fill the policies list with
1777 * policy entries that are inherited from XCCDF benchmark Profile elements. For each
1778 * profile element call xccdf_policy_new function.
1779 */
1780 struct xccdf_policy_modelcxx . . $ xccdf_policy_model# * xccdf_policy_model_newcxx . . $ xccdf_policy_model_new(b3d462237ee1830).(struct xccdf_benchmarkcxx . . $ xccdf_benchmark# * benchmark) {
1781
1782 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(benchmark);
1783
1784 struct xccdf_policy_modelcxx . . $ xccdf_policy_model# * model;
1785
1786 model = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct xccdf_policy_modelcxx . . $ xccdf_policy_model#));
1787 if (model == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
1788 return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1789 memsetcxx . . $ memset(d1de1e4fb215f1c6).(model, 0, sizeof(struct xccdf_policy_modelcxx . . $ xccdf_policy_model#));
1790
1791 model->benchmarkcxx . . $ xccdf_policy_model#benchmark. = benchmark;
1792 model->tailoringcxx . . $ xccdf_policy_model#tailoring. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1793 model->policiescxx . . $ xccdf_policy_model#policies. = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).();
1794 model->callbackscxx . . $ xccdf_policy_model#callbacks. = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).();
1795 model->enginescxx . . $ xccdf_policy_model#engines. = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).();
1796
1797 model->cpecxx . . $ xccdf_policy_model#cpe. = cpe_session_newcxx . . $ cpe_session_new(4e53726e2e033d05).();
1798
1799 /* Resolve document */
1800 xccdf_benchmark_resolvecxx . . $ xccdf_benchmark_resolve(9e5458caf3f9d147).(benchmark);
1801 return model;
1802 }
1803
1804 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!
1805 _xccdf_policy_add_selector_internalcxx . . $ _xccdf_policy_add_selector_internal(63b4aa487e490d6e).(struct xccdf_policycxx . . $ xccdf_policy# *policy, struct xccdf_benchmarkcxx . . $ xccdf_benchmark# *benchmark, struct xccdf_selectcxx . . $ xccdf_select# *sel, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! resolve)
1806 {
1807 /* This is the only way, how one can add selector to a policy. */
1808 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! result = oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(policy->selectscxx . . $ xccdf_policy#selects., sel);
1809
1810 struct xccdf_itemcxx . . $ xccdf_item# *item = xccdf_benchmark_get_membercxx . . $ xccdf_benchmark_get_member(51139a28f6959fd9).(benchmark, XCCDF_ITEMcxx . . $ XCCDF_ITEM., xccdf_select_get_itemcxx . . $ xccdf_select_get_item(5bca08d84ffaa667).(sel));
1811 if (item != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1812 /* If selector points to a single item. Update internal dictionary. */
1813 oscap_htable_detachcxx . . $ oscap_htable_detach(f5c7e8ff6c970cd3).(policy->selected_internalcxx . . $ xccdf_policy#selected_internal., xccdf_select_get_itemcxx . . $ xccdf_select_get_item(5bca08d84ffaa667).(sel));
1814 result &= oscap_htable_addcxx . . $ oscap_htable_add(d9abe78f59fa00eb).(policy->selected_internalcxx . . $ xccdf_policy#selected_internal., xccdf_select_get_itemcxx . . $ xccdf_select_get_item(5bca08d84ffaa667).(sel), sel);
1815 if (resolve) {
1816 const struct xccdf_itemcxx . . $ xccdf_item# *parent = xccdf_item_get_parentcxx . . $ xccdf_item_get_parent(b4a609d518f04b24).(item);
1817 /* If we are adding a selector to a top-level XCCDF Group (its parent is the Benchmark),
1818 we have to consider the parent selected even though it is not in
1819 the final selected hashmap. XCCDF Benchmark can't be unselected. */
1820 xccdf_policy_resolve_itemcxx . . $ xccdf_policy_resolve_item(a82616d50c5910f3).(policy, item, (parent == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! || xccdf_item_get_typecxx . . $ xccdf_item_get_type(3d8d48c673cd637b).(parent) == XCCDF_BENCHMARKcxx . . $ XCCDF_BENCHMARK.) ?
1821 truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`! : xccdf_policy_is_item_selectedcxx . . $ xccdf_policy_is_item_selected(556e49a57ec3a724).(policy, xccdf_item_get_idcxx . . $ xccdf_item_get_id(b87246382a73d514).(parent)));
1822 }
1823 return result;
1824 }
1825
1826 /** If the selector doesn't point to an item it can still point to the cluster. */
1827 struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *hit = xccdf_benchmark_get_cluster_itemscxx . . $ xccdf_benchmark_get_cluster_items(8fab0d5eef3ad923).(benchmark, xccdf_select_get_itemcxx . . $ xccdf_select_get_item(5bca08d84ffaa667).(sel));
1828 if (hit == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1829 dWcxx . . $ `src/common/debug_priv.h:62:9`!("Selector ID(%s) does not exist in Benchmark and it will be ignored.", xccdf_select_get_item(sel));
1830 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1831 }
1832 if (!oscap_htable_iterator_has_morecxx . . $ oscap_htable_iterator_has_more(eba4198ab3388c55).(hit)) {
1833 oscap_htable_iterator_freecxx . . $ oscap_htable_iterator_free(e07ea5562ff119bd).(hit);
1834 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1835 }
1836 while (oscap_htable_iterator_has_morecxx . . $ oscap_htable_iterator_has_more(eba4198ab3388c55).(hit)) {
1837 const char *item_id = oscap_htable_iterator_next_keycxx . . $ oscap_htable_iterator_next_key(952d27177769fc02).(hit);
1838 if (item_id == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1839 assertcxx . . $ `/usr/include/assert.h:50:10`!(item_id != NULL);
1840 continue;
1841 }
1842 oscap_htable_detachcxx . . $ oscap_htable_detach(f5c7e8ff6c970cd3).(policy->selected_internalcxx . . $ xccdf_policy#selected_internal., item_id);
1843 result &= oscap_htable_addcxx . . $ oscap_htable_add(d9abe78f59fa00eb).(policy->selected_internalcxx . . $ xccdf_policy#selected_internal., item_id, sel);
1844 }
1845 if (resolve) {
1846 oscap_htable_iterator_resetcxx . . $ oscap_htable_iterator_reset(e07ea5562ff119bd).(hit);
1847 while (oscap_htable_iterator_has_morecxx . . $ oscap_htable_iterator_has_more(eba4198ab3388c55).(hit)) {
1848 item = (struct xccdf_itemcxx . . $ xccdf_item# *) oscap_htable_iterator_next_valuecxx . . $ oscap_htable_iterator_next_value(4e1156670e4376db).(hit);
1849 if (item == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
1850 continue;
1851 const struct xccdf_itemcxx . . $ xccdf_item# *parent = xccdf_item_get_parentcxx . . $ xccdf_item_get_parent(b4a609d518f04b24).(item);
1852 xccdf_policy_resolve_itemcxx . . $ xccdf_policy_resolve_item(a82616d50c5910f3).(policy, item, (parent == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! || xccdf_item_get_typecxx . . $ xccdf_item_get_type(3d8d48c673cd637b).(parent) == XCCDF_BENCHMARKcxx . . $ XCCDF_BENCHMARK.) ?
1853 truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`! : xccdf_policy_is_item_selectedcxx . . $ xccdf_policy_is_item_selected(556e49a57ec3a724).(policy, xccdf_item_get_idcxx . . $ xccdf_item_get_id(b87246382a73d514).(parent)));
1854 }
1855 }
1856 oscap_htable_iterator_freecxx . . $ oscap_htable_iterator_free(e07ea5562ff119bd).(hit);
1857 return result;
1858 }
1859
1860 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!
1861 xccdf_policy_add_selectcxx . . $ xccdf_policy_add_select(7406cf70eba6826a).(struct xccdf_policycxx . . $ xccdf_policy# *policy, struct xccdf_selectcxx . . $ xccdf_select# *sel)
1862 {
1863 struct xccdf_benchmarkcxx . . $ xccdf_benchmark# *benchmark = xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(xccdf_policy_get_modelcxx . . $ xccdf_policy_get_model(f98af4da2524e136).(policy));
1864 return _xccdf_policy_add_selector_internalcxx . . $ _xccdf_policy_add_selector_internal(63b4aa487e490d6e).(policy, benchmark, sel, truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1865 }
1866
1867 static void _xccdf_policy_add_profile_selectorscxx . . $ _xccdf_policy_add_profile_selectors(2d8c765620553d20).(struct xccdf_policycxx . . $ xccdf_policy#* policy, struct xccdf_benchmarkcxx . . $ xccdf_benchmark# *benchmark, struct xccdf_profilecxx . . $ xccdf_profile# *profile) {
1868 if (!profile)
1869 return;
1870
1871 const char *parent_profile_id = xccdf_profile_get_extendscxx . . $ xccdf_profile_get_extends(d143a4aa05fc37ce).(profile);
1872 struct xccdf_profilecxx . . $ xccdf_profile# *parent_profile = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1873
1874 if (parent_profile_id != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1875 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(parent_profile_id, xccdf_profile_get_idcxx . . $ xccdf_profile_get_id(d143a4aa05fc37ce).(profile)) == 0) {
1876 // We are shadowing a profile, we need to get the original profile from
1877 // benchmark directly to avoid an endless loop.
1878 parent_profile = xccdf_benchmark_get_profile_by_idcxx . . $ xccdf_benchmark_get_profile_by_id(34bf61e7e9f7ecd5).(benchmark, parent_profile_id);
1879 }
1880 else {
1881 struct xccdf_policycxx . . $ xccdf_policy# *parent_profile_policy = xccdf_policy_model_get_policy_by_idcxx . . $ xccdf_policy_model_get_policy_by_id(3a48227fe1c1225a).(xccdf_policy_get_modelcxx . . $ xccdf_policy_get_model(f98af4da2524e136).(policy), parent_profile_id);
1882 parent_profile = parent_profile_policy != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! ? xccdf_policy_get_profilecxx . . $ xccdf_policy_get_profile(f562c39304763510).(parent_profile_policy) : NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1883 }
1884 }
1885
1886 // Add selectors from parent profile if any, these selectors should be added
1887 // before selectors from the "real" policy profile are added so that they
1888 // can be overridden.
1889 if (parent_profile)
1890 _xccdf_policy_add_profile_selectorscxx . . $ _xccdf_policy_add_profile_selectors(2d8c765620553d20).(policy, benchmark, parent_profile);
1891
1892 struct xccdf_select_iteratorcxx . . $ xccdf_select_iterator# *sel_it = xccdf_profile_get_selectscxx . . $ xccdf_profile_get_selects(39b227367103f57e).(profile);
1893 /* Iterate through selects in profile */
1894 while (xccdf_select_iterator_has_morecxx . . $ xccdf_select_iterator_has_more(685310f75eef1664).(sel_it)) {
1895 struct xccdf_selectcxx . . $ xccdf_select# *sel = xccdf_select_iterator_nextcxx . . $ xccdf_select_iterator_next(944efed7a3f49b12).(sel_it);
1896 if (sel == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1897 assertcxx . . $ `/usr/include/assert.h:50:10`!(false);
1898 continue;
1899 }
1900
1901 struct xccdf_selectcxx . . $ xccdf_select# *clone = xccdf_select_clonecxx . . $ xccdf_select_clone(e7d392ef5505c82c).(sel);
1902 _xccdf_policy_add_selector_internalcxx . . $ _xccdf_policy_add_selector_internal(63b4aa487e490d6e).(policy, benchmark, clone, falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!);
1903 }
1904 xccdf_select_iterator_freecxx . . $ xccdf_select_iterator_free(ad10dccc2bb9fd31).(sel_it);
1905 }
1906
1907 /**
1908 * Constructor for structure XCCDF Policy. Create the structure and resolve all rules
1909 * from benchmark that are not present in selectors. This step is necessary because of
1910 * default values of groups / rules that can be added to Policy whether or not they have
1911 * their selector. Last step is filling the list of value bindings (see more in
1912 * xccdf_value_binding_proccess).
1913 */
1914 struct xccdf_policycxx . . $ xccdf_policy# * xccdf_policy_newcxx . . $ xccdf_policy_new(975c97c2cbf6e97).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# * model, struct xccdf_profilecxx . . $ xccdf_profile# * profile) {
1915
1916 struct xccdf_policycxx . . $ xccdf_policy# * policy;
1917 struct xccdf_benchmarkcxx . . $ xccdf_benchmark# * benchmark;
1918 struct xccdf_item_iteratorcxx . . $ xccdf_item_iterator# * item_it;
1919 struct xccdf_itemcxx . . $ xccdf_item# * item;
1920
1921 policy = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct xccdf_policycxx . . $ xccdf_policy#));
1922 if (policy == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
1923 return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1924 memsetcxx . . $ memset(d1de1e4fb215f1c6).(policy, 0, sizeof(struct xccdf_policycxx . . $ xccdf_policy#));
1925
1926 policy->profilecxx . . $ xccdf_policy#profile. = profile;
1927 policy->rulescxx . . $ xccdf_policy#rules. = oscap_htable_newcxx . . $ oscap_htable_new(3c1cb2b6f390ad38).();
1928 policy->rules_foundcxx . . $ xccdf_policy#rules_found. = oscap_htable_newcxx . . $ oscap_htable_new(3c1cb2b6f390ad38).();
1929 policy->skip_rulescxx . . $ xccdf_policy#skip_rules. = oscap_htable_newcxx . . $ oscap_htable_new(3c1cb2b6f390ad38).();
1930 policy->selectscxx . . $ xccdf_policy#selects. = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).();
1931 policy->valuescxx . . $ xccdf_policy#values. = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).();
1932 policy->resultscxx . . $ xccdf_policy#results. = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).();
1933
1934 policy->selected_internalcxx . . $ xccdf_policy#selected_internal. = oscap_htable_newcxx . . $ oscap_htable_new(3c1cb2b6f390ad38).();
1935 policy->selected_finalcxx . . $ xccdf_policy#selected_final. = oscap_htable_newcxx . . $ oscap_htable_new(3c1cb2b6f390ad38).();
1936 policy->refine_rules_internalcxx . . $ xccdf_policy#refine_rules_internal. = oscap_htable_newcxx . . $ oscap_htable_new(3c1cb2b6f390ad38).();
1937 policy->modelcxx . . $ xccdf_policy#model. = model;
1938
1939 policy->reference_filtercxx . . $ xccdf_policy#reference_filter..activecxx . . $ xccdf_policy#$anonymous_type_0#active. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1940 policy->reference_filtercxx . . $ xccdf_policy#reference_filter..hrefcxx . . $ xccdf_policy#$anonymous_type_0#href. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1941 policy->reference_filtercxx . . $ xccdf_policy#reference_filter..titlecxx . . $ xccdf_policy#$anonymous_type_0#title. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1942
1943 benchmark = xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(model);
1944
1945 if (profile) {
1946 _xccdf_policy_add_profile_selectorscxx . . $ _xccdf_policy_add_profile_selectors(2d8c765620553d20).(policy, benchmark, profile);
1947 xccdf_policy_add_profile_refine_rulescxx . . $ xccdf_policy_add_profile_refine_rules(2d8c765620553d20).(policy, benchmark, profile);
1948 }
1949
1950 /* Iterate through items in benchmark and resolve rules */
1951 item_it = xccdf_benchmark_get_contentcxx . . $ xccdf_benchmark_get_content(630a032521212bb1).(benchmark);
1952 while (xccdf_item_iterator_has_morecxx . . $ xccdf_item_iterator_has_more(c8a83ac60f16d388).(item_it)) {
1953 item = xccdf_item_iterator_nextcxx . . $ xccdf_item_iterator_next(73e3c3f4fb48321d).(item_it);
1954 xccdf_policy_resolve_itemcxx . . $ xccdf_policy_resolve_item(a82616d50c5910f3).(policy, item, truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1955 }
1956 xccdf_item_iterator_freecxx . . $ xccdf_item_iterator_free(5a27e088a1e93c63).(item_it);
1957 policy->show_rule_detailscxx . . $ xccdf_policy#show_rule_details. = model->show_rule_detailscxx . . $ xccdf_policy_model#show_rule_details.;
1958 return policy;
1959 }
1960
1961 /**
1962 * Constructor for structure XCCDF Policy Value bindings
1963 */
1964 struct xccdf_value_bindingcxx . . $ xccdf_value_binding# * xccdf_value_binding_newcxx . . $ xccdf_value_binding_new(4ab1590557d95e6a).() {
1965
1966 struct xccdf_value_bindingcxx . . $ xccdf_value_binding# * binding;
1967
1968 /* Initialization */
1969 binding = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct xccdf_value_bindingcxx . . $ xccdf_value_binding#));
1970 if (binding == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
1971 return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1972 memsetcxx . . $ memset(d1de1e4fb215f1c6).(binding, 0, sizeof(struct xccdf_value_bindingcxx . . $ xccdf_value_binding#));
1973
1974 binding->namecxx . . $ xccdf_value_binding#name. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1975 binding->typecxx . . $ xccdf_value_binding#type. = 0;
1976 binding->valuecxx . . $ xccdf_value_binding#value. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1977 binding->setvaluecxx . . $ xccdf_value_binding#setvalue. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1978 binding->operatorcxx . . $ xccdf_value_binding#operator. = XCCDF_OPERATOR_EQUALScxx . . $ XCCDF_OPERATOR_EQUALS.;
1979
1980 return binding;
1981 }
1982
1983 /***************************************************************************/
1984
1985 /**
1986 * If policy has the select specified by item_id return the select, NULL otherwise
1987 */
1988 struct xccdf_selectcxx . . $ xccdf_select# * xccdf_policy_get_select_by_idcxx . . $ xccdf_policy_get_select_by_id(16ffa0f3d08abac0).(struct xccdf_policycxx . . $ xccdf_policy# * policy, const char *item_id)
1989 {
1990 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(policy);
1991 return oscap_htable_getcxx . . $ oscap_htable_get(f5c7e8ff6c970cd3).(policy->selected_internalcxx . . $ xccdf_policy#selected_internal., item_id);
1992 }
1993
1994
1995 struct xccdf_select_iteratorcxx . . $ xccdf_select_iterator# * xccdf_policy_get_selected_rulescxx . . $ xccdf_policy_get_selected_rules(8c20b0067b829e32).(struct xccdf_policycxx . . $ xccdf_policy# * policy) {
1996
1997 return (struct xccdf_select_iteratorcxx . . $ xccdf_select_iterator# *) oscap_iterator_new_filtercxx . . $ oscap_iterator_new_filter(412a5e5f37b98023).( policy->selectscxx . . $ xccdf_policy#selects.,
1998 (oscap_filter_funccxx . . $ oscap_filter_func#) xccdf_policy_filter_selectedcxx . . $ xccdf_policy_filter_selected(838b4d1787e4a177).,
1999 policy);
2000 }
2001
2002 /**
2003 * Get Policy from Policy model by it's id.
2004 */
2005 struct xccdf_policycxx . . $ xccdf_policy# * xccdf_policy_model_get_policy_by_idcxx . . $ xccdf_policy_model_get_policy_by_id(3a48227fe1c1225a).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# * policy_model, const char * id)
2006 {
2007 struct xccdf_policycxx . . $ xccdf_policy# *policy = xccdf_policy_model_get_existing_policy_by_idcxx . . $ xccdf_policy_model_get_existing_policy_by_id(3a48227fe1c1225a).(policy_model, id);
2008 if (policy != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
2009 return policy;
2010 }
2011
2012 policy = xccdf_policy_model_create_policy_by_idcxx . . $ xccdf_policy_model_create_policy_by_id(3a48227fe1c1225a).(policy_model, id);
2013 if (policy != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
2014 oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(policy_model->policiescxx . . $ xccdf_policy_model#policies., policy);
2015 return policy;
2016 }
2017
2018 /**
2019 * Resolve benchmark - apply all refine_rules to the benchmark items.
2020 * Beware ! Benchmark properties will be changed ! For discarding changes you have to load
2021 * benchmark from XML file again.
2022 */
2023 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_resolvecxx . . $ xccdf_policy_resolve(11f15227c042e923).(struct xccdf_policycxx . . $ xccdf_policy# * policy)
2024 {
2025
2026 struct xccdf_refine_rule_iteratorcxx . . $ xccdf_refine_rule_iterator# * r_rule_it;
2027 struct xccdf_refine_rulecxx . . $ xccdf_refine_rule# * r_rule;
2028 struct xccdf_itemcxx . . $ xccdf_item# * item;
2029
2030 struct xccdf_policy_modelcxx . . $ xccdf_policy_model# * policy_model = xccdf_policy_get_modelcxx . . $ xccdf_policy_get_model(f98af4da2524e136).(policy);
2031 struct xccdf_benchmarkcxx . . $ xccdf_benchmark# * benchmark = xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(policy_model);
2032 struct xccdf_profilecxx . . $ xccdf_profile# * profile = xccdf_policy_get_profilecxx . . $ xccdf_policy_get_profile(f562c39304763510).(policy);
2033
2034 /* Proccess refine rules; Changing Rules and Groups */
2035 r_rule_it = xccdf_profile_get_refine_rulescxx . . $ xccdf_profile_get_refine_rules(6293f31d601f739c).(profile);
2036 while (xccdf_refine_rule_iterator_has_morecxx . . $ xccdf_refine_rule_iterator_has_more(3336035403056a8a).(r_rule_it)) {
2037 r_rule = xccdf_refine_rule_iterator_nextcxx . . $ xccdf_refine_rule_iterator_next(edffddc607d0b594).(r_rule_it);
2038 item = xccdf_benchmark_get_itemcxx . . $ xccdf_benchmark_get_item(daeed5940f8c8cf2).(benchmark, xccdf_refine_rule_get_itemcxx . . $ xccdf_refine_rule_get_item(11f7a48e00d52e4a).(r_rule));
2039 if (item != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
2040 /* Proccess refine rule appliement */
2041 /* In r_rule we have refine rule that match - no more then one !*/
2042 if (xccdf_item_get_typecxx . . $ xccdf_item_get_type(3d8d48c673cd637b).(item) == XCCDF_GROUPcxx . . $ XCCDF_GROUP.) {
2043 /* Perform check of weight attribute - ignore other attributes */
2044 if (xccdf_refine_rule_weight_definedcxx . . $ xccdf_refine_rule_weight_defined(9bc8e32f099f2c6e).(r_rule)) {
2045 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XCCDFcxx . . $ `src/common/public/oscap_error.h:62:9`!, "'Weight' attribute not specified, only 'weight' attribute applies to groups items");
2046 xccdf_refine_rule_iterator_freecxx . . $ xccdf_refine_rule_iterator_free(744e48aec72399b2).(r_rule_it);
2047 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
2048 }
2049 else {
2050 /* Apply the rule changes */
2051 xccdf_group_set_weightcxx . . $ xccdf_group_set_weight(fb3acf3de1adc580).((struct xccdf_groupcxx . . $ xccdf_group# *) item, xccdf_refine_rule_get_weightcxx . . $ xccdf_refine_rule_get_weight(8a3938df3dddaee0).(r_rule) );
2052 }
2053
2054 } else if (xccdf_item_get_typecxx . . $ xccdf_item_get_type(3d8d48c673cd637b).(item) == XCCDF_RULEcxx . . $ XCCDF_RULE.) {
2055 /* Perform all changes in rule */
2056 if ((int)xccdf_refine_rule_get_rolecxx . . $ xccdf_refine_rule_get_role(a0568139d0ca7124).(r_rule) > 0)
2057 xccdf_rule_set_rolecxx . . $ xccdf_rule_set_role(5a2c689977d86227).((struct xccdf_rulecxx . . $ xccdf_rule# *) item, xccdf_refine_rule_get_rolecxx . . $ xccdf_refine_rule_get_role(a0568139d0ca7124).(r_rule));
2058 if ((int)xccdf_refine_rule_get_severitycxx . . $ xccdf_refine_rule_get_severity(838e81374fa6e3ad).(r_rule) != XCCDF_LEVEL_NOT_DEFINEDcxx . . $ XCCDF_LEVEL_NOT_DEFINED.)
2059 xccdf_rule_set_severitycxx . . $ xccdf_rule_set_severity(c5ef94ba7d6974a3).((struct xccdf_rulecxx . . $ xccdf_rule# *) item, xccdf_refine_rule_get_severitycxx . . $ xccdf_refine_rule_get_severity(838e81374fa6e3ad).(r_rule));
2060
2061 } else {}/* TODO oscap_err ? */;
2062
2063 } else {
2064 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XCCDFcxx . . $ `src/common/public/oscap_error.h:62:9`!, "Refine rule item points to nonexisting XCCDF item");
2065 xccdf_refine_rule_iterator_freecxx . . $ xccdf_refine_rule_iterator_free(744e48aec72399b2).(r_rule_it);
2066 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
2067 }
2068 }
2069 xccdf_refine_rule_iterator_freecxx . . $ xccdf_refine_rule_iterator_free(744e48aec72399b2).(r_rule_it);
2070
2071 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
2072 }
2073
2074 static void xccdf_policy_add_final_setvaluecxx . . $ xccdf_policy_add_final_setvalue(2e96752498ef13c9).(struct xccdf_policycxx . . $ xccdf_policy# *policy, struct xccdf_valuecxx . . $ xccdf_value# *value, struct xccdf_resultcxx . . $ xccdf_result# *result)
2075 {
2076 const char *idref = xccdf_value_get_idcxx . . $ xccdf_value_get_id(7dce63a6a4cb9377).(value);
2077 const char *content = xccdf_policy_get_value_of_itemcxx . . $ xccdf_policy_get_value_of_item(a5cb590029f1e3ee).(policy, xccdf_value_to_itemcxx . . $ xccdf_value_to_item(8177c121c599be72).(value));
2078
2079 struct xccdf_setvaluecxx . . $ xccdf_setvalue# *setvalue = xccdf_setvalue_newcxx . . $ xccdf_setvalue_new(7ea2a52b87df379d).();
2080 xccdf_setvalue_set_itemcxx . . $ xccdf_setvalue_set_item(cd43b182e35143a4).(setvalue, idref);
2081 xccdf_setvalue_set_valuecxx . . $ xccdf_setvalue_set_value(cd43b182e35143a4).(setvalue, content);
2082
2083 xccdf_result_add_setvaluecxx . . $ xccdf_result_add_setvalue(f2ef40b9fceb2834).(result, setvalue);
2084 }
2085
2086 static void xccdf_policy_add_final_setvaluescxx . . $ xccdf_policy_add_final_setvalues(1612a5c8b6f6b7b0).(struct xccdf_policycxx . . $ xccdf_policy# *policy, struct xccdf_itemcxx . . $ xccdf_item# *item, struct xccdf_resultcxx . . $ xccdf_result# *result)
2087 {
2088 struct xccdf_item_iteratorcxx . . $ xccdf_item_iterator# *child_it = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
2089 struct xccdf_value_iteratorcxx . . $ xccdf_value_iterator# *value_it = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
2090
2091 xccdf_type_tcxx . . $ xccdf_type_t# itype = xccdf_item_get_typecxx . . $ xccdf_item_get_type(3d8d48c673cd637b).(item);
2092 switch (itype) {
2093 case XCCDF_GROUPcxx . . $ XCCDF_GROUP.:
2094 value_it = xccdf_group_get_valuescxx . . $ xccdf_group_get_values(e98be977e40fa4cf).(xccdf_item_to_groupcxx . . $ xccdf_item_to_group(7b8647c4cae09ecc).(item));
2095 while (xccdf_value_iterator_has_morecxx . . $ xccdf_value_iterator_has_more(bc25df683f527b01).(value_it)) {
2096 struct xccdf_valuecxx . . $ xccdf_value# *value = xccdf_value_iterator_nextcxx . . $ xccdf_value_iterator_next(7466feec91220de5).(value_it);
2097 xccdf_policy_add_final_setvaluecxx . . $ xccdf_policy_add_final_setvalue(2e96752498ef13c9).(policy, value, result);
2098 }
2099 xccdf_value_iterator_freecxx . . $ xccdf_value_iterator_free(ba449c68b21eaa11).(value_it);
2100
2101 child_it = xccdf_group_get_contentcxx . . $ xccdf_group_get_content(cff1b1d0a9b9d63).(xccdf_item_to_groupcxx . . $ xccdf_item_to_group(7b8647c4cae09ecc).(item));
2102 while (xccdf_item_iterator_has_morecxx . . $ xccdf_item_iterator_has_more(c8a83ac60f16d388).(child_it)) {
2103 struct xccdf_itemcxx . . $ xccdf_item# *child = xccdf_item_iterator_nextcxx . . $ xccdf_item_iterator_next(73e3c3f4fb48321d).(child_it);
2104 xccdf_policy_add_final_setvaluescxx . . $ xccdf_policy_add_final_setvalues(1612a5c8b6f6b7b0).(policy, child, result);
2105 }
2106 xccdf_item_iterator_freecxx . . $ xccdf_item_iterator_free(5a27e088a1e93c63).(child_it);
2107 break;
2108 case XCCDF_BENCHMARKcxx . . $ XCCDF_BENCHMARK.:
2109 value_it = xccdf_benchmark_get_valuescxx . . $ xccdf_benchmark_get_values(2a6ced3aecb31917).(xccdf_item_to_benchmarkcxx . . $ xccdf_item_to_benchmark(670be6b45aa1b2de).(item));
2110 while (xccdf_value_iterator_has_morecxx . . $ xccdf_value_iterator_has_more(bc25df683f527b01).(value_it)) {
2111 struct xccdf_valuecxx . . $ xccdf_value# *value = xccdf_value_iterator_nextcxx . . $ xccdf_value_iterator_next(7466feec91220de5).(value_it);
2112 xccdf_policy_add_final_setvaluecxx . . $ xccdf_policy_add_final_setvalue(2e96752498ef13c9).(policy, value, result);
2113 }
2114 xccdf_value_iterator_freecxx . . $ xccdf_value_iterator_free(ba449c68b21eaa11).(value_it);
2115
2116 child_it = xccdf_benchmark_get_contentcxx . . $ xccdf_benchmark_get_content(630a032521212bb1).(xccdf_item_to_benchmarkcxx . . $ xccdf_item_to_benchmark(670be6b45aa1b2de).(item));
2117 while (xccdf_item_iterator_has_morecxx . . $ xccdf_item_iterator_has_more(c8a83ac60f16d388).(child_it)) {
2118 struct xccdf_itemcxx . . $ xccdf_item# *child = xccdf_item_iterator_nextcxx . . $ xccdf_item_iterator_next(73e3c3f4fb48321d).(child_it);
2119 xccdf_policy_add_final_setvaluescxx . . $ xccdf_policy_add_final_setvalues(1612a5c8b6f6b7b0).(policy, child, result);
2120 }
2121 xccdf_item_iterator_freecxx . . $ xccdf_item_iterator_free(5a27e088a1e93c63).(child_it);
2122 break;
2123
2124 default:
2125 break;
2126 }
2127 }
2128
2129 /**
2130 * Evaluate XCCDF Policy
2131 * Iterate through Benchmark items and evaluate one by one by calling
2132 * callback for checking system that is defined by particular rules
2133 * Callbacks for checking systems have to be defined before calling this function, otherwise
2134 * rules would not be evaluated and process ends with error.
2135 */
2136 struct xccdf_resultcxx . . $ xccdf_result# * xccdf_policy_evaluatecxx . . $ xccdf_policy_evaluate(93b250fa94f0dc8e).(struct xccdf_policycxx . . $ xccdf_policy# * policy)
2137 {
2138 struct xccdf_benchmarkcxx . . $ xccdf_benchmark# * benchmark;
2139 int ret = -1;
2140 const char * doc_version = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
2141
2142 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(policy);
2143
2144 /* Add result to policy */
2145 struct xccdf_resultcxx . . $ xccdf_result# * result = xccdf_result_newcxx . . $ xccdf_result_new(619d03edcb8ef9cb).();
2146
2147 xccdf_result_set_start_time_currentcxx . . $ xccdf_result_set_start_time_current(d573a91df5d5af14).(result);
2148 xccdf_result_set_test_systemcxx . . $ xccdf_result_set_test_system(2deabb2a41c12da7).(result, "cpe:/a:redhat:openscap:" OPENSCAP_VERSIONcxx . . $ `build/config.h:4:9`!);
2149
2150 /** Set ID of TestResult */
2151 char *id = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
2152 if ((xccdf_policy_get_profilecxx . . $ xccdf_policy_get_profile(f562c39304763510).(policy) != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) && (xccdf_profile_get_idcxx . . $ xccdf_profile_get_id(d143a4aa05fc37ce).(xccdf_policy_get_profilecxx . . $ xccdf_policy_get_profile(f562c39304763510).(policy)) != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)) {
2153 id = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(xccdf_profile_get_idcxx . . $ xccdf_profile_get_id(d143a4aa05fc37ce).(xccdf_policy_get_profilecxx . . $ xccdf_policy_get_profile(f562c39304763510).(policy)));
2154 xccdf_result_set_profilecxx . . $ xccdf_result_set_profile(2deabb2a41c12da7).(result, id);
2155 } else {
2156 id = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).("default-profile");
2157 }
2158
2159 dIcxx . . $ `src/common/debug_priv.h:61:9`!("Evaluating a XCCDF policy with selected '%s' profile.", id);
2160
2161 /* Get all constant information */
2162 benchmark = xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(xccdf_policy_get_modelcxx . . $ xccdf_policy_get_model(f98af4da2524e136).(policy));
2163 const struct xccdf_version_infocxx . . $ xccdf_version_info#* version_info = xccdf_benchmark_get_schema_versioncxx . . $ xccdf_benchmark_get_schema_version(d71c39bb737b7106).(benchmark);
2164 doc_version = xccdf_version_info_get_versioncxx . . $ xccdf_version_info_get_version(1e170957141ea993).(version_info);
2165
2166 const char *rid_prefix;
2167 #ifdef __USE_GNUcxx . . $ `<external>/18206667465210621810/features.h:430:10`!
2168 if (strverscmpcxx . . $ strverscmp(5ae29d726ae57f88).("1.2", doc_version) >= 0)
2169 #else
2170 if (strcmp("1.2", doc_version) >= 0)
2171 #endif
2172 {
2173 // we have to enforce a certain type of ids for XCCDF 1.2+
2174 rid_prefix = "xccdf_org.open-scap_testresult_";
2175 } else {
2176 // previous behaviour for backwards compatibility
2177 rid_prefix = "OSCAP-Test-";
2178 }
2179 const size_t rid_len = strlencxx . . $ strlen(751346f8406fd082).(rid_prefix) + strlencxx . . $ strlen(751346f8406fd082).(id) + 1; // + 1 for terminating '\0'
2180 char *rid = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(rid_len);
2181 snprintfcxx . . $ snprintf(ea502d73e74c754c).(rid, rid_len, "%s%s", rid_prefix, id);
2182 xccdf_result_set_idcxx . . $ xccdf_result_set_id(2deabb2a41c12da7).(result, rid);
2183 freecxx . . $ free(5d22bdacc48458e8).(rid);
2184
2185 freecxx . . $ free(5d22bdacc48458e8).(id);
2186
2187 /** We need to process document top-down order.
2188 * See conflicts/requires and Item Processing Algorithm */
2189 struct xccdf_item_iteratorcxx . . $ xccdf_item_iterator# *item_it = xccdf_benchmark_get_contentcxx . . $ xccdf_benchmark_get_content(630a032521212bb1).(benchmark);
2190 while (xccdf_item_iterator_has_morecxx . . $ xccdf_item_iterator_has_more(c8a83ac60f16d388).(item_it)) {
2191 struct xccdf_itemcxx . . $ xccdf_item# *item = xccdf_item_iterator_nextcxx . . $ xccdf_item_iterator_next(73e3c3f4fb48321d).(item_it);
2192 ret = xccdf_policy_item_evaluatecxx . . $ xccdf_policy_item_evaluate(605795c9928edfc2).(policy, item, result, truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
2193 if (ret == -1) {
2194 xccdf_item_iterator_freecxx . . $ xccdf_item_iterator_free(5a27e088a1e93c63).(item_it);
2195 xccdf_result_freecxx . . $ xccdf_result_free(731f9fbfcaef207c).(result);
2196 return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
2197 }
2198 if (ret != 0)
2199 break;
2200 }
2201 xccdf_item_iterator_freecxx . . $ xccdf_item_iterator_free(5a27e088a1e93c63).(item_it);
2202
2203 struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *rit = oscap_htable_iterator_newcxx . . $ oscap_htable_iterator_new(81743c99830972e7).(policy->rulescxx . . $ xccdf_policy#rules.);
2204 while (oscap_htable_iterator_has_morecxx . . $ oscap_htable_iterator_has_more(eba4198ab3388c55).(rit)) {
2205 const char *rule_id = oscap_htable_iterator_next_keycxx . . $ oscap_htable_iterator_next_key(952d27177769fc02).(rit);
2206 if (oscap_htable_getcxx . . $ oscap_htable_get(f5c7e8ff6c970cd3).(policy->rules_foundcxx . . $ xccdf_policy#rules_found., rule_id) == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
2207 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XCCDFcxx . . $ `src/common/public/oscap_error.h:62:9`!,
2208 "Rule '%s' not found in selected profile.", rule_id);
2209 oscap_htable_iterator_freecxx . . $ oscap_htable_iterator_free(e07ea5562ff119bd).(rit);
2210 return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
2211 }
2212 }
2213 oscap_htable_iterator_freecxx . . $ oscap_htable_iterator_free(e07ea5562ff119bd).(rit);
2214
2215 xccdf_policy_add_final_setvaluescxx . . $ xccdf_policy_add_final_setvalues(1612a5c8b6f6b7b0).(policy, xccdf_benchmark_to_itemcxx . . $ xccdf_benchmark_to_item(35d9a9a789e4e4ae).(benchmark), result);
2216
2217 struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *it = oscap_htable_iterator_newcxx . . $ oscap_htable_iterator_new(81743c99830972e7).(policy->modelcxx . . $ xccdf_policy#model.->cpecxx . . $ xccdf_policy_model#cpe.->applicable_platformscxx . . $ cpe_session#applicable_platforms.);
2218 while (oscap_htable_iterator_has_morecxx . . $ oscap_htable_iterator_has_more(eba4198ab3388c55).(it)) {
2219 const char *key = oscap_htable_iterator_next_keycxx . . $ oscap_htable_iterator_next_key(952d27177769fc02).(it);
2220 xccdf_result_add_applicable_platformcxx . . $ xccdf_result_add_applicable_platform(2deabb2a41c12da7).(result, key);
2221 }
2222 oscap_htable_iterator_freecxx . . $ oscap_htable_iterator_free(e07ea5562ff119bd).(it);
2223
2224 xccdf_policy_add_resultcxx . . $ xccdf_policy_add_result(f4ee17754169c3e6).(policy, result);
2225
2226 xccdf_result_set_end_time_currentcxx . . $ xccdf_result_set_end_time_current(d573a91df5d5af14).(result);
2227
2228 return result;
2229 }
2230
2231 struct xccdf_scorecxx . . $ xccdf_score# * xccdf_policy_get_scorecxx . . $ xccdf_policy_get_score(ccecc07d9e5e436f).(struct xccdf_policycxx . . $ xccdf_policy# * policy, struct xccdf_resultcxx . . $ xccdf_result# * test_result, const char * scsystem)
2232 {
2233 struct xccdf_benchmarkcxx . . $ xccdf_benchmark# * benchmark = xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(xccdf_policy_get_modelcxx . . $ xccdf_policy_get_model(f98af4da2524e136).(policy));
2234 return xccdf_result_calculate_scorecxx . . $ xccdf_result_calculate_score(8cf0e8d85d748892).(test_result, (struct xccdf_itemcxx . . $ xccdf_item# *) benchmark, scsystem);
2235 }
2236
2237 int xccdf_policy_recalculate_scorecxx . . $ xccdf_policy_recalculate_score(c13e896f71b5e244).(struct xccdf_policycxx . . $ xccdf_policy# * policy, struct xccdf_resultcxx . . $ xccdf_result# * test_result)
2238 {
2239 struct xccdf_benchmarkcxx . . $ xccdf_benchmark# * benchmark = xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(xccdf_policy_get_modelcxx . . $ xccdf_policy_get_model(f98af4da2524e136).(policy));
2240 return xccdf_result_recalculate_scorescxx . . $ xccdf_result_recalculate_scores(496dadfa59822415).(test_result, (struct xccdf_itemcxx . . $ xccdf_item# *) benchmark);
2241 }
2242
2243 const char *xccdf_policy_get_value_of_itemcxx . . $ xccdf_policy_get_value_of_item(a5cb590029f1e3ee).(struct xccdf_policycxx . . $ xccdf_policy# * policy, struct xccdf_itemcxx . . $ xccdf_item# * item)
2244 {
2245 struct xccdf_profilecxx . . $ xccdf_profile# * profile = xccdf_policy_get_profilecxx . . $ xccdf_policy_get_profile(f562c39304763510).(policy);
2246 const char *selector = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
2247
2248 if (profile != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
2249 /* Get set_value for this item */
2250 struct xccdf_setvaluecxx . . $ xccdf_setvalue# *s_value = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
2251 struct xccdf_setvaluecxx . . $ xccdf_setvalue# *last_s_value = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
2252 struct xccdf_setvalue_iteratorcxx . . $ xccdf_setvalue_iterator# *s_value_it = xccdf_profile_get_setvaluescxx . . $ xccdf_profile_get_setvalues(2858520f7d7fac8c).(profile);
2253 while (xccdf_setvalue_iterator_has_morecxx . . $ xccdf_setvalue_iterator_has_more(3ec70e5e2abc17db).(s_value_it)) {
2254 s_value = xccdf_setvalue_iterator_nextcxx . . $ xccdf_setvalue_iterator_next(753fc4cd25f5e085).(s_value_it);
2255 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(xccdf_setvalue_get_itemcxx . . $ xccdf_setvalue_get_item(b6c7ccbe9a2081b7).(s_value), xccdf_value_get_idcxx . . $ xccdf_value_get_id(7dce63a6a4cb9377).((struct xccdf_valuecxx . . $ xccdf_value# *) item)) == 0)
2256 last_s_value = s_value;
2257 }
2258 xccdf_setvalue_iterator_freecxx . . $ xccdf_setvalue_iterator_free(88ac5f99059bb7a3).(s_value_it);
2259 if (last_s_value != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
2260 return xccdf_setvalue_get_valuecxx . . $ xccdf_setvalue_get_value(b6c7ccbe9a2081b7).(last_s_value);
2261
2262 /* We don't have set-value in profile, look for refine-value */
2263 struct xccdf_refine_value_iteratorcxx . . $ xccdf_refine_value_iterator# *r_value_it = xccdf_profile_get_refine_valuescxx . . $ xccdf_profile_get_refine_values(d46be7e16f877ffa).(profile);
2264 while (xccdf_refine_value_iterator_has_morecxx . . $ xccdf_refine_value_iterator_has_more(7ad4a4ce170291e7).(r_value_it)) {
2265 struct xccdf_refine_valuecxx . . $ xccdf_refine_value# *r_value = xccdf_refine_value_iterator_nextcxx . . $ xccdf_refine_value_iterator_next(7670134309efdbc5).(r_value_it);
2266 if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(xccdf_refine_value_get_itemcxx . . $ xccdf_refine_value_get_item(99f8a21d78864a7b).(r_value), xccdf_value_get_idcxx . . $ xccdf_value_get_id(7dce63a6a4cb9377).((struct xccdf_valuecxx . . $ xccdf_value# *) item))) {
2267 selector = xccdf_refine_value_get_selectorcxx . . $ xccdf_refine_value_get_selector(99f8a21d78864a7b).(r_value);
2268 break;
2269 }
2270 }
2271 xccdf_refine_value_iterator_freecxx . . $ xccdf_refine_value_iterator_free(699a53bbf99fc3b2).(r_value_it);
2272 }
2273
2274 struct xccdf_value_instancecxx . . $ xccdf_value_instance# *instance = xccdf_value_get_instance_by_selectorcxx . . $ xccdf_value_get_instance_by_selector(1c9d6811ccaf1af0).((struct xccdf_valuecxx . . $ xccdf_value# *) item, selector);
2275 if (instance == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
2276 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XCCDFcxx . . $ `src/common/public/oscap_error.h:62:9`!, "Invalid selector '%s' for xccdf:value/@id='%s'. Using null value instead.",
2277 selector, xccdf_value_get_id((struct xccdf_value *) item));
2278 return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
2279 } else {
2280 return xccdf_value_instance_get_valuecxx . . $ xccdf_value_instance_get_value(fa38e5a18b4e4656).(instance);
2281 }
2282 }
2283
2284 struct oscap_file_entry_listcxx . . $ oscap_file_entry_list# * xccdf_policy_model_get_systems_and_filescxx . . $ xccdf_policy_model_get_systems_and_files(bd306bb648bca7f3).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# * policy_model)
2285 {
2286 return xccdf_item_get_systems_and_filescxx . . $ xccdf_item_get_systems_and_files(6e7c065411dc8fc2).((struct xccdf_itemcxx . . $ xccdf_item# *) xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(policy_model));
2287 }
2288
2289 struct oscap_stringlistcxx . . $ oscap_stringlist# * xccdf_policy_model_get_filescxx . . $ xccdf_policy_model_get_files(dac1d415a4793168).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# * policy_model)
2290 {
2291 return xccdf_item_get_filescxx . . $ xccdf_item_get_files(87bb2e49d8fada07).((struct xccdf_itemcxx . . $ xccdf_item# *) xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(policy_model));
2292 }
2293
2294 struct xccdf_benchmarkcxx . . $ xccdf_benchmark# *xccdf_policy_get_benchmarkcxx . . $ xccdf_policy_get_benchmark(2b37a6455229dc70).(const struct xccdf_policycxx . . $ xccdf_policy# *policy)
2295 {
2296 if (policy == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
2297 return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
2298 const struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model = xccdf_policy_get_modelcxx . . $ xccdf_policy_get_model(f98af4da2524e136).(policy);
2299 if (model == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
2300 return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
2301 return xccdf_policy_model_get_benchmarkcxx . . $ xccdf_policy_model_get_benchmark(a911a8e37770e756).(model);
2302 }
2303
2304 void xccdf_policy_model_freecxx . . $ xccdf_policy_model_free(72c03b3c10433f31).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# * model) {
2305
2306 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(model->policiescxx . . $ xccdf_policy_model#policies., (oscap_destruct_funccxx . . $ oscap_destruct_func#) xccdf_policy_freecxx . . $ xccdf_policy_free(d81e5bae50d670c2).);
2307 xccdf_policy_model_unregister_enginescxx . . $ xccdf_policy_model_unregister_engines(7c84e7be56876a5f).(model, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
2308 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(model->callbackscxx . . $ xccdf_policy_model#callbacks., (oscap_destruct_funccxx . . $ oscap_destruct_func#) freecxx . . $ free(5d22bdacc48458e8).);
2309 xccdf_tailoring_freecxx . . $ xccdf_tailoring_free(b4f0b704104bd93e).(model->tailoringcxx . . $ xccdf_policy_model#tailoring.);
2310 xccdf_benchmark_freecxx . . $ xccdf_benchmark_free(55d89e1b9b447538).(model->benchmarkcxx . . $ xccdf_policy_model#benchmark.);
2311 cpe_session_freecxx . . $ cpe_session_free(b639cf00dbfac4ec).(model->cpecxx . . $ xccdf_policy_model#cpe.);
2312 freecxx . . $ free(5d22bdacc48458e8).(model);
2313 }
2314
2315 static const char *_find_reference_uri_by_keycxx . . $ _find_reference_uri_by_key(c41009f8b28a5e9).(struct xccdf_benchmarkcxx . . $ xccdf_benchmark# *benchmark, const char *key)
2316 {
2317 const char *uri = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
2318 struct oscap_reference_iteratorcxx . . $ oscap_reference_iterator# *benchmark_references = xccdf_item_get_referencescxx . . $ xccdf_item_get_references(58b511645be6226a).((struct xccdf_itemcxx . . $ xccdf_item# *)benchmark);
2319 while (oscap_reference_iterator_has_morecxx . . $ oscap_reference_iterator_has_more(3902913d46f91173).(benchmark_references)) {
2320 struct oscap_referencecxx . . $ oscap_reference# *ref = oscap_reference_iterator_nextcxx . . $ oscap_reference_iterator_next(81bc9a067126085c).(benchmark_references);
2321 const char *title = oscap_reference_get_titlecxx . . $ oscap_reference_get_title(2a9eef276a992895).(ref);
2322 if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(key, title)) {
2323 uri = oscap_reference_get_hrefcxx . . $ oscap_reference_get_href(2a9eef276a992895).(ref);
2324 break;
2325 }
2326 }
2327 oscap_reference_iterator_freecxx . . $ oscap_reference_iterator_free(3e07142178288e0).(benchmark_references);
2328 return uri;
2329 }
2330
2331 void xccdf_policy_set_reference_filtercxx . . $ xccdf_policy_set_reference_filter(439ce320e94f2f4c).(struct xccdf_policycxx . . $ xccdf_policy# *policy, const char *reference_parameter)
2332 {
2333 if (!reference_parameter) {
2334 return;
2335 }
2336 char *reference_parameter_dup = strdupcxx . . $ strdup(a8b8e32347182212).(reference_parameter);
2337 char **split = oscap_splitcxx . . $ oscap_split(25e857aacd75b4b6).(reference_parameter_dup, ":");
2338 struct xccdf_benchmarkcxx . . $ xccdf_benchmark# *benchmark = policy->modelcxx . . $ xccdf_policy#model.->benchmarkcxx . . $ xccdf_policy_model#benchmark.;
2339 char *key = split[0];
2340 const char *uri = _find_reference_uri_by_keycxx . . $ _find_reference_uri_by_key(c41009f8b28a5e9).(benchmark, key);
2341 if (!uri) {
2342 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_OSCAPcxx . . $ `src/common/public/oscap_error.h:60:9`!, "Reference type '%s' isn't available in this benchmark", key);
2343 goto cleanup;
2344 }
2345 char *title = split[1];
2346 if (!title) {
2347 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_OSCAPcxx . . $ `src/common/public/oscap_error.h:60:9`!, "Reference identifier hasn't been provided");
2348 goto cleanup;
2349 }
2350 policy->reference_filtercxx . . $ xccdf_policy#reference_filter..activecxx . . $ xccdf_policy#$anonymous_type_0#active. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
2351 policy->reference_filtercxx . . $ xccdf_policy#reference_filter..hrefcxx . . $ xccdf_policy#$anonymous_type_0#href. = strdupcxx . . $ strdup(a8b8e32347182212).(uri);
2352 policy->reference_filtercxx . . $ xccdf_policy#reference_filter..titlecxx . . $ xccdf_policy#$anonymous_type_0#title. = strdupcxx . . $ strdup(a8b8e32347182212).(title);
2353 cleanup:
2354 freecxx . . $ free(5d22bdacc48458e8).(split);
2355 freecxx . . $ free(5d22bdacc48458e8).(reference_parameter_dup);
2356 }
2357
2358
2359 void xccdf_policy_freecxx . . $ xccdf_policy_free(d81e5bae50d670c2).(struct xccdf_policycxx . . $ xccdf_policy# * policy) {
2360
2361 /* A policy which is set to use default profile has its profile member set to NULL,
2362 * check it so we don't try to get the ID from a NULL profile.
2363 * */
2364 if (policy->profilecxx . . $ xccdf_policy#profile. && (
2365 (xccdf_profile_get_idcxx . . $ xccdf_profile_get_id(d143a4aa05fc37ce).(policy->profilecxx . . $ xccdf_policy#profile.) == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) ||
2366 (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(xccdf_profile_get_idcxx . . $ xccdf_profile_get_id(d143a4aa05fc37ce).(policy->profilecxx . . $ xccdf_policy#profile.), "(all)") == 0)))
2367 /* If ID of policy's profile is NULL or "(all)" then this
2368 * profile is created by Policy layer and need
2369 * to be freed
2370 */
2371 xccdf_profile_freecxx . . $ xccdf_profile_free(9e1ae929b010245a).((struct xccdf_itemcxx . . $ xccdf_item# *) policy->profilecxx . . $ xccdf_policy#profile.);
2372
2373 oscap_htable_free0cxx . . $ oscap_htable_free0(dbd8f9d05ba37fd5).(policy->rulescxx . . $ xccdf_policy#rules.);
2374 oscap_htable_free0cxx . . $ oscap_htable_free0(dbd8f9d05ba37fd5).(policy->skip_rulescxx . . $ xccdf_policy#skip_rules.);
2375 oscap_htable_free0cxx . . $ oscap_htable_free0(dbd8f9d05ba37fd5).(policy->rules_foundcxx . . $ xccdf_policy#rules_found.);
2376 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(policy->selectscxx . . $ xccdf_policy#selects., (oscap_destruct_funccxx . . $ oscap_destruct_func#) xccdf_select_freecxx . . $ xccdf_select_free(1d6b3c56f7681a70).);
2377 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(policy->valuescxx . . $ xccdf_policy#values., (oscap_destruct_funccxx . . $ oscap_destruct_func#) xccdf_value_binding_freecxx . . $ xccdf_value_binding_free(97df0146bfa7ea12).);
2378 oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(policy->resultscxx . . $ xccdf_policy#results., (oscap_destruct_funccxx . . $ oscap_destruct_func#) xccdf_result_freecxx . . $ xccdf_result_free(731f9fbfcaef207c).);
2379 oscap_htable_free0cxx . . $ oscap_htable_free0(dbd8f9d05ba37fd5).(policy->selected_internalcxx . . $ xccdf_policy#selected_internal.);
2380 oscap_htable_free0cxx . . $ oscap_htable_free0(dbd8f9d05ba37fd5).(policy->selected_finalcxx . . $ xccdf_policy#selected_final.);
2381 oscap_htable_freecxx . . $ oscap_htable_free(efa5da5da5d523d).(policy->refine_rules_internalcxx . . $ xccdf_policy#refine_rules_internal., (oscap_destruct_funccxx . . $ oscap_destruct_func#) xccdf_refine_rule_internal_freecxx . . $ xccdf_refine_rule_internal_free(5369899814db855c).);
2382 freecxx . . $ free(5d22bdacc48458e8).(policy->reference_filtercxx . . $ xccdf_policy#reference_filter..hrefcxx . . $ xccdf_policy#$anonymous_type_0#href.);
2383 freecxx . . $ free(5d22bdacc48458e8).(policy->reference_filtercxx . . $ xccdf_policy#reference_filter..titlecxx . . $ xccdf_policy#$anonymous_type_0#title.);
2384 freecxx . . $ free(5d22bdacc48458e8).(policy);
2385 }
2386
2387 void xccdf_value_binding_freecxx . . $ xccdf_value_binding_free(97df0146bfa7ea12).(struct xccdf_value_bindingcxx . . $ xccdf_value_binding# * binding) {
2388
2389 freecxx . . $ free(5d22bdacc48458e8).(binding->namecxx . . $ xccdf_value_binding#name.);
2390 freecxx . . $ free(5d22bdacc48458e8).(binding->valuecxx . . $ xccdf_value_binding#value.);
2391 freecxx . . $ free(5d22bdacc48458e8).(binding->setvaluecxx . . $ xccdf_value_binding#setvalue.);
2392 freecxx . . $ free(5d22bdacc48458e8).(binding);
2393 }
2394
2395 void xccdf_policy_model_set_show_rule_detailscxx . . $ xccdf_policy_model_set_show_rule_details(64287508088bf563).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *policy_model, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! show_rule_details)
2396 {
2397 policy_model->show_rule_detailscxx . . $ xccdf_policy_model#show_rule_details. = show_rule_details;
2398 }