| 1 | /** |
| 2 | * @file module_entry.c |
| 3 | * \brief Extra Check Engines Module Entry for Script Check Engine |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright 2013 Red Hat Inc., Durham, North Carolina. |
| 8 | * All Rights Reserved. |
| 9 | * |
| 10 | * This library is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU Lesser General Public |
| 12 | * License as published by the Free Software Foundation; either |
| 13 | * version 2.1 of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This library is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | * Lesser General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU Lesser General Public |
| 21 | * License along with this library; if not, write to the Free Software |
| 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 23 | * |
| 24 | * Authors: |
| 25 | * "Martin Preisler" <[email protected]> |
| 26 | */ |
| 27 | |
| 28 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 29 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 30 | #endif |
| 31 | |
| 32 | #include "sce_engine_api.h"cxx . . $ `<file>/src/SCE/public/sce_engine_api.h`/ |
| 33 | #include "XCCDF_POLICY/public/check_engine_plugin.h"cxx . . $ `<file>/src/XCCDF_POLICY/public/check_engine_plugin.h`/ |
| 34 | |
| 35 | #include <libgen.h> |
| 36 | #include <string.h> |
| 37 | |
| 38 | static int sce_engine_registercxx . . $ sce_engine_register(f9b6cff1c6ae6a1).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model, const char *path_hint, void **user_data) |
| 39 | { |
| 40 | struct sce_parameterscxx . . $ sce_parameters# *parameters = (struct sce_parameterscxx . . $ sce_parameters#*) *user_data; |
| 41 | if (parameters != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 42 | sce_parameters_freecxx . . $ sce_parameters_free(3951596372db9be1).(parameters); |
| 43 | |
| 44 | parameters = sce_parameters_newcxx . . $ sce_parameters_new(41e602c2677de0c6).(); |
| 45 | sce_parameters_set_xccdf_directorycxx . . $ sce_parameters_set_xccdf_directory(3f4426a8c3afb843).(parameters, path_hint); |
| 46 | sce_parameters_allocate_sessioncxx . . $ sce_parameters_allocate_session(3951596372db9be1).(parameters); |
| 47 | |
| 48 | *user_data = (void*)parameters; // This way the data will get freed later |
| 49 | |
| 50 | return !xccdf_policy_model_register_engine_scecxx . . $ xccdf_policy_model_register_engine_sce(f8237cfb45f8a428).(model, parameters); |
| 51 | } |
| 52 | |
| 53 | static int sce_engine_cleanupcxx . . $ sce_engine_cleanup(5b54cb04b6c72188).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model, void **user_data) |
| 54 | { |
| 55 | struct sce_parameterscxx . . $ sce_parameters# *parameters = (struct sce_parameterscxx . . $ sce_parameters#*) *user_data; |
| 56 | if (parameters != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 57 | sce_parameters_freecxx . . $ sce_parameters_free(3951596372db9be1).(parameters); |
| 58 | |
| 59 | *user_data = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 60 | |
| 61 | // FIXME: Unregister SCE? |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | static int sce_engine_export_resultscxx . . $ sce_engine_export_results(d9b29fb0f06e25e4).(struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *model, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! validate, const char *path_hint, void **user_data) |
| 66 | { |
| 67 | struct sce_parameterscxx . . $ sce_parameters# *parameters = (struct sce_parameterscxx . . $ sce_parameters#*) *user_data; |
| 68 | if (parameters == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) { |
| 69 | return 1; |
| 70 | } |
| 71 | |
| 72 | struct sce_sessioncxx . . $ sce_session# *sce_session = sce_parameters_get_sessioncxx . . $ sce_parameters_get_session(a4b1286c3a37b79d).(parameters); |
| 73 | if (sce_session == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 74 | return 1; |
| 75 | struct sce_check_result_iteratorcxx . . $ sce_check_result_iterator# *it = sce_session_get_check_resultscxx . . $ sce_session_get_check_results(631e7e3c7918875b).(sce_session); |
| 76 | |
| 77 | while(sce_check_result_iterator_has_morecxx . . $ sce_check_result_iterator_has_more(8878db1c6e4b4ae3).(it)) |
| 78 | { |
| 79 | struct sce_check_resultcxx . . $ sce_check_result# *check_result = sce_check_result_iterator_nextcxx . . $ sce_check_result_iterator_next(635aa288c67a5480).(it); |
| 80 | char target[2 + strlencxx . . $ strlen(751346f8406fd082).(sce_check_result_get_basenamecxx . . $ sce_check_result_get_basename(a3aefccd2beab286).(check_result)) + 11 + 1]; |
| 81 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(target, sizeof(target), "./%s.result.xml", sce_check_result_get_basenamecxx . . $ sce_check_result_get_basename(a3aefccd2beab286).(check_result)); |
| 82 | sce_check_result_exportcxx . . $ sce_check_result_export(84ed1ba2de1ba4ee).(check_result, target); |
| 83 | } |
| 84 | |
| 85 | sce_check_result_iterator_freecxx . . $ sce_check_result_iterator_free(80927f24f3dab80a).(it); |
| 86 | |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | static const char *sce_engine_get_capabilitiescxx . . $ sce_engine_get_capabilities(c4fc68ef6b2a360).(void **user_data) |
| 91 | { |
| 92 | return "SCE Version: 1.0"; |
| 93 | } |
| 94 | |
| 95 | int OPENSCAP_CHECK_ENGINE_PLUGIN_ENTRYcxx . . $ `src/XCCDF_POLICY/public/check_engine_plugin.h:70:9`! (struct check_engine_plugin_defcxx . . $ check_engine_plugin_def# *plugin); |
| 96 | |
| 97 | int OPENSCAP_CHECK_ENGINE_PLUGIN_ENTRYcxx . . $ `src/XCCDF_POLICY/public/check_engine_plugin.h:70:9`! (struct check_engine_plugin_defcxx . . $ check_engine_plugin_def# *plugin) |
| 98 | { |
| 99 | plugin->register_fncxx . . $ check_engine_plugin_def#register_fn. = sce_engine_registercxx . . $ sce_engine_register(f9b6cff1c6ae6a1).; |
| 100 | plugin->cleanup_fncxx . . $ check_engine_plugin_def#cleanup_fn. = sce_engine_cleanupcxx . . $ sce_engine_cleanup(5b54cb04b6c72188).; |
| 101 | plugin->export_results_fncxx . . $ check_engine_plugin_def#export_results_fn. = sce_engine_export_resultscxx . . $ sce_engine_export_results(d9b29fb0f06e25e4).; |
| 102 | plugin->get_capabilities_fncxx . . $ check_engine_plugin_def#get_capabilities_fn. = sce_engine_get_capabilitiescxx . . $ sce_engine_get_capabilities(c4fc68ef6b2a360).; |
| 103 | |
| 104 | return 0; |
| 105 | } |