| 1 | /* |
| 2 | * Copyright 2012--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 | * Martin Preisler <[email protected]> |
| 21 | */ |
| 22 | |
| 23 | /* Standard header files */ |
| 24 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| 28 | #ifdef HAVE_GETOPT_Hcxx . . $ `build/config.h:79:9`! |
| 29 | #include <getopt.h> |
| 30 | #endif |
| 31 | #ifdef OS_WINDOWS |
| 32 | #include <io.h> |
| 33 | #else |
| 34 | #include <unistd.h> |
| 35 | #endif |
| 36 | |
| 37 | #ifndef PATH_MAX |
| 38 | #define PATH_MAXcxx . . $ `utils/oscap-ds.c:38:9`! 4096 |
| 39 | #endif |
| 40 | |
| 41 | /* DS */ |
| 42 | #include <scap_ds.h>cxx . . $ `<file>/src/DS/public/scap_ds.h`/ |
| 43 | #include <oscap_source.h>cxx . . $ `<file>/src/source/public/oscap_source.h`/ |
| 44 | #include <ds_rds_session.h>cxx . . $ `<file>/src/DS/public/ds_rds_session.h`/ |
| 45 | #include <ds_sds_session.h>cxx . . $ `<file>/src/DS/public/ds_sds_session.h`/ |
| 46 | #include <xccdf_session.h>cxx . . $ `<file>/src/XCCDF/public/xccdf_session.h`/ |
| 47 | |
| 48 | #include "oscap-tool.h"cxx . . $ `<file>/utils/oscap-tool.h`/ |
| 49 | #include <oscap_debug.h>cxx . . $ `<file>/src/common/public/oscap_debug.h`/ |
| 50 | #include "oscap_helpers.h"cxx . . $ `<file>/src/common/public/oscap_helpers.h`/ |
| 51 | |
| 52 | #define DS_SUBMODULES_NUMcxx . . $ `utils/oscap-ds.c:52:9`! 8 /* See actual DS_SUBMODULES array |
| 53 | initialization below. */ |
| 54 | static struct oscap_modulecxx . . $ oscap_module#* DS_SUBMODULEScxx . . $ DS_SUBMODULES.[DS_SUBMODULES_NUMcxx . . $ `utils/oscap-ds.c:52:9`!]; |
| 55 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! getopt_dscxx . . $ getopt_ds(93e8ba72609212ff).(int argc, char **argv, struct oscap_actioncxx . . $ oscap_action# *action); |
| 56 | int app_ds_sds_splitcxx . . $ app_ds_sds_split(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action); |
| 57 | int app_ds_sds_composecxx . . $ app_ds_sds_compose(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action); |
| 58 | int app_ds_sds_addcxx . . $ app_ds_sds_add(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action); |
| 59 | int app_ds_sds_validatecxx . . $ app_ds_sds_validate(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action); |
| 60 | int app_ds_rds_splitcxx . . $ app_ds_rds_split(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action); |
| 61 | int app_ds_rds_createcxx . . $ app_ds_rds_create(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action); |
| 62 | int app_ds_rds_validatecxx . . $ app_ds_rds_validate(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action); |
| 63 | |
| 64 | struct oscap_modulecxx . . $ oscap_module# OSCAP_DS_MODULEcxx . . $ OSCAP_DS_MODULE. = { |
| 65 | .name = "ds", |
| 66 | .parent = &OSCAP_ROOT_MODULEcxx . . $ OSCAP_ROOT_MODULE., |
| 67 | .summary = "Data stream utilities", |
| 68 | .submodules = DS_SUBMODULEScxx . . $ DS_SUBMODULES. |
| 69 | }; |
| 70 | |
| 71 | static struct oscap_modulecxx . . $ oscap_module# DS_SDS_VALIDATE_MODULEcxx . . $ DS_SDS_VALIDATE_MODULE. = { |
| 72 | .name = "sds-validate", |
| 73 | .parent = &OSCAP_DS_MODULEcxx . . $ OSCAP_DS_MODULE., |
| 74 | .summary = "Validate given source data stream", |
| 75 | .usage = "source_datastream.xml", |
| 76 | .help = "Options:\n" |
| 77 | " --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n" |
| 78 | " Verbosity level must be one of: DEVEL, INFO, WARNING, ERROR.\n" |
| 79 | " --verbose-log-file <file> - Write verbose information into file.\n", |
| 80 | .opt_parser = getopt_dscxx . . $ getopt_ds(93e8ba72609212ff)., |
| 81 | .func = app_ds_sds_validatecxx . . $ app_ds_sds_validate(d99c68634f61e371). |
| 82 | }; |
| 83 | |
| 84 | static struct oscap_modulecxx . . $ oscap_module# DS_RDS_VALIDATE_MODULEcxx . . $ DS_RDS_VALIDATE_MODULE. = { |
| 85 | .name = "rds-validate", |
| 86 | .parent = &OSCAP_DS_MODULEcxx . . $ OSCAP_DS_MODULE., |
| 87 | .summary = "Validate given result data stream", |
| 88 | .usage = "[options] result_datastream.xml", |
| 89 | .help = "Options:\n" |
| 90 | " --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n" |
| 91 | " Verbosity level must be one of: DEVEL, INFO, WARNING, ERROR.\n" |
| 92 | " --verbose-log-file <file> - Write verbose information into file.\n", |
| 93 | .opt_parser = getopt_dscxx . . $ getopt_ds(93e8ba72609212ff)., |
| 94 | .func = app_ds_rds_validatecxx . . $ app_ds_rds_validate(d99c68634f61e371). |
| 95 | }; |
| 96 | |
| 97 | static struct oscap_modulecxx . . $ oscap_module#* DS_SUBMODULEScxx . . $ DS_SUBMODULES.[DS_SUBMODULES_NUMcxx . . $ `utils/oscap-ds.c:52:9`!] = { |
| 98 | &DS_SDS_VALIDATE_MODULEcxx . . $ DS_SDS_VALIDATE_MODULE., |
| 99 | &DS_RDS_VALIDATE_MODULEcxx . . $ DS_RDS_VALIDATE_MODULE., |
| 100 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! |
| 101 | }; |
| 102 | |
| 103 | enum ds_optcxx . . $ ds_opt# { |
| 104 | DS_OPT_DATASTREAM_IDcxx . . $ DS_OPT_DATASTREAM_ID. = 1, |
| 105 | DS_OPT_XCCDF_IDcxx . . $ DS_OPT_XCCDF_ID., |
| 106 | DS_OPT_REPORT_IDcxx . . $ DS_OPT_REPORT_ID., |
| 107 | DS_OPT_LOCAL_FILEScxx . . $ DS_OPT_LOCAL_FILES., |
| 108 | DS_OPT_VERBOSEcxx . . $ DS_OPT_VERBOSE., |
| 109 | DS_OPT_VERBOSE_LOG_FILEcxx . . $ DS_OPT_VERBOSE_LOG_FILE., |
| 110 | }; |
| 111 | |
| 112 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! getopt_dscxx . . $ getopt_ds(93e8ba72609212ff).(int argc, char **argv, struct oscap_actioncxx . . $ oscap_action# *action) { |
| 113 | action->doctypecxx . . $ oscap_action#doctype. = OSCAP_DOCUMENT_SDScxx . . $ OSCAP_DOCUMENT_SDS.; |
| 114 | |
| 115 | /* Command-options */ |
| 116 | const struct optioncxx . . $ option# long_options[] = { |
| 117 | // options |
| 118 | {"skip-validation", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->validatecxx . . $ oscap_action#validate., 0}, |
| 119 | {"datastream-id", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, DS_OPT_DATASTREAM_IDcxx . . $ DS_OPT_DATASTREAM_ID.}, |
| 120 | {"xccdf-id", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, DS_OPT_XCCDF_IDcxx . . $ DS_OPT_XCCDF_ID.}, |
| 121 | {"report-id", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, DS_OPT_REPORT_IDcxx . . $ DS_OPT_REPORT_ID.}, |
| 122 | {"fetch-remote-resources", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->remote_resourcescxx . . $ oscap_action#remote_resources., 1}, |
| 123 | {"local-files", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, DS_OPT_LOCAL_FILEScxx . . $ DS_OPT_LOCAL_FILES.}, |
| 124 | {"verbose", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, DS_OPT_VERBOSEcxx . . $ DS_OPT_VERBOSE.}, |
| 125 | {"verbose-log-file", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, DS_OPT_VERBOSE_LOG_FILEcxx . . $ DS_OPT_VERBOSE_LOG_FILE.}, |
| 126 | // end |
| 127 | {0, 0, 0, 0} |
| 128 | }; |
| 129 | |
| 130 | int c; |
| 131 | while ((c = getopt_longcxx . . $ getopt_long(41f665c090816971).(argc, argv, "o:i:", long_options, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) != -1) { |
| 132 | |
| 133 | switch (c) { |
| 134 | case DS_OPT_DATASTREAM_IDcxx . . $ DS_OPT_DATASTREAM_ID.: action->f_datastream_idcxx . . $ oscap_action#f_datastream_id. = optargcxx . . $ optarg.; break; |
| 135 | case DS_OPT_XCCDF_IDcxx . . $ DS_OPT_XCCDF_ID.: action->f_xccdf_idcxx . . $ oscap_action#f_xccdf_id. = optargcxx . . $ optarg.; break; |
| 136 | case DS_OPT_REPORT_IDcxx . . $ DS_OPT_REPORT_ID.: action->f_report_idcxx . . $ oscap_action#f_report_id. = optargcxx . . $ optarg.; break; |
| 137 | case DS_OPT_LOCAL_FILEScxx . . $ DS_OPT_LOCAL_FILES.: |
| 138 | action->local_filescxx . . $ oscap_action#local_files. = optargcxx . . $ optarg.; |
| 139 | break; |
| 140 | case DS_OPT_VERBOSEcxx . . $ DS_OPT_VERBOSE.: |
| 141 | action->verbosity_levelcxx . . $ oscap_action#verbosity_level. = optargcxx . . $ optarg.; |
| 142 | break; |
| 143 | case DS_OPT_VERBOSE_LOG_FILEcxx . . $ DS_OPT_VERBOSE_LOG_FILE.: |
| 144 | action->f_verbose_logcxx . . $ oscap_action#f_verbose_log. = optargcxx . . $ optarg.; |
| 145 | break; |
| 146 | case 0: break; |
| 147 | default: return oscap_module_usagecxx . . $ oscap_module_usage(8d148a6468c518c9).(action->modulecxx . . $ oscap_action#module., stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | if (action->modulecxx . . $ oscap_action#module. == &DS_SDS_VALIDATE_MODULEcxx . . $ DS_SDS_VALIDATE_MODULE.) { |
| 152 | if( argc != 4 ) { |
| 153 | oscap_module_usagecxx . . $ oscap_module_usage(8d148a6468c518c9).(action->modulecxx . . $ oscap_action#module., stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Wrong number of parameters.\n"); |
| 154 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 155 | } |
| 156 | action->ds_actioncxx . . $ oscap_action#ds_action. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct ds_actioncxx . . $ ds_action#)); |
| 157 | action->ds_actioncxx . . $ oscap_action#ds_action.->filecxx . . $ ds_action#file. = argv[3]; |
| 158 | } |
| 159 | else if (action->modulecxx . . $ oscap_action#module. == &DS_RDS_VALIDATE_MODULEcxx . . $ DS_RDS_VALIDATE_MODULE.) { |
| 160 | if(optindcxx . . $ optind. >= argc) { |
| 161 | oscap_module_usagecxx . . $ oscap_module_usage(8d148a6468c518c9).(action->modulecxx . . $ oscap_action#module., stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Result data stream file need to be specified!\n"); |
| 162 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 163 | } |
| 164 | action->ds_actioncxx . . $ oscap_action#ds_action. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct ds_actioncxx . . $ ds_action#)); |
| 165 | action->ds_actioncxx . . $ oscap_action#ds_action.->filecxx . . $ ds_action#file. = argv[optindcxx . . $ optind.]; |
| 166 | } |
| 167 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 168 | } |
| 169 | |
| 170 | static inline char *_gcwdcxx . . $ _gcwd(41208ce6ca65dd58).(void) |
| 171 | { |
| 172 | char *cwd = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(char) * (PATH_MAXcxx . . $ `utils/oscap-ds.c:38:9`! + 1)); |
| 173 | if (getcwdcxx . . $ getcwd(dff97f9eb74e1544).(cwd, PATH_MAXcxx . . $ `utils/oscap-ds.c:38:9`!) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 174 | perrorcxx . . $ perror(85c52e162fed56f9).("Can't find out current working directory.\n"); |
| 175 | freecxx . . $ free(5d22bdacc48458e8).(cwd); |
| 176 | cwd = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 177 | } |
| 178 | return cwd; |
| 179 | } |
| 180 | |
| 181 | int app_ds_sds_splitcxx . . $ app_ds_sds_split(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action) { |
| 182 | int ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.; |
| 183 | const char* f_datastream_id = action->f_datastream_idcxx . . $ oscap_action#f_datastream_id.; |
| 184 | const char* f_component_id = action->f_xccdf_idcxx . . $ oscap_action#f_xccdf_id.; |
| 185 | struct ds_sds_sessioncxx . . $ ds_sds_session# *session = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 186 | |
| 187 | struct oscap_sourcecxx . . $ oscap_source# *source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(action->ds_actioncxx . . $ oscap_action#ds_action.->filecxx . . $ ds_action#file.); |
| 188 | /* Validate */ |
| 189 | if (action->validatecxx . . $ oscap_action#validate.) |
| 190 | { |
| 191 | if (oscap_source_validatecxx . . $ oscap_source_validate(58e1cfedb30f1c20).(source, reportercxx . . $ reporter(710d628f83af7da6)., (void *) action) != 0) { |
| 192 | goto cleanup; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | session = ds_sds_session_new_from_sourcecxx . . $ ds_sds_session_new_from_source(84081d5e8394044f).(source); |
| 197 | if (session == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 198 | goto cleanup; |
| 199 | } |
| 200 | if (ds_sds_index_select_checklistcxx . . $ ds_sds_index_select_checklist(bea618b8c835104b).(ds_sds_session_get_sds_idxcxx . . $ ds_sds_session_get_sds_idx(4257cf9e93799a4d).(session), &f_datastream_id, &f_component_id) != 0) { |
| 201 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "Failed to locate a data stream with ID matching '%s' ID " |
| 202 | "and checklist inside matching '%s' ID.\n", |
| 203 | action->f_datastream_idcxx . . $ oscap_action#f_datastream_id. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "<any>" : action->f_datastream_idcxx . . $ oscap_action#f_datastream_id., |
| 204 | action->f_xccdf_idcxx . . $ oscap_action#f_xccdf_id. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "<any>" : action->f_xccdf_idcxx . . $ oscap_action#f_xccdf_id.); |
| 205 | goto cleanup; |
| 206 | } |
| 207 | ds_sds_session_set_datastream_idcxx . . $ ds_sds_session_set_datastream_id(d40402bb7044504c).(session, f_datastream_id); |
| 208 | |
| 209 | ds_sds_session_configure_remote_resourcescxx . . $ ds_sds_session_configure_remote_resources(61c5f4052dda9a0f).(session, action->remote_resourcescxx . . $ oscap_action#remote_resources., action->local_filescxx . . $ oscap_action#local_files., download_reporting_callbackcxx . . $ download_reporting_callback(3ca54e6407cd3d15).); |
| 210 | ds_sds_session_set_target_dircxx . . $ ds_sds_session_set_target_dir(d40402bb7044504c).(session, action->ds_actioncxx . . $ oscap_action#ds_action.->targetcxx . . $ ds_action#target.); |
| 211 | if (ds_sds_session_register_component_with_dependenciescxx . . $ ds_sds_session_register_component_with_dependencies(2e27e35b07e9ac87).(session, "checklists", f_component_id, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) != 0) { |
| 212 | goto cleanup; |
| 213 | } |
| 214 | // CPE dictionaries aren't required in datastreams, just silently continue |
| 215 | // if we can't register them |
| 216 | if (ds_sds_session_can_register_componentcxx . . $ ds_sds_session_can_register_component(cd5c734c21abbdcb).(session, "dictionaries", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) { |
| 217 | if (ds_sds_session_register_component_with_dependenciescxx . . $ ds_sds_session_register_component_with_dependencies(2e27e35b07e9ac87).(session, "dictionaries", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) != 0) { |
| 218 | goto cleanup; |
| 219 | } |
| 220 | } |
| 221 | if (ds_sds_session_dump_component_filescxx . . $ ds_sds_session_dump_component_files(1aa04247b518277f).(session) != 0) { |
| 222 | goto cleanup; |
| 223 | } |
| 224 | |
| 225 | ret = OSCAP_OKcxx . . $ OSCAP_OK.; |
| 226 | |
| 227 | cleanup: |
| 228 | oscap_print_errorcxx . . $ oscap_print_error(49f6e7a06ebc5aa8).(); |
| 229 | |
| 230 | ds_sds_session_freecxx . . $ ds_sds_session_free(41ab223cf3ccc737).(session); |
| 231 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source); |
| 232 | freecxx . . $ free(5d22bdacc48458e8).(action->ds_actioncxx . . $ oscap_action#ds_action.); |
| 233 | |
| 234 | return ret; |
| 235 | } |
| 236 | |
| 237 | int app_ds_sds_composecxx . . $ app_ds_sds_compose(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action) { |
| 238 | int ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.; |
| 239 | |
| 240 | // The API will correctly deal with the file parameter having directory |
| 241 | // references in it. However this will create a hard to navigate mangled |
| 242 | // component IDs in the resulting datastream. |
| 243 | // |
| 244 | // To fix this we will chdir to parent dir of the given XCCDF and chdir |
| 245 | // back after we are done. |
| 246 | |
| 247 | char *previous_cwd = _gcwdcxx . . $ _gcwd(41208ce6ca65dd58).(); |
| 248 | if (previous_cwd == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 249 | goto cleanup; |
| 250 | } |
| 251 | |
| 252 | char target_abs_path[PATH_MAXcxx . . $ `utils/oscap-ds.c:38:9`! + 1]; |
| 253 | |
| 254 | // if the path is already absolute we just use it as it is |
| 255 | if (*action->ds_actioncxx . . $ oscap_action#ds_action.->targetcxx . . $ ds_action#target. == '/') |
| 256 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(target_abs_path, PATH_MAXcxx . . $ `utils/oscap-ds.c:38:9`!, "%s", action->ds_actioncxx . . $ oscap_action#ds_action.->targetcxx . . $ ds_action#target.); |
| 257 | else |
| 258 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(target_abs_path, PATH_MAXcxx . . $ `utils/oscap-ds.c:38:9`!, "%s/%s", previous_cwd, action->ds_actioncxx . . $ oscap_action#ds_action.->targetcxx . . $ ds_action#target.); |
| 259 | |
| 260 | char* temp_cwd = strdupcxx . . $ strdup(a8b8e32347182212).(action->ds_actioncxx . . $ oscap_action#ds_action.->filecxx . . $ ds_action#file.); |
| 261 | char *temp_cwd_dirname = oscap_dirnamecxx . . $ oscap_dirname(7a9722d75b371431).(temp_cwd); |
| 262 | if (chdircxx . . $ chdir(5c4306d8553b3696).(temp_cwd_dirname) < 0) { |
| 263 | freecxx . . $ free(5d22bdacc48458e8).(temp_cwd_dirname); |
| 264 | freecxx . . $ free(5d22bdacc48458e8).(temp_cwd); |
| 265 | goto cleanup; |
| 266 | } |
| 267 | freecxx . . $ free(5d22bdacc48458e8).(temp_cwd_dirname); |
| 268 | freecxx . . $ free(5d22bdacc48458e8).(temp_cwd); |
| 269 | |
| 270 | char* source_xccdf = strdupcxx . . $ strdup(a8b8e32347182212).(action->ds_actioncxx . . $ oscap_action#ds_action.->filecxx . . $ ds_action#file.); |
| 271 | char *base_name = oscap_basenamecxx . . $ oscap_basename(7a9722d75b371431).(source_xccdf); |
| 272 | ds_sds_compose_from_xccdfcxx . . $ ds_sds_compose_from_xccdf(5ae29d726ae57f88).(base_name, target_abs_path); |
| 273 | freecxx . . $ free(5d22bdacc48458e8).(base_name); |
| 274 | freecxx . . $ free(5d22bdacc48458e8).(source_xccdf); |
| 275 | |
| 276 | if (chdircxx . . $ chdir(5c4306d8553b3696).(previous_cwd) < 0) { |
| 277 | goto cleanup; |
| 278 | } |
| 279 | |
| 280 | if (action->validatecxx . . $ oscap_action#validate.) |
| 281 | { |
| 282 | struct oscap_sourcecxx . . $ oscap_source# *source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(target_abs_path); |
| 283 | if (oscap_source_validatecxx . . $ oscap_source_validate(58e1cfedb30f1c20).(source, reportercxx . . $ reporter(710d628f83af7da6)., (void *) action) != 0) { |
| 284 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source); |
| 285 | goto cleanup; |
| 286 | } |
| 287 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source); |
| 288 | } |
| 289 | |
| 290 | ret = OSCAP_OKcxx . . $ OSCAP_OK.; |
| 291 | |
| 292 | cleanup: |
| 293 | oscap_print_errorcxx . . $ oscap_print_error(49f6e7a06ebc5aa8).(); |
| 294 | |
| 295 | freecxx . . $ free(5d22bdacc48458e8).(previous_cwd); |
| 296 | freecxx . . $ free(5d22bdacc48458e8).(action->ds_actioncxx . . $ oscap_action#ds_action.); |
| 297 | return ret; |
| 298 | } |
| 299 | |
| 300 | int app_ds_sds_addcxx . . $ app_ds_sds_add(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action) |
| 301 | { |
| 302 | int ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.; |
| 303 | // TODO: chdir to the directory of the component (same as when composing new sds) |
| 304 | ret = ds_sds_compose_add_componentcxx . . $ ds_sds_compose_add_component(aea0df7b663a3343).(action->ds_actioncxx . . $ oscap_action#ds_action.->targetcxx . . $ ds_action#target., action->f_datastream_idcxx . . $ oscap_action#f_datastream_id., action->ds_actioncxx . . $ oscap_action#ds_action.->filecxx . . $ ds_action#file., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 305 | if (action->validatecxx . . $ oscap_action#validate.) { |
| 306 | struct oscap_sourcecxx . . $ oscap_source# *source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(action->ds_actioncxx . . $ oscap_action#ds_action.->filecxx . . $ ds_action#file.); |
| 307 | if (oscap_source_validatecxx . . $ oscap_source_validate(58e1cfedb30f1c20).(source, reportercxx . . $ reporter(710d628f83af7da6)., (void *) action) != 0) { |
| 308 | ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.; |
| 309 | } |
| 310 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source); |
| 311 | } |
| 312 | oscap_print_errorcxx . . $ oscap_print_error(49f6e7a06ebc5aa8).(); |
| 313 | |
| 314 | freecxx . . $ free(5d22bdacc48458e8).(action->ds_actioncxx . . $ oscap_action#ds_action.); |
| 315 | return ret; |
| 316 | } |
| 317 | |
| 318 | int app_ds_sds_validatecxx . . $ app_ds_sds_validate(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action) { |
| 319 | int ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.; |
| 320 | struct oscap_sourcecxx . . $ oscap_source# *source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(action->ds_actioncxx . . $ oscap_action#ds_action.->filecxx . . $ ds_action#file.); |
| 321 | if (oscap_source_validatecxx . . $ oscap_source_validate(58e1cfedb30f1c20).(source, reportercxx . . $ reporter(710d628f83af7da6)., (void*) action) != 0) { |
| 322 | goto cleanup; |
| 323 | } |
| 324 | |
| 325 | ret = OSCAP_OKcxx . . $ OSCAP_OK.; |
| 326 | |
| 327 | cleanup: |
| 328 | oscap_print_errorcxx . . $ oscap_print_error(49f6e7a06ebc5aa8).(); |
| 329 | |
| 330 | freecxx . . $ free(5d22bdacc48458e8).(action->ds_actioncxx . . $ oscap_action#ds_action.); |
| 331 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source); |
| 332 | return ret; |
| 333 | } |
| 334 | |
| 335 | int app_ds_rds_splitcxx . . $ app_ds_rds_split(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action) { |
| 336 | int ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.; |
| 337 | struct ds_rds_sessioncxx . . $ ds_rds_session# *session = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 338 | |
| 339 | struct oscap_sourcecxx . . $ oscap_source# *source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(action->ds_actioncxx . . $ oscap_action#ds_action.->filecxx . . $ ds_action#file.); |
| 340 | if (action->validatecxx . . $ oscap_action#validate.) |
| 341 | { |
| 342 | if (oscap_source_validatecxx . . $ oscap_source_validate(58e1cfedb30f1c20).(source, reportercxx . . $ reporter(710d628f83af7da6)., (void *) action) != 0) { |
| 343 | goto cleanup; |
| 344 | } |
| 345 | } |
| 346 | session = ds_rds_session_new_from_sourcecxx . . $ ds_rds_session_new_from_source(592e39614e891652).(source); |
| 347 | if (session == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! |
| 348 | || ds_rds_session_set_target_dircxx . . $ ds_rds_session_set_target_dir(78d741831fd83d06).(session, action->ds_actioncxx . . $ oscap_action#ds_action.->targetcxx . . $ ds_action#target.) != 0 |
| 349 | || ds_rds_session_select_reportcxx . . $ ds_rds_session_select_report(e0b2d513013fe52d).(session, action->f_report_idcxx . . $ oscap_action#f_report_id.) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! |
| 350 | || ds_rds_session_select_report_requestcxx . . $ ds_rds_session_select_report_request(e0b2d513013fe52d).(session, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! |
| 351 | || ds_rds_session_dump_component_filescxx . . $ ds_rds_session_dump_component_files(d9925a5eb3f8526d).(session) != 0) { |
| 352 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "Failed to split given result data stream '%s'.\n", action->ds_actioncxx . . $ oscap_action#ds_action.->filecxx . . $ ds_action#file.); |
| 353 | goto cleanup; |
| 354 | } |
| 355 | |
| 356 | ret = OSCAP_OKcxx . . $ OSCAP_OK.; |
| 357 | |
| 358 | cleanup: |
| 359 | oscap_print_errorcxx . . $ oscap_print_error(49f6e7a06ebc5aa8).(); |
| 360 | |
| 361 | ds_rds_session_freecxx . . $ ds_rds_session_free(f80cb7d7d6605f3a).(session); |
| 362 | freecxx . . $ free(5d22bdacc48458e8).(action->ds_actioncxx . . $ oscap_action#ds_action.); |
| 363 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source); |
| 364 | |
| 365 | return ret; |
| 366 | } |
| 367 | |
| 368 | int app_ds_rds_createcxx . . $ app_ds_rds_create(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action) { |
| 369 | int ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.; |
| 370 | |
| 371 | if (action->validatecxx . . $ oscap_action#validate.) |
| 372 | { |
| 373 | struct oscap_sourcecxx . . $ oscap_source# *sds = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(action->ds_actioncxx . . $ oscap_action#ds_action.->filecxx . . $ ds_action#file.); |
| 374 | if (oscap_source_validatecxx . . $ oscap_source_validate(58e1cfedb30f1c20).(sds, reportercxx . . $ reporter(710d628f83af7da6)., (void *) action) != 0) { |
| 375 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(sds); |
| 376 | goto cleanup; |
| 377 | } |
| 378 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(sds); |
| 379 | |
| 380 | struct oscap_sourcecxx . . $ oscap_source# *result = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(action->ds_actioncxx . . $ oscap_action#ds_action.->xccdf_resultcxx . . $ ds_action#xccdf_result.); |
| 381 | if (oscap_source_validatecxx . . $ oscap_source_validate(58e1cfedb30f1c20).(result, reportercxx . . $ reporter(710d628f83af7da6)., (void *) action) != 0) { |
| 382 | ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.; |
| 383 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(result); |
| 384 | goto cleanup; |
| 385 | } |
| 386 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(result); |
| 387 | } |
| 388 | |
| 389 | char** oval_result_files = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(char*) * (action->ds_actioncxx . . $ oscap_action#ds_action.->oval_result_countcxx . . $ ds_action#oval_result_count. + 1)); |
| 390 | |
| 391 | size_t i; |
| 392 | for (i = 0; i < action->ds_actioncxx . . $ oscap_action#ds_action.->oval_result_countcxx . . $ ds_action#oval_result_count.; ++i) |
| 393 | { |
| 394 | oval_result_files[i] = action->ds_actioncxx . . $ oscap_action#ds_action.->oval_resultscxx . . $ ds_action#oval_results.[i]; |
| 395 | |
| 396 | if (action->validatecxx . . $ oscap_action#validate.) |
| 397 | { |
| 398 | struct oscap_sourcecxx . . $ oscap_source# *source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(oval_result_files[i]); |
| 399 | if (oscap_source_validatecxx . . $ oscap_source_validate(58e1cfedb30f1c20).(source, reportercxx . . $ reporter(710d628f83af7da6)., (void *) action) != 0) { |
| 400 | ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.; |
| 401 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source); |
| 402 | freecxx . . $ free(5d22bdacc48458e8).(oval_result_files); |
| 403 | goto cleanup; |
| 404 | } |
| 405 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source); |
| 406 | } |
| 407 | } |
| 408 | oval_result_files[i] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 409 | |
| 410 | ret = ds_rds_createcxx . . $ ds_rds_create(ff736071f9a2196b).(action->ds_actioncxx . . $ oscap_action#ds_action.->filecxx . . $ ds_action#file., action->ds_actioncxx . . $ oscap_action#ds_action.->xccdf_resultcxx . . $ ds_action#xccdf_result., |
| 411 | (const char**)oval_result_files, action->ds_actioncxx . . $ oscap_action#ds_action.->targetcxx . . $ ds_action#target.); |
| 412 | |
| 413 | freecxx . . $ free(5d22bdacc48458e8).(oval_result_files); |
| 414 | |
| 415 | if (ret != 0) |
| 416 | { |
| 417 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "Failed to create result data stream in ARF."); |
| 418 | ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.; |
| 419 | goto cleanup; |
| 420 | } |
| 421 | |
| 422 | const char* full_validation = getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_FULL_VALIDATION"); |
| 423 | |
| 424 | if (action->validatecxx . . $ oscap_action#validate. && full_validation) |
| 425 | { |
| 426 | struct oscap_sourcecxx . . $ oscap_source# *rds = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(action->ds_actioncxx . . $ oscap_action#ds_action.->targetcxx . . $ ds_action#target.); |
| 427 | if (oscap_source_validatecxx . . $ oscap_source_validate(58e1cfedb30f1c20).(rds, reportercxx . . $ reporter(710d628f83af7da6)., (void *) action) != 0) { |
| 428 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(rds); |
| 429 | goto cleanup; |
| 430 | } |
| 431 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(rds); |
| 432 | } |
| 433 | |
| 434 | ret = OSCAP_OKcxx . . $ OSCAP_OK.; |
| 435 | |
| 436 | cleanup: |
| 437 | oscap_print_errorcxx . . $ oscap_print_error(49f6e7a06ebc5aa8).(); |
| 438 | |
| 439 | freecxx . . $ free(5d22bdacc48458e8).(action->ds_actioncxx . . $ oscap_action#ds_action.); |
| 440 | return ret; |
| 441 | } |
| 442 | |
| 443 | int app_ds_rds_validatecxx . . $ app_ds_rds_validate(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action) { |
| 444 | int ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.; |
| 445 | |
| 446 | struct oscap_sourcecxx . . $ oscap_source# *rds = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(action->ds_actioncxx . . $ oscap_action#ds_action.->filecxx . . $ ds_action#file.); |
| 447 | if (oscap_source_validatecxx . . $ oscap_source_validate(58e1cfedb30f1c20).(rds, reportercxx . . $ reporter(710d628f83af7da6)., (void *) action) != 0) { |
| 448 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(rds); |
| 449 | goto cleanup; |
| 450 | } |
| 451 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(rds); |
| 452 | |
| 453 | ret = OSCAP_OKcxx . . $ OSCAP_OK.; |
| 454 | |
| 455 | cleanup: |
| 456 | oscap_print_errorcxx . . $ oscap_print_error(49f6e7a06ebc5aa8).(); |
| 457 | |
| 458 | freecxx . . $ free(5d22bdacc48458e8).(action->ds_actioncxx . . $ oscap_action#ds_action.); |
| 459 | return ret; |
| 460 | } |