Debian Codegraph @

src/XCCDF_POLICY/xccdf_policy_engine.c

raw symbols SCIP
1 /*
2 * Copyright 2014 Red Hat Inc., Durham, North Carolina.
3 * All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Authors:
20 * Šimon Lukašík
21 */
22
23 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
24 #include <config.h>cxx . . $ `<file>/build/config.h`/
25 #endif
26
27 #include "common/util.h"cxx . . $ `<file>/src/common/util.h`/
28 #include "common/list.h"cxx . . $ `<file>/src/common/list.h`/
29 #include "common/_error.h"cxx . . $ `<file>/src/common/_error.h`/
30 #include "public/xccdf_policy.h"cxx . . $ `<file>/src/XCCDF_POLICY/public/xccdf_policy.h`/
31 #include "xccdf_policy_engine_priv.h"cxx . . $ `<file>/src/XCCDF_POLICY/xccdf_policy_engine_priv.h`/
32
33 struct xccdf_policy_enginecxx . . $ xccdf_policy_engine# {
34 char *systemcxx . . $ xccdf_policy_engine#system.; ///< Identificator of checking engine
35 xccdf_policy_engine_eval_fncxx . . $ xccdf_policy_engine_eval_fn# callbackcxx . . $ xccdf_policy_engine#callback.; ///< format of callback function
36 void * usrcxx . . $ xccdf_policy_engine#usr.; ///< User data structure
37 xccdf_policy_engine_query_fncxx . . $ xccdf_policy_engine_query_fn# query_fncxx . . $ xccdf_policy_engine#query_fn.; ///< query callback function
38 };
39
40 struct xccdf_policy_enginecxx . . $ xccdf_policy_engine# *xccdf_policy_engine_newcxx . . $ xccdf_policy_engine_new(54b196a8acbffd20).(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)
41 {
42 struct xccdf_policy_enginecxx . . $ xccdf_policy_engine# *engine = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct xccdf_policy_enginecxx . . $ xccdf_policy_engine#));
43 if (engine != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
44 engine->systemcxx . . $ xccdf_policy_engine#system. = sys;
45 engine->callbackcxx . . $ xccdf_policy_engine#callback. = eval_fn;
46 engine->usrcxx . . $ xccdf_policy_engine#usr. = usr;
47 engine->query_fncxx . . $ xccdf_policy_engine#query_fn. = query_fn;
48 }
49 return engine;
50 }
51
52 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xccdf_policy_engine_filtercxx . . $ xccdf_policy_engine_filter(90adb2dfb41d6248).(struct xccdf_policy_enginecxx . . $ xccdf_policy_engine# *engine, const char *sysname)
53 {
54 return oscap_strcmpcxx . . $ oscap_strcmp(5ae29d726ae57f88).(engine->systemcxx . . $ xccdf_policy_engine#system., sysname) == 0;
55 }
56
57 xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# xccdf_policy_engine_evalcxx . . $ xccdf_policy_engine_eval(a4ba672079ed066f).(struct xccdf_policy_enginecxx . . $ xccdf_policy_engine# *engine, struct xccdf_policycxx . . $ xccdf_policy# *policy, const char *definition_id, const char *href_id, struct oscap_listcxx . . $ oscap_list# *value_bindings, struct xccdf_check_import_iteratorcxx . . $ xccdf_check_import_iterator# *check_import_it)
58 {
59 xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# ret = XCCDF_RESULT_NOT_CHECKEDcxx . . $ XCCDF_RESULT_NOT_CHECKED.;
60 if (engine == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
61 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XCCDFcxx . . $ `src/common/public/oscap_error.h:62:9`!, "Unknown callback for given checking system. Set callback first");
62 }
63 else {
64 struct xccdf_value_binding_iteratorcxx . . $ xccdf_value_binding_iterator# * binding_it = (struct xccdf_value_binding_iteratorcxx . . $ xccdf_value_binding_iterator# *) oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).(value_bindings);
65 ret = engine->callbackcxx . . $ xccdf_policy_engine#callback.(policy, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, definition_id, href_id, binding_it, check_import_it, engine->usrcxx . . $ xccdf_policy_engine#usr.);
66 if (binding_it != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
67 xccdf_value_binding_iterator_freecxx . . $ xccdf_value_binding_iterator_free(b942e4caf9f52bf0).(binding_it);
68 }
69 return ret;
70 }
71
72 struct oscap_listcxx . . $ oscap_list# *xccdf_policy_engine_querycxx . . $ xccdf_policy_engine_query(657864ad0a42fc34).(struct xccdf_policy_enginecxx . . $ xccdf_policy_engine# *engine, xccdf_policy_engine_query_tcxx . . $ xccdf_policy_engine_query_t# query_type, void *query_data)
73 {
74 if (engine->query_fncxx . . $ xccdf_policy_engine#query_fn. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
75 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
76 return (struct oscap_listcxx . . $ oscap_list# *) engine->query_fncxx . . $ xccdf_policy_engine#query_fn.(engine->usrcxx . . $ xccdf_policy_engine#usr., query_type, query_data);
77 }