| 1 | /* |
| 2 | * Copyright 2012 Red Hat Inc., Durham, North Carolina. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public |
| 16 | * License along with this library; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | * |
| 19 | * Authors: |
| 20 | * Martin Preisler <[email protected]> |
| 21 | */ |
| 22 | |
| 23 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 24 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 25 | #endif |
| 26 | |
| 27 | #include "public/scap_ds.h"cxx . . $ `<file>/src/DS/public/scap_ds.h`/ |
| 28 | |
| 29 | #include "public/oscap.h"cxx . . $ `<file>/src/common/public/oscap.h`/ |
| 30 | #include "public/oscap_text.h"cxx . . $ `<file>/src/common/public/oscap_text.h`/ |
| 31 | |
| 32 | #include "ds_common.h"cxx . . $ `<file>/src/DS/ds_common.h`/ |
| 33 | #include "ds_sds_session_priv.h"cxx . . $ `<file>/src/DS/ds_sds_session_priv.h`/ |
| 34 | #include "sds_priv.h"cxx . . $ `<file>/src/DS/sds_priv.h`/ |
| 35 | |
| 36 | #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/ |
| 37 | #include "common/_error.h"cxx . . $ `<file>/src/common/_error.h`/ |
| 38 | #include "common/util.h"cxx . . $ `<file>/src/common/util.h`/ |
| 39 | #include "common/list.h"cxx . . $ `<file>/src/common/list.h`/ |
| 40 | #include "common/oscap_acquire.h"cxx . . $ `<file>/src/common/oscap_acquire.h`/ |
| 41 | #include "source/oscap_source_priv.h"cxx . . $ `<file>/src/source/oscap_source_priv.h`/ |
| 42 | #include "source/public/oscap_source.h"cxx . . $ `<file>/src/source/public/oscap_source.h`/ |
| 43 | #include "oscap_helpers.h"cxx . . $ `<file>/src/common/public/oscap_helpers.h`/ |
| 44 | |
| 45 | #include <sys/stat.h> |
| 46 | #include <time.h> |
| 47 | |
| 48 | #include <libxml/xmlreader.h> |
| 49 | #include <libxml/parser.h> |
| 50 | #include <libxml/tree.h> |
| 51 | #include <libxml/xpath.h> |
| 52 | #include <libxml/xpathInternals.h> |
| 53 | |
| 54 | #include <string.h> |
| 55 | #include <fcntl.h> |
| 56 | #ifdef OS_WINDOWS |
| 57 | #include <io.h> |
| 58 | #else |
| 59 | #include <unistd.h> |
| 60 | #endif |
| 61 | |
| 62 | #ifndef MAXPATHLEN |
| 63 | # define MAXPATHLENcxx . . $ `src/DS/sds.c:63:12`! 1024 |
| 64 | #endif |
| 65 | |
| 66 | #ifndef O_NOFOLLOWcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:141:10`! |
| 67 | #define O_NOFOLLOW 0 |
| 68 | #endif |
| 69 | |
| 70 | static const char* datastream_ns_uricxx . . $ datastream_ns_uri. = "http://scap.nist.gov/schema/scap/source/1.2"; |
| 71 | static const char* xlink_ns_uricxx . . $ xlink_ns_uri. = "http://www.w3.org/1999/xlink"; |
| 72 | static const char* cat_ns_uricxx . . $ cat_ns_uri. = "urn:oasis:names:tc:entity:xmlns:xml:catalog"; |
| 73 | static const char* sce_xccdf_ns_uricxx . . $ sce_xccdf_ns_uri. = "http://open-scap.org/page/SCE_xccdf_stream"; |
| 74 | |
| 75 | xmlNodePtrcxx . . $ xmlNodePtr# node_get_child_elementcxx . . $ node_get_child_element(2d28023bb541569e).(xmlNodePtrcxx . . $ xmlNodePtr# parent, const char* name) |
| 76 | { |
| 77 | xmlNodePtrcxx . . $ xmlNodePtr# candidate = parent->childrencxx . . $ _xmlNode#children.; |
| 78 | |
| 79 | for (; candidate != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; candidate = candidate->nextcxx . . $ _xmlNode#next.) |
| 80 | { |
| 81 | if (candidate->typecxx . . $ _xmlNode#type. != XML_ELEMENT_NODEcxx . . $ XML_ELEMENT_NODE.) |
| 82 | continue; |
| 83 | |
| 84 | if (name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && strcmpcxx . . $ strcmp(5ae29d726ae57f88).((const char*)(candidate->namecxx . . $ _xmlNode#name.), name) != 0) |
| 85 | continue; |
| 86 | |
| 87 | return candidate; |
| 88 | } |
| 89 | |
| 90 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 91 | } |
| 92 | |
| 93 | xmlNodecxx . . $ xmlNode# *containter_get_component_ref_by_idcxx . . $ containter_get_component_ref_by_id(2d28023bb541569e).(xmlNodecxx . . $ xmlNode# *container, const char *component_id) |
| 94 | { |
| 95 | for (xmlNodecxx . . $ xmlNode# *component_ref = container->childrencxx . . $ _xmlNode#children.; component_ref != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; component_ref = component_ref->nextcxx . . $ _xmlNode#next.) |
| 96 | { |
| 97 | if (component_ref->typecxx . . $ _xmlNode#type. != XML_ELEMENT_NODEcxx . . $ XML_ELEMENT_NODE.) |
| 98 | continue; |
| 99 | |
| 100 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).((const char*)(component_ref->namecxx . . $ _xmlNode#name.), "component-ref") != 0) |
| 101 | continue; |
| 102 | |
| 103 | xmlCharcxx . . $ xmlChar#* cref_id = xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(component_ref, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 104 | // if cref_id is zero we have encountered a fatal error that will be handled |
| 105 | // in ds_sds_dump_component_ref |
| 106 | if (component_id && cref_id && strcmpcxx . . $ strcmp(5ae29d726ae57f88).(component_id, (char*)cref_id) != 0) |
| 107 | { |
| 108 | xmlFreecxx . . $ xmlFree.(cref_id); |
| 109 | continue; |
| 110 | } |
| 111 | xmlFreecxx . . $ xmlFree.(cref_id); |
| 112 | return component_ref; |
| 113 | } |
| 114 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 115 | } |
| 116 | |
| 117 | xmlNodePtrcxx . . $ xmlNodePtr# ds_sds_find_component_refcxx . . $ ds_sds_find_component_ref(2d28023bb541569e).(xmlNodePtrcxx . . $ xmlNodePtr# datastream, const char* id) |
| 118 | { |
| 119 | /* This searches for a ds:component-ref (XLink) element with a given id. |
| 120 | * It returns a first such element in a given ds:data-stream. |
| 121 | */ |
| 122 | xmlNodePtrcxx . . $ xmlNodePtr# cref_parent = datastream->childrencxx . . $ _xmlNode#children.; |
| 123 | |
| 124 | for (; cref_parent != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; cref_parent = cref_parent->nextcxx . . $ _xmlNode#next.) |
| 125 | { |
| 126 | if (cref_parent->typecxx . . $ _xmlNode#type. != XML_ELEMENT_NODEcxx . . $ XML_ELEMENT_NODE.) |
| 127 | continue; |
| 128 | xmlNodecxx . . $ xmlNode# *component_ref = containter_get_component_ref_by_idcxx . . $ containter_get_component_ref_by_id(2d28023bb541569e).(cref_parent, id); |
| 129 | if (component_ref != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 130 | return component_ref; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 135 | } |
| 136 | |
| 137 | xmlNodePtrcxx . . $ xmlNodePtr# lookup_component_in_collectioncxx . . $ lookup_component_in_collection(2d28023bb541569e).(xmlNodePtrcxx . . $ xmlNodePtr# root, const char *component_id) |
| 138 | { |
| 139 | xmlNodePtrcxx . . $ xmlNodePtr# component = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 140 | xmlNodePtrcxx . . $ xmlNodePtr# candidate = root->childrencxx . . $ _xmlNode#children.; |
| 141 | |
| 142 | for (; candidate != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; candidate = candidate->nextcxx . . $ _xmlNode#next.) |
| 143 | { |
| 144 | if (candidate->typecxx . . $ _xmlNode#type. != XML_ELEMENT_NODEcxx . . $ XML_ELEMENT_NODE.) |
| 145 | continue; |
| 146 | |
| 147 | if ((strcmpcxx . . $ strcmp(5ae29d726ae57f88).((const char*)(candidate->namecxx . . $ _xmlNode#name.), "component") != 0) && |
| 148 | (strcmpcxx . . $ strcmp(5ae29d726ae57f88).((const char*)(candidate->namecxx . . $ _xmlNode#name.), "extended-component") != 0)) |
| 149 | continue; |
| 150 | |
| 151 | char* candidate_id = (char*)xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(candidate, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 152 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(candidate_id, component_id) == 0) |
| 153 | { |
| 154 | component = candidate; |
| 155 | xmlFreecxx . . $ xmlFree.(candidate_id); |
| 156 | break; |
| 157 | } |
| 158 | xmlFreecxx . . $ xmlFree.(candidate_id); |
| 159 | } |
| 160 | return component; |
| 161 | } |
| 162 | |
| 163 | static int ds_sds_dump_component_scecxx . . $ ds_sds_dump_component_sce(6f1aaaa17d993d3e).(const xmlNodecxx . . $ xmlNode# *script_node, const char *component_id, const char *filename) |
| 164 | { |
| 165 | if (script_node) { |
| 166 | if (oscap_acquire_ensure_parent_dircxx . . $ oscap_acquire_ensure_parent_dir(5c4306d8553b3696).(filename) < 0) { |
| 167 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Error while creating script parent directory for file '%s' of (id='%s')", filename, component_id); |
| 168 | return -1; |
| 169 | } |
| 170 | // TODO: should we check whether the component is extended? |
| 171 | int fd; |
| 172 | xmlCharcxx . . $ xmlChar#* text_contents = xmlNodeGetContentcxx . . $ xmlNodeGetContent(cadd6f62b3cc3aeb).(script_node); |
| 173 | if ((fd = opencxx . . $ open(e156e3aa1e5c4ad1).(filename, O_CREATcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:47:10`! | O_TRUNCcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:56:10`! | O_NOFOLLOWcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:141:10`! | O_WRONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:44:9`!, 0700)) < 0) { |
| 174 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Error while creating script component (id='%s') to file '%s'.", component_id, filename); |
| 175 | xmlFreecxx . . $ xmlFree.(text_contents); |
| 176 | return -1; |
| 177 | } |
| 178 | FILEcxx . . $ FILE#* output_file = fdopencxx . . $ fdopen(8f4e2d7350ebd077).(fd, "w"); |
| 179 | if (output_file == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 180 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Error while dumping script component (id='%s') to file '%s'.", component_id, filename); |
| 181 | xmlFreecxx . . $ xmlFree.(text_contents); |
| 182 | closecxx . . $ close(7864480464b09eea).(fd); |
| 183 | return -1; |
| 184 | } |
| 185 | // TODO: error checking, fprintf should return strlen((const char*)text_contents) |
| 186 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(output_file, "%s", text_contents ? (char*)text_contents : ""); |
| 187 | #ifndef OS_WINDOWS |
| 188 | // NB: This code is for SCE scripts |
| 189 | if (fchmodcxx . . $ fchmod(b223e862534b1804).(fd, 0700) != 0) { |
| 190 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Failed to set executable permission on script (id='%s') that was split to '%s'.", component_id, filename); |
| 191 | } |
| 192 | #endif |
| 193 | |
| 194 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Successfully dumped script component (id='%s') to file '%s'.", component_id, filename); |
| 195 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(output_file); |
| 196 | xmlFreecxx . . $ xmlFree.(text_contents); |
| 197 | return 0; |
| 198 | } |
| 199 | else { |
| 200 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Error while dumping script component (id='%s') to file '%s'. " |
| 201 | "The script element was empty!", component_id, filename); |
| 202 | return -1; |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * Load oscap source from file |
| 208 | * Filename is relatively to datastream file |
| 209 | */ |
| 210 | static struct oscap_sourcecxx . . $ oscap_source# *load_referenced_sourcecxx . . $ load_referenced_source(48739439d81565a0).(const struct ds_sds_sessioncxx . . $ ds_sds_session# *session, const char *filename) |
| 211 | { |
| 212 | const char* readable_origin = ds_sds_session_get_readable_origincxx . . $ ds_sds_session_get_readable_origin(5b4526c9616cba95).(session); |
| 213 | assertcxx . . $ `/usr/include/assert.h:50:10`!(readable_origin != NULL); |
| 214 | char* readable_origin_cp = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(readable_origin); |
| 215 | |
| 216 | char *dir_name = oscap_dirnamecxx . . $ oscap_dirname(7a9722d75b371431).(readable_origin_cp); |
| 217 | char* full_path = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("%s/%s", dir_name, filename); |
| 218 | freecxx . . $ free(5d22bdacc48458e8).(dir_name); |
| 219 | |
| 220 | struct oscap_sourcecxx . . $ oscap_source# *source_file = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(full_path); |
| 221 | |
| 222 | freecxx . . $ free(5d22bdacc48458e8).(full_path); |
| 223 | freecxx . . $ free(5d22bdacc48458e8).(readable_origin_cp); |
| 224 | |
| 225 | return source_file; |
| 226 | } |
| 227 | |
| 228 | static int ds_sds_register_scecxx . . $ ds_sds_register_sce(56f5b208247cfa28).(struct ds_sds_sessioncxx . . $ ds_sds_session# *session, xmlNodePtrcxx . . $ xmlNodePtr# component_inner_root, const char* component_id, const char* target_filename_dirname, const char* relative_filepath) |
| 229 | { |
| 230 | // the cast is safe to do because we are using the GNU basename, it doesn't |
| 231 | // modify the string |
| 232 | char *file_basename = oscap_basenamecxx . . $ oscap_basename(7a9722d75b371431).((char*)relative_filepath); |
| 233 | char *sce_filename = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("%s/%s/%s",ds_sds_session_get_target_dircxx . . $ ds_sds_session_get_target_dir(f40a0d7511d218a2).(session), target_filename_dirname, file_basename); |
| 234 | freecxx . . $ free(5d22bdacc48458e8).(file_basename); |
| 235 | const int ret = ds_sds_dump_component_scecxx . . $ ds_sds_dump_component_sce(6f1aaaa17d993d3e).(component_inner_root->childrencxx . . $ _xmlNode#children., component_id, sce_filename); |
| 236 | freecxx . . $ free(5d22bdacc48458e8).(sce_filename); |
| 237 | return ret; |
| 238 | } |
| 239 | |
| 240 | static int ds_sds_register_xmlDoccxx . . $ ds_sds_register_xmlDoc(4feca09654c3682a).(struct ds_sds_sessioncxx . . $ ds_sds_session# *session, xmlDoccxx . . $ xmlDoc#* doc, xmlNodePtrcxx . . $ xmlNodePtr# component_inner_root, const char *relative_filepath) |
| 241 | { |
| 242 | xmlDoccxx . . $ xmlDoc# *new_doc = ds_doc_from_foreign_nodecxx . . $ ds_doc_from_foreign_node(c7a03b65c170feae).(component_inner_root, doc); |
| 243 | if (new_doc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 244 | return -1; |
| 245 | } |
| 246 | |
| 247 | struct oscap_sourcecxx . . $ oscap_source# *component_source = oscap_source_new_from_xmlDoccxx . . $ oscap_source_new_from_xmlDoc(20d5db8f38e74517).(new_doc, relative_filepath); |
| 248 | |
| 249 | if (ds_sds_session_register_component_sourcecxx . . $ ds_sds_session_register_component_source(4e906d719ef7817e).(session, relative_filepath, component_source) != 0) { |
| 250 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(component_source); |
| 251 | } |
| 252 | return 0; // TODO: Return value of ds_sds_session_register_component_source(). (commit message) |
| 253 | } |
| 254 | |
| 255 | static int ds_sds_register_componentcxx . . $ ds_sds_register_component(860711700dfba07a).(struct ds_sds_sessioncxx . . $ ds_sds_session# *session, xmlDoccxx . . $ xmlDoc#* doc, xmlNodePtrcxx . . $ xmlNodePtr# component_inner_root, const char* component_id, const char* target_filename_dirname, const char* relative_filepath) |
| 256 | { |
| 257 | if (component_inner_root == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 258 | { |
| 259 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Found component (id='%s') but it has no element contents, nothing to dump, skipping...", component_id); |
| 260 | return -1; |
| 261 | } |
| 262 | |
| 263 | // If the inner root is script, we have to treat it in a special way |
| 264 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).((const char*)component_inner_root->namecxx . . $ _xmlNode#name., "script") == 0) { |
| 265 | return ds_sds_register_scecxx . . $ ds_sds_register_sce(56f5b208247cfa28).(session, component_inner_root, component_id, target_filename_dirname, relative_filepath); |
| 266 | } else { |
| 267 | // Otherwise we create a new XML doc we will dump the contents to. |
| 268 | // We can't just dump node "innerXML" because namespaces have to be |
| 269 | // handled. |
| 270 | return ds_sds_register_xmlDoccxx . . $ ds_sds_register_xmlDoc(4feca09654c3682a).(session, doc, component_inner_root, relative_filepath); |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | static xmlNodePtrcxx . . $ xmlNodePtr# ds_sds_get_component_root_by_idcxx . . $ ds_sds_get_component_root_by_id(fa7f9e35a4c9c2b5).(xmlDoccxx . . $ xmlDoc# *doc, const char* component_id) |
| 275 | { |
| 276 | xmlNodePtrcxx . . $ xmlNodePtr# component; |
| 277 | if (component_id == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 278 | component = (xmlNodePtrcxx . . $ xmlNodePtr#)doc; |
| 279 | } else { |
| 280 | xmlNodePtrcxx . . $ xmlNodePtr# root = xmlDocGetRootElementcxx . . $ xmlDocGetRootElement(53aa9a676bd496f2).(doc); |
| 281 | component = lookup_component_in_collectioncxx . . $ lookup_component_in_collection(2d28023bb541569e).(root, component_id); |
| 282 | if (component == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 283 | { |
| 284 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Component of given id '%s' was not found in the document.", component_id); |
| 285 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | return node_get_child_elementcxx . . $ node_get_child_element(2d28023bb541569e).(component, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 290 | } |
| 291 | |
| 292 | static int ds_sds_dump_local_componentcxx . . $ ds_sds_dump_local_component(a5d23d0dc71a6e19).(const char* component_id, struct ds_sds_sessioncxx . . $ ds_sds_session# *session, const char *target_filename_dirname, const char *relative_filepath) |
| 293 | { |
| 294 | xmlDoccxx . . $ xmlDoc# *doc = ds_sds_session_get_xmlDoccxx . . $ ds_sds_session_get_xmlDoc(ef366a06b12ae0ef).(session); |
| 295 | |
| 296 | xmlNodePtrcxx . . $ xmlNodePtr# inner_root = ds_sds_get_component_root_by_idcxx . . $ ds_sds_get_component_root_by_id(fa7f9e35a4c9c2b5).(doc, component_id); |
| 297 | |
| 298 | return ds_sds_register_componentcxx . . $ ds_sds_register_component(860711700dfba07a).(session, doc, inner_root, component_id, target_filename_dirname, relative_filepath); |
| 299 | } |
| 300 | |
| 301 | static int ds_sds_dump_file_componentcxx . . $ ds_sds_dump_file_component(c29e09ff4393b124).(const char* external_file, const char* component_id, struct ds_sds_sessioncxx . . $ ds_sds_session# *session, const char *target_filename_dirname, const char *relative_filepath) |
| 302 | { |
| 303 | int ret = 0; |
| 304 | |
| 305 | struct oscap_sourcecxx . . $ oscap_source# *source_file = load_referenced_sourcecxx . . $ load_referenced_source(48739439d81565a0).(session, external_file); |
| 306 | xmlDoccxx . . $ xmlDoc# *doc = oscap_source_get_xmlDoccxx . . $ oscap_source_get_xmlDoc(51aac4e66711e6e6).(source_file); |
| 307 | |
| 308 | if (doc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 309 | ret = -1; |
| 310 | goto cleanup; |
| 311 | } |
| 312 | |
| 313 | xmlNodePtrcxx . . $ xmlNodePtr# inner_root = ds_sds_get_component_root_by_idcxx . . $ ds_sds_get_component_root_by_id(fa7f9e35a4c9c2b5).(doc, component_id); |
| 314 | |
| 315 | if (ds_sds_register_componentcxx . . $ ds_sds_register_component(860711700dfba07a).(session, doc, inner_root, component_id, target_filename_dirname, relative_filepath) != 0) { |
| 316 | ret = -1; |
| 317 | goto cleanup; |
| 318 | } |
| 319 | |
| 320 | cleanup: |
| 321 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source_file); |
| 322 | return ret; |
| 323 | } |
| 324 | |
| 325 | static int ds_dsd_dump_remote_componentcxx . . $ ds_dsd_dump_remote_component(c29e09ff4393b124).(const char* url, const char* component_id, struct ds_sds_sessioncxx . . $ ds_sds_session# *session, const char *target_filename_dirname, const char *relative_filepath) |
| 326 | { |
| 327 | int ret = 0; |
| 328 | size_t memory_size = 0; |
| 329 | |
| 330 | ds_sds_session_remote_resources_progresscxx . . $ ds_sds_session_remote_resources_progress(47b8220cbc7dd248).(session)(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, "Downloading: %s ... ", url); |
| 331 | |
| 332 | char* mem = oscap_acquire_url_downloadcxx . . $ oscap_acquire_url_download(90074be1d80d1697).(url, &memory_size); |
| 333 | if (mem == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 334 | ds_sds_session_remote_resources_progresscxx . . $ ds_sds_session_remote_resources_progress(47b8220cbc7dd248).(session)(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, "error\n", url); |
| 335 | return -1; |
| 336 | } |
| 337 | |
| 338 | ds_sds_session_remote_resources_progresscxx . . $ ds_sds_session_remote_resources_progress(47b8220cbc7dd248).(session)(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, "ok\n", url); |
| 339 | |
| 340 | struct oscap_sourcecxx . . $ oscap_source# *source_file = oscap_source_new_take_memorycxx . . $ oscap_source_new_take_memory(2b1f5a784648902c).(mem, memory_size, url); |
| 341 | xmlDoccxx . . $ xmlDoc# *doc = oscap_source_get_xmlDoccxx . . $ oscap_source_get_xmlDoc(51aac4e66711e6e6).(source_file); |
| 342 | |
| 343 | if (doc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 344 | ret = -1; |
| 345 | goto cleanup; |
| 346 | } |
| 347 | |
| 348 | xmlNodePtrcxx . . $ xmlNodePtr# inner_root = ds_sds_get_component_root_by_idcxx . . $ ds_sds_get_component_root_by_id(fa7f9e35a4c9c2b5).(doc, component_id); |
| 349 | |
| 350 | if (ds_sds_register_componentcxx . . $ ds_sds_register_component(860711700dfba07a).(session, doc, inner_root, component_id, target_filename_dirname, relative_filepath) != 0) { |
| 351 | ret = -1; |
| 352 | goto cleanup; |
| 353 | } |
| 354 | |
| 355 | cleanup: |
| 356 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source_file); |
| 357 | return ret; |
| 358 | } |
| 359 | |
| 360 | static char *compose_target_filename_dirnamecxx . . $ compose_target_filename_dirname(a713fe7b9a57cf96).(const char *relative_filepath, const char* sub_dir) |
| 361 | { |
| 362 | char* filename_cpy = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("./%s", relative_filepath); |
| 363 | char* file_reldir = oscap_dirnamecxx . . $ oscap_dirname(7a9722d75b371431).(filename_cpy); |
| 364 | |
| 365 | char* target_filename_dirname = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("%s/%s",sub_dir, file_reldir); |
| 366 | freecxx . . $ free(5d22bdacc48458e8).(file_reldir); |
| 367 | freecxx . . $ free(5d22bdacc48458e8).(filename_cpy); |
| 368 | |
| 369 | return target_filename_dirname; |
| 370 | } |
| 371 | |
| 372 | static int _handle_disabled_downloadscxx . . $ _handle_disabled_downloads(ab4c5bad0ab970f2).(struct ds_sds_sessioncxx . . $ ds_sds_session# *session, const char *relative_filepath, const char *xlink_href, const char *component_id, const char *target_filename_dirname, const char *cref_id, const char *url) |
| 373 | { |
| 374 | /* |
| 375 | * If fetching remote resources isn't allowed by the user let's take a look |
| 376 | * whether there exists a file whose file name is equal to @name attribute |
| 377 | * of the uri element within the catalog of the previously processed |
| 378 | * component-ref which pointed us to the currently processed component-ref. |
| 379 | * Note that the @name attribute value has been passed as relative_filepath |
| 380 | * in the recursive call of ds_sds_dump_component_ref_as. If such file |
| 381 | * exists, we will assume that it's a local copy of the remote component |
| 382 | * located at the URL defined in @xlink:href. This way people can provide |
| 383 | * the previously downloaded component which might be useful on systems with |
| 384 | * limited internet access. This behavior is allowed only when --local-files |
| 385 | * is used on the command line. |
| 386 | * See: https://bugzilla.redhat.com/show_bug.cgi?id=1970527 |
| 387 | * See: https://access.redhat.com/solutions/5185891 |
| 388 | */ |
| 389 | const char *local_files = ds_sds_session_local_filescxx . . $ ds_sds_session_local_files(f40a0d7511d218a2).(session); |
| 390 | if (local_files == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 391 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! fetch_remote_resources_suggested = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 392 | if (!fetch_remote_resources_suggested) { |
| 393 | fetch_remote_resources_suggested = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 394 | ds_sds_session_remote_resources_progresscxx . . $ ds_sds_session_remote_resources_progress(47b8220cbc7dd248).(session)(truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, |
| 395 | "WARNING: Datastream component '%s' points out to the remote '%s'. Use '--fetch-remote-resources' option to download it.\n", |
| 396 | cref_id, url); |
| 397 | } |
| 398 | |
| 399 | ds_sds_session_remote_resources_progresscxx . . $ ds_sds_session_remote_resources_progress(47b8220cbc7dd248).(session)(truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, |
| 400 | "WARNING: Skipping '%s' file which is referenced from datastream\n", |
| 401 | url); |
| 402 | // -2 means that remote resources were not downloaded |
| 403 | return -2; |
| 404 | } |
| 405 | char *local_filepath = oscap_path_joincxx . . $ oscap_path_join(a713fe7b9a57cf96).(local_files, relative_filepath); |
| 406 | struct statcxx . . $ stat# sb; |
| 407 | if (statcxx . . $ stat(a9cd1e23e96f423c).(local_filepath, &sb) == 0) { |
| 408 | ds_sds_session_remote_resources_progresscxx . . $ ds_sds_session_remote_resources_progress(47b8220cbc7dd248).(session)(truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, |
| 409 | "WARNING: Using local file '%s' instead of '%s'", |
| 410 | local_filepath, xlink_href); |
| 411 | struct oscap_sourcecxx . . $ oscap_source# *source_file = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(local_filepath); |
| 412 | xmlDoccxx . . $ xmlDoc# *doc = oscap_source_pop_xmlDoccxx . . $ oscap_source_pop_xmlDoc(51aac4e66711e6e6).(source_file); |
| 413 | if (doc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 414 | freecxx . . $ free(5d22bdacc48458e8).(local_filepath); |
| 415 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source_file); |
| 416 | return -1; |
| 417 | } |
| 418 | xmlNodePtrcxx . . $ xmlNodePtr# inner_root = ds_sds_get_component_root_by_idcxx . . $ ds_sds_get_component_root_by_id(fa7f9e35a4c9c2b5).(doc, component_id); |
| 419 | |
| 420 | if (ds_sds_register_componentcxx . . $ ds_sds_register_component(860711700dfba07a).(session, doc, inner_root, component_id, target_filename_dirname, relative_filepath) != 0) { |
| 421 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source_file); |
| 422 | freecxx . . $ free(5d22bdacc48458e8).(local_filepath); |
| 423 | return -1; |
| 424 | } |
| 425 | freecxx . . $ free(5d22bdacc48458e8).(local_filepath); |
| 426 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source_file); |
| 427 | return 0; |
| 428 | } |
| 429 | ds_sds_session_remote_resources_progresscxx . . $ ds_sds_session_remote_resources_progress(47b8220cbc7dd248).(session)(truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, |
| 430 | "WARNING: Data stream component '%s' points out to the remote '%s'. " \ |
| 431 | "The option --local-files '%s' has been provided, but the file '%s' can't be used locally: %s.\n", |
| 432 | cref_id, url, local_files, local_filepath, strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 433 | freecxx . . $ free(5d22bdacc48458e8).(local_filepath); |
| 434 | return -2; |
| 435 | } |
| 436 | |
| 437 | static int ds_sds_dump_component_by_hrefcxx . . $ ds_sds_dump_component_by_href(8e430a23e1de52c6).(struct ds_sds_sessioncxx . . $ ds_sds_session# *session, char* xlink_href, char *target_filename_dirname, const char* relative_filepath, char* cref_id, char **component_id) |
| 438 | { |
| 439 | if (!xlink_href || strlencxx . . $ strlen(751346f8406fd082).(xlink_href) < 2) |
| 440 | { |
| 441 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "No or invalid xlink:href attribute on given component-ref."); |
| 442 | return -1; |
| 443 | } |
| 444 | |
| 445 | if (xlink_href[0] == '#') |
| 446 | { |
| 447 | *component_id = xlink_href + 1; |
| 448 | |
| 449 | return ds_sds_dump_local_componentcxx . . $ ds_sds_dump_local_component(a5d23d0dc71a6e19).(*component_id, session, target_filename_dirname, relative_filepath); |
| 450 | |
| 451 | } else if (oscap_str_startswithcxx . . $ oscap_str_startswith(b7a7aa4a824b7595).(xlink_href, "file:")){ |
| 452 | |
| 453 | char* sep = strchrcxx . . $ strchr(2050848944e00d54).(xlink_href, '#'); |
| 454 | |
| 455 | const char *filename = xlink_href + strlencxx . . $ strlen(751346f8406fd082).("file:"); |
| 456 | |
| 457 | if (sep == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 458 | *component_id = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 459 | } else { |
| 460 | *sep = '\0'; |
| 461 | *component_id = sep + 1; |
| 462 | } |
| 463 | |
| 464 | return ds_sds_dump_file_componentcxx . . $ ds_sds_dump_file_component(c29e09ff4393b124).(filename, *component_id, session, target_filename_dirname, relative_filepath); |
| 465 | |
| 466 | } else if (oscap_acquire_url_is_supportedcxx . . $ oscap_acquire_url_is_supported(c5f7da30cbc0f4e9).(xlink_href)){ |
| 467 | char *sep = strchrcxx . . $ strchr(2050848944e00d54).(xlink_href, '#'); |
| 468 | |
| 469 | char* url = xlink_href; |
| 470 | |
| 471 | if (sep == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 472 | *component_id = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 473 | } else { |
| 474 | *sep = '\0'; |
| 475 | *component_id = sep + 1; |
| 476 | } |
| 477 | |
| 478 | if (!ds_sds_session_fetch_remote_resourcescxx . . $ ds_sds_session_fetch_remote_resources(718d9c4b5b99b7c5).(session)) { |
| 479 | return _handle_disabled_downloadscxx . . $ _handle_disabled_downloads(ab4c5bad0ab970f2).( |
| 480 | session, relative_filepath, xlink_href, *component_id, |
| 481 | target_filename_dirname, cref_id, url); |
| 482 | } |
| 483 | |
| 484 | return ds_dsd_dump_remote_componentcxx . . $ ds_dsd_dump_remote_component(c29e09ff4393b124).(url, *component_id, session, target_filename_dirname, relative_filepath); |
| 485 | } else { |
| 486 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Unsupported type of xlink:href attribute on given component-ref - '%s'.", xlink_href); |
| 487 | return -1; |
| 488 | } |
| 489 | return 0; |
| 490 | } |
| 491 | |
| 492 | int ds_sds_dump_component_ref_ascxx . . $ ds_sds_dump_component_ref_as(505a2532abaea7ee).(const xmlNodePtrcxx . . $ xmlNodePtr# component_ref, struct ds_sds_sessioncxx . . $ ds_sds_session# *session, const char* sub_dir, const char* relative_filepath) |
| 493 | { |
| 494 | char* cref_id = (char*)xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(component_ref, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 495 | if (!cref_id) |
| 496 | { |
| 497 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "No or invalid id attribute on given component-ref."); |
| 498 | xmlFreecxx . . $ xmlFree.(cref_id); |
| 499 | return -1; |
| 500 | } |
| 501 | |
| 502 | char* xlink_href = (char*)xmlGetNsPropcxx . . $ xmlGetNsProp(3f3adc55d94f1650).(component_ref, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "href", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! xlink_ns_uricxx . . $ xlink_ns_uri.); |
| 503 | |
| 504 | char* target_filename_dirname = compose_target_filename_dirnamecxx . . $ compose_target_filename_dirname(a713fe7b9a57cf96).(relative_filepath, sub_dir); |
| 505 | |
| 506 | char* component_id = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 507 | |
| 508 | // make a copy of xlink_href because ds_sds_dump_component_by_href modifies its second argument |
| 509 | char *xlink_href_copy = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(xlink_href); |
| 510 | int ret = ds_sds_dump_component_by_hrefcxx . . $ ds_sds_dump_component_by_href(8e430a23e1de52c6).(session, xlink_href, target_filename_dirname, relative_filepath, cref_id, &component_id); |
| 511 | if (!oscap_htable_addcxx . . $ oscap_htable_add(d9abe78f59fa00eb).(ds_sds_session_get_component_uriscxx . . $ ds_sds_session_get_component_uris(a99418aa193592e1).(session), cref_id, xlink_href_copy)) { |
| 512 | freecxx . . $ free(5d22bdacc48458e8).(xlink_href_copy); |
| 513 | } |
| 514 | |
| 515 | xmlFreecxx . . $ xmlFree.(xlink_href); |
| 516 | xmlFreecxx . . $ xmlFree.(cref_id); |
| 517 | |
| 518 | if (ret == -2) { |
| 519 | // A remote component was not dumped |
| 520 | // It should be ok to continue without it |
| 521 | freecxx . . $ free(5d22bdacc48458e8).(target_filename_dirname); |
| 522 | return 0; |
| 523 | } else if (ret != 0) { |
| 524 | freecxx . . $ free(5d22bdacc48458e8).(target_filename_dirname); |
| 525 | return -1; |
| 526 | } |
| 527 | |
| 528 | xmlNodePtrcxx . . $ xmlNodePtr# catalog = node_get_child_elementcxx . . $ node_get_child_element(2d28023bb541569e).(component_ref, "catalog"); |
| 529 | if (catalog) |
| 530 | { |
| 531 | xmlNodePtrcxx . . $ xmlNodePtr# uri = catalog->childrencxx . . $ _xmlNode#children.; |
| 532 | |
| 533 | for (; uri != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; uri = uri->nextcxx . . $ _xmlNode#next.) |
| 534 | { |
| 535 | if (uri->typecxx . . $ _xmlNode#type. != XML_ELEMENT_NODEcxx . . $ XML_ELEMENT_NODE.) |
| 536 | continue; |
| 537 | |
| 538 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).((const char*)(uri->namecxx . . $ _xmlNode#name.), "uri") != 0) |
| 539 | continue; |
| 540 | |
| 541 | char* name = (char*)xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(uri, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "name"); |
| 542 | |
| 543 | if (!name) |
| 544 | { |
| 545 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "No 'name' attribute for a component referenced in the catalog of component '%s'.", component_id); |
| 546 | freecxx . . $ free(5d22bdacc48458e8).(target_filename_dirname); |
| 547 | return -1; |
| 548 | } |
| 549 | |
| 550 | char* str_uri = (char*)xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(uri, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "uri"); |
| 551 | |
| 552 | if (!str_uri || strlencxx . . $ strlen(751346f8406fd082).(str_uri) < 2) |
| 553 | { |
| 554 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "No or invalid 'uri' attribute for a component referenced in the catalog of component '%s'.", component_id); |
| 555 | xmlFreecxx . . $ xmlFree.(str_uri); |
| 556 | xmlFreecxx . . $ xmlFree.(name); |
| 557 | freecxx . . $ free(5d22bdacc48458e8).(target_filename_dirname); |
| 558 | return -1; |
| 559 | } |
| 560 | |
| 561 | // the pointer arithmetics simply skips the first character which is '#' |
| 562 | assertcxx . . $ `/usr/include/assert.h:50:10`!(str_uri[0] == '#'); |
| 563 | xmlNodePtrcxx . . $ xmlNodePtr# cat_component_ref = ds_sds_find_component_refcxx . . $ ds_sds_find_component_ref(2d28023bb541569e).(ds_sds_session_get_selected_datastreamcxx . . $ ds_sds_session_get_selected_datastream(ccff434c2b6278bf).(session), str_uri + 1 * sizeof(char)); |
| 564 | |
| 565 | if (!cat_component_ref) |
| 566 | { |
| 567 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "component-ref with given id '%s' wasn't found in the document! We are looking for it because it's in the catalog of component '%s'.", str_uri + 1 * sizeof(char), component_id); |
| 568 | xmlFreecxx . . $ xmlFree.(str_uri); |
| 569 | xmlFreecxx . . $ xmlFree.(name); |
| 570 | freecxx . . $ free(5d22bdacc48458e8).(target_filename_dirname); |
| 571 | return -1; |
| 572 | } |
| 573 | xmlFreecxx . . $ xmlFree.(str_uri); |
| 574 | |
| 575 | if (ds_sds_dump_component_ref_ascxx . . $ ds_sds_dump_component_ref_as(505a2532abaea7ee).(cat_component_ref, session, target_filename_dirname, name) != 0) |
| 576 | { |
| 577 | xmlFreecxx . . $ xmlFree.(name); |
| 578 | freecxx . . $ free(5d22bdacc48458e8).(target_filename_dirname); |
| 579 | return -1; // no need to call oscap_seterr here, it's already set |
| 580 | } |
| 581 | |
| 582 | xmlFreecxx . . $ xmlFree.(name); |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | freecxx . . $ free(5d22bdacc48458e8).(target_filename_dirname); |
| 587 | |
| 588 | |
| 589 | return 0; |
| 590 | } |
| 591 | |
| 592 | int ds_sds_dump_component_refcxx . . $ ds_sds_dump_component_ref(96cde591c87a42e1).(const xmlNodePtrcxx . . $ xmlNodePtr# component_ref, struct ds_sds_sessioncxx . . $ ds_sds_session# *session) |
| 593 | { |
| 594 | char* cref_id = (char*)xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(component_ref, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 595 | if (!cref_id) |
| 596 | { |
| 597 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "No or invalid id attribute on given component-ref."); |
| 598 | xmlFreecxx . . $ xmlFree.(cref_id); |
| 599 | return -1; |
| 600 | } |
| 601 | |
| 602 | int result = ds_sds_dump_component_ref_ascxx . . $ ds_sds_dump_component_ref_as(505a2532abaea7ee).(component_ref, session, ".", cref_id); |
| 603 | xmlFreecxx . . $ xmlFree.(cref_id); |
| 604 | |
| 605 | // if result is -1, oscap_seterr was already called, no need to call it again |
| 606 | return result; |
| 607 | } |
| 608 | |
| 609 | xmlNodePtrcxx . . $ xmlNodePtr# ds_sds_lookup_datastream_in_collectioncxx . . $ ds_sds_lookup_datastream_in_collection(fa7f9e35a4c9c2b5).(xmlDocPtrcxx . . $ xmlDocPtr# doc, const char *datastream_id) |
| 610 | { |
| 611 | xmlNodePtrcxx . . $ xmlNodePtr# root = xmlDocGetRootElementcxx . . $ xmlDocGetRootElement(53aa9a676bd496f2).(doc); |
| 612 | |
| 613 | xmlNodePtrcxx . . $ xmlNodePtr# datastream = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 614 | xmlNodePtrcxx . . $ xmlNodePtr# candidate_datastream = root->childrencxx . . $ _xmlNode#children.; |
| 615 | |
| 616 | for (; candidate_datastream != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; candidate_datastream = candidate_datastream->nextcxx . . $ _xmlNode#next.) |
| 617 | { |
| 618 | if (candidate_datastream->typecxx . . $ _xmlNode#type. != XML_ELEMENT_NODEcxx . . $ XML_ELEMENT_NODE.) |
| 619 | continue; |
| 620 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).((const char*)(candidate_datastream->namecxx . . $ _xmlNode#name.), "data-stream") != 0) |
| 621 | continue; |
| 622 | |
| 623 | // at this point it is sure to be a <data-stream> element |
| 624 | |
| 625 | char* candidate_id = (char*)xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(candidate_datastream, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 626 | if (datastream_id == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || oscap_streqcxx . . $ oscap_streq(b7a7aa4a824b7595).(datastream_id, candidate_id)) { |
| 627 | datastream = candidate_datastream; |
| 628 | xmlFreecxx . . $ xmlFree.(candidate_id); |
| 629 | break; |
| 630 | } |
| 631 | xmlFreecxx . . $ xmlFree.(candidate_id); |
| 632 | } |
| 633 | |
| 634 | return datastream; |
| 635 | } |
| 636 | |
| 637 | static inline int ds_sds_compose_component_add_script_contentcxx . . $ ds_sds_compose_component_add_script_content(74c422745e7770d7).(xmlNodecxx . . $ xmlNode# *component, const char *filepath) |
| 638 | { |
| 639 | FILEcxx . . $ FILE#* f = fopencxx . . $ fopen(82ec0787cd37e0a3).(filepath, "r"); |
| 640 | if (!f) { |
| 641 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_GLIBCcxx . . $ `src/common/public/oscap_error.h:58:9`!, "Can't read plain text from file '%s'.", filepath); |
| 642 | return -1; |
| 643 | } |
| 644 | |
| 645 | fseekcxx . . $ fseek(543fae30d249f6b1).(f, 0, SEEK_ENDcxx . . $ `<external>/14710646456994434043/fcntl.h:139:10`!); |
| 646 | long int length = ftellcxx . . $ ftell(1dcafcd8ef4c6e6c).(f); |
| 647 | fseekcxx . . $ fseek(543fae30d249f6b1).(f, 0, SEEK_SETcxx . . $ `<external>/14710646456994434043/fcntl.h:137:10`!); |
| 648 | if (length >= 0) { |
| 649 | char* buffer = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).((length + 1) * sizeof(char)); |
| 650 | if (freadcxx . . $ fread(738fc8ac1d711e58).(buffer, length, 1, f) != 1) { |
| 651 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_GLIBCcxx . . $ `src/common/public/oscap_error.h:58:9`!, "Error while reading from file '%s'.", filepath); |
| 652 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(f); |
| 653 | freecxx . . $ free(5d22bdacc48458e8).(buffer); |
| 654 | return -1; |
| 655 | } |
| 656 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(f); |
| 657 | buffer[length] = '\0'; |
| 658 | xmlNsPtrcxx . . $ xmlNsPtr# local_ns = xmlNewNscxx . . $ xmlNewNs(f962c8aae91c9a10).(component, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! sce_xccdf_ns_uricxx . . $ sce_xccdf_ns_uri., BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "oscap-sce-xccdf-stream"); |
| 659 | xmlNewTextChildcxx . . $ xmlNewTextChild(4c74f4d7754e7bc8).(component, local_ns, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "script", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! buffer); |
| 660 | freecxx . . $ free(5d22bdacc48458e8).(buffer); |
| 661 | return 0; |
| 662 | } else { |
| 663 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_GLIBCcxx . . $ `src/common/public/oscap_error.h:58:9`!, "No data read from file '%s'.", filepath); |
| 664 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(f); |
| 665 | return -1; |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | static int ds_sds_compose_add_component_internalcxx . . $ ds_sds_compose_add_component_internal(5d8bae95df76c87f).(xmlDocPtrcxx . . $ xmlDocPtr# doc, xmlNodePtrcxx . . $ xmlNodePtr# datastream, struct oscap_sourcecxx . . $ oscap_source# *component_source, const char* comp_id, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! extended) |
| 670 | { |
| 671 | xmlNsPtrcxx . . $ xmlNsPtr# ds_ns = xmlSearchNsByHrefcxx . . $ xmlSearchNsByHref(d0fb0b6b99319c4).(doc, datastream, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! datastream_ns_uricxx . . $ datastream_ns_uri.); |
| 672 | if (!ds_ns) |
| 673 | { |
| 674 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_GLIBCcxx . . $ `src/common/public/oscap_error.h:58:9`!, |
| 675 | "Unable to find namespace '%s' in the XML DOM tree when create " |
| 676 | "source datastream. This is most likely an internal error!", |
| 677 | datastream_ns_uri); |
| 678 | return -1; |
| 679 | } |
| 680 | |
| 681 | char file_timestamp[32]; |
| 682 | strncpycxx . . $ strncpy(255158a415b673b0).(file_timestamp, "0000-00-00T00:00:00", sizeof(file_timestamp)); |
| 683 | |
| 684 | const char *filepath = oscap_source_get_filepathcxx . . $ oscap_source_get_filepath(e20df36988f50e45).(component_source); |
| 685 | struct statcxx . . $ stat# file_stat; |
| 686 | if (statcxx . . $ stat(a9cd1e23e96f423c).(filepath, &file_stat) == 0) { |
| 687 | time_tcxx . . $ time_t# mtime; |
| 688 | struct tmcxx . . $ tm# result; |
| 689 | char *source_date_epoch = getenvcxx . . $ getenv(a8b8e32347182212).("SOURCE_DATE_EPOCH"); |
| 690 | if (source_date_epoch == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || |
| 691 | (mtime = (time_tcxx . . $ time_t#)strtollcxx . . $ strtoll(c50972e7488cbac6).(source_date_epoch, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 10)) <= 0 || |
| 692 | mtime > file_stat.st_mtimecxx . . $ `<external>/16045971866008360577/struct_stat.h:78:11`!) |
| 693 | mtime = file_stat.st_mtimecxx . . $ `<external>/16045971866008360577/struct_stat.h:78:11`!; |
| 694 | strftimecxx . . $ strftime(98e75925167c4f1b).(file_timestamp, 32, "%Y-%m-%dT%H:%M:%S", localtime_rcxx . . $ localtime_r(92e3d173686db852).(&mtime, &result)); |
| 695 | } else { |
| 696 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_GLIBCcxx . . $ `src/common/public/oscap_error.h:58:9`!, "Could not find file %s: %s.", filepath, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 697 | // Return positive number, indicating less severe problem. |
| 698 | // Rationale: When an OVAL file is missing during a scan it it not considered |
| 699 | // to be deal breaker (it shall have 'notchecked' result), thus we shall allow |
| 700 | // DataStreams with missing OVAL. |
| 701 | return 1; |
| 702 | } |
| 703 | |
| 704 | xmlNodePtrcxx . . $ xmlNodePtr# component = xmlNewNodecxx . . $ xmlNewNode(cc9f3f2e425bac4).(ds_ns, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! (extended ? "extended-component" : "component")); |
| 705 | xmlSetPropcxx . . $ xmlSetProp(6ee5a6130c40eb8b).(component, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! comp_id); |
| 706 | xmlSetPropcxx . . $ xmlSetProp(6ee5a6130c40eb8b).(component, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "timestamp", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! file_timestamp); |
| 707 | |
| 708 | xmlNodePtrcxx . . $ xmlNodePtr# doc_root = xmlDocGetRootElementcxx . . $ xmlDocGetRootElement(53aa9a676bd496f2).(doc); |
| 709 | |
| 710 | if (extended) { |
| 711 | if (ds_sds_compose_component_add_script_contentcxx . . $ ds_sds_compose_component_add_script_content(74c422745e7770d7).(component, filepath) == -1) { |
| 712 | xmlFreeNodecxx . . $ xmlFreeNode(5712c9d4a25253).(component); |
| 713 | return -1; |
| 714 | } |
| 715 | // extended components always go at the end |
| 716 | xmlAddChildcxx . . $ xmlAddChild(93e65f4d4ebd68bd).(doc_root, component); |
| 717 | } else { |
| 718 | xmlDoccxx . . $ xmlDoc# *component_doc = oscap_source_get_xmlDoccxx . . $ oscap_source_get_xmlDoc(51aac4e66711e6e6).(component_source); |
| 719 | if (!component_doc) { |
| 720 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Could not read/parse XML of given input file at path '%s'.", filepath); |
| 721 | xmlFreeNodecxx . . $ xmlFreeNode(5712c9d4a25253).(component); |
| 722 | return -1; |
| 723 | } |
| 724 | |
| 725 | xmlNodePtrcxx . . $ xmlNodePtr# component_root = xmlDocGetRootElementcxx . . $ xmlDocGetRootElement(53aa9a676bd496f2).(component_doc); |
| 726 | |
| 727 | xmlDOMWrapCtxtPtrcxx . . $ xmlDOMWrapCtxtPtr# wrap_ctxt = xmlDOMWrapNewCtxtcxx . . $ xmlDOMWrapNewCtxt(cf68cd44886dfff6).(); |
| 728 | |
| 729 | xmlNodePtrcxx . . $ xmlNodePtr# res_component_root = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 730 | if (xmlDOMWrapCloneNodecxx . . $ xmlDOMWrapCloneNode(1d59bf3bdf7b6ffa).(wrap_ctxt, component_doc, component_root, &res_component_root, doc, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 1, 0) != 0) |
| 731 | { |
| 732 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, |
| 733 | "Cannot clone node when adding component from file '%s' with id '%s' while " |
| 734 | "creating source datastream.", filepath, comp_id); |
| 735 | |
| 736 | xmlDOMWrapFreeCtxtcxx . . $ xmlDOMWrapFreeCtxt(e842b388ca82d286).(wrap_ctxt); |
| 737 | xmlFreeNodecxx . . $ xmlFreeNode(5712c9d4a25253).(component); |
| 738 | |
| 739 | return -1; |
| 740 | } |
| 741 | if (xmlDOMWrapReconcileNamespacescxx . . $ xmlDOMWrapReconcileNamespaces(d2ba4bf5093ab1a3).(wrap_ctxt, res_component_root, 0) != 0) |
| 742 | { |
| 743 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, |
| 744 | "Cannot reconcile namespaces when adding component from file '%s' with id '%s' while " |
| 745 | "creating source datastream.", filepath, comp_id); |
| 746 | |
| 747 | xmlDOMWrapFreeCtxtcxx . . $ xmlDOMWrapFreeCtxt(e842b388ca82d286).(wrap_ctxt); |
| 748 | xmlFreeNodecxx . . $ xmlFreeNode(5712c9d4a25253).(component); |
| 749 | |
| 750 | return -1; |
| 751 | } |
| 752 | |
| 753 | xmlAddChildcxx . . $ xmlAddChild(93e65f4d4ebd68bd).(component, res_component_root); |
| 754 | |
| 755 | xmlDOMWrapFreeCtxtcxx . . $ xmlDOMWrapFreeCtxt(e842b388ca82d286).(wrap_ctxt); |
| 756 | |
| 757 | // this component is not extended, we have to figure out if there |
| 758 | // already is an extended-component and if so, add it right before |
| 759 | // that component |
| 760 | |
| 761 | xmlNodePtrcxx . . $ xmlNodePtr# first_extended_component = node_get_child_elementcxx . . $ node_get_child_element(2d28023bb541569e).(doc_root, "extended-component"); |
| 762 | if (first_extended_component == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 763 | { |
| 764 | // no extended component yet, add to the end |
| 765 | xmlAddChildcxx . . $ xmlAddChild(93e65f4d4ebd68bd).(doc_root, component); |
| 766 | } |
| 767 | else |
| 768 | { |
| 769 | xmlAddPrevSiblingcxx . . $ xmlAddPrevSibling(93e65f4d4ebd68bd).(first_extended_component, component); |
| 770 | } |
| 771 | } |
| 772 | |
| 773 | return 0; |
| 774 | } |
| 775 | |
| 776 | static int ds_sds_compose_catalog_has_uricxx . . $ ds_sds_compose_catalog_has_uri(256fedf1748d1e8f).(xmlDocPtrcxx . . $ xmlDocPtr# doc, xmlNodePtrcxx . . $ xmlNodePtr# catalog, const char* uri) |
| 777 | { |
| 778 | xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# xpathCtx = xmlXPathNewContextcxx . . $ xmlXPathNewContext(87a056aba6f65ba7).(doc); |
| 779 | if (xpathCtx == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 780 | { |
| 781 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Error: unable to create a new XPath context."); |
| 782 | return -1; |
| 783 | } |
| 784 | |
| 785 | xmlXPathRegisterNscxx . . $ xmlXPathRegisterNs(8fbdd0521ec1038).(xpathCtx, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "cat", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! cat_ns_uricxx . . $ cat_ns_uri.); |
| 786 | xmlXPathRegisterNscxx . . $ xmlXPathRegisterNs(8fbdd0521ec1038).(xpathCtx, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "xlink", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! xlink_ns_uricxx . . $ xlink_ns_uri.); |
| 787 | |
| 788 | // limit xpath execution to just the catalog node |
| 789 | // this is done for performance reasons |
| 790 | xpathCtx->nodecxx . . $ _xmlXPathContext#node. = catalog; |
| 791 | |
| 792 | char *expression = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("cat:uri[@uri = '%s']", uri); |
| 793 | if (expression == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 794 | { |
| 795 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_OSCAPcxx . . $ `src/common/public/oscap_error.h:60:9`!, "Error: Unable to create XPath expression."); |
| 796 | xmlXPathFreeContextcxx . . $ xmlXPathFreeContext(a63b128a98dd7774).(xpathCtx); |
| 797 | |
| 798 | return -1; |
| 799 | } |
| 800 | |
| 801 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# xpathObj = xmlXPathEvalExpressioncxx . . $ xmlXPathEvalExpression(217f200a3c77f61d).( |
| 802 | BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! expression, |
| 803 | xpathCtx); |
| 804 | |
| 805 | freecxx . . $ free(5d22bdacc48458e8).(expression); |
| 806 | |
| 807 | if (xpathObj == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 808 | { |
| 809 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Error: Unable to evaluate XPath expression."); |
| 810 | xmlXPathFreeContextcxx . . $ xmlXPathFreeContext(a63b128a98dd7774).(xpathCtx); |
| 811 | |
| 812 | return -1; |
| 813 | } |
| 814 | |
| 815 | int result = 0; |
| 816 | |
| 817 | xmlNodeSetPtrcxx . . $ xmlNodeSetPtr# nodeset = xpathObj->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.; |
| 818 | if (nodeset != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 819 | result = nodeset->nodeNrcxx . . $ _xmlNodeSet#nodeNr. > 0 ? 0 : 1; |
| 820 | |
| 821 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(xpathObj); |
| 822 | xmlXPathFreeContextcxx . . $ xmlXPathFreeContext(a63b128a98dd7774).(xpathCtx); |
| 823 | |
| 824 | return result; |
| 825 | } |
| 826 | |
| 827 | // takes given relative filepath and mangles it so that it's acceptable |
| 828 | // as a component id |
| 829 | char* ds_sds_mangle_filepathcxx . . $ ds_sds_mangle_filepath(a8b8e32347182212).(const char* filepath) |
| 830 | { |
| 831 | if (filepath == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 832 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 833 | |
| 834 | // the string will grow 2x the size in the worst case (every char is /) |
| 835 | // TODO: We can do better than this by counting the slashes |
| 836 | char* ret = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(strlencxx . . $ strlen(751346f8406fd082).(filepath) * sizeof(char) * 2); |
| 837 | |
| 838 | const char* src_it = filepath; |
| 839 | char* dst_it = ret; |
| 840 | |
| 841 | while (*src_it) |
| 842 | { |
| 843 | if (*src_it == '/') |
| 844 | { |
| 845 | *dst_it++ = '-'; |
| 846 | *dst_it++ = '-'; |
| 847 | } |
| 848 | else if (*src_it == '@') { |
| 849 | *dst_it++ = '-'; |
| 850 | *dst_it++ = '-'; |
| 851 | } |
| 852 | else |
| 853 | { |
| 854 | *dst_it++ = *src_it; |
| 855 | } |
| 856 | |
| 857 | src_it++; |
| 858 | } |
| 859 | |
| 860 | *dst_it = '\0'; |
| 861 | |
| 862 | return ret; |
| 863 | } |
| 864 | |
| 865 | static int ds_sds_compose_add_component_with_refcxx . . $ ds_sds_compose_add_component_with_ref(7f8e0434cb01b286).(xmlDocPtrcxx . . $ xmlDocPtr# doc, xmlNodePtrcxx . . $ xmlNodePtr# datastream, const char* filepath, const char* cref_id); |
| 866 | |
| 867 | static inline const char *_get_dep_xpath_for_typecxx . . $ _get_dep_xpath_for_type(f7ae7e56280f18ae).(int document_type) |
| 868 | { |
| 869 | static const char *xccdf_xpath = "//*[local-name() = 'check-content-ref']"; |
| 870 | static const char *cpe_xpath = "//*[local-name() = 'check']"; |
| 871 | if (document_type == OSCAP_DOCUMENT_CPE_DICTIONARYcxx . . $ OSCAP_DOCUMENT_CPE_DICTIONARY.) |
| 872 | return cpe_xpath; |
| 873 | return xccdf_xpath; |
| 874 | } |
| 875 | |
| 876 | static int ds_sds_compose_add_component_dependenciescxx . . $ ds_sds_compose_add_component_dependencies(6e5a60b4303aeb2a).(xmlDocPtrcxx . . $ xmlDocPtr# doc, xmlNodePtrcxx . . $ xmlNodePtr# datastream, struct oscap_sourcecxx . . $ oscap_source# *component_source, xmlNodePtrcxx . . $ xmlNodePtr# catalog, int component_type) |
| 877 | { |
| 878 | xmlDocPtrcxx . . $ xmlDocPtr# component_doc = oscap_source_get_xmlDoccxx . . $ oscap_source_get_xmlDoc(51aac4e66711e6e6).(component_source); |
| 879 | if (component_doc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 880 | { |
| 881 | return -1; |
| 882 | } |
| 883 | |
| 884 | xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# xpathCtx = xmlXPathNewContextcxx . . $ xmlXPathNewContext(87a056aba6f65ba7).(component_doc); |
| 885 | if (xpathCtx == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 886 | { |
| 887 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Error: unable to create new XPath context."); |
| 888 | return -1; |
| 889 | } |
| 890 | |
| 891 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# xpathObj = xmlXPathEvalExpressioncxx . . $ xmlXPathEvalExpression(217f200a3c77f61d).( |
| 892 | // we want robustness and support for future versions, this expression |
| 893 | // retrieves check-content-refs from any namespace |
| 894 | BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! _get_dep_xpath_for_typecxx . . $ _get_dep_xpath_for_type(f7ae7e56280f18ae).(component_type), |
| 895 | xpathCtx); |
| 896 | if (xpathObj == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 897 | { |
| 898 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Error: Unable to evaluate XPath expression."); |
| 899 | xmlXPathFreeContextcxx . . $ xmlXPathFreeContext(a63b128a98dd7774).(xpathCtx); |
| 900 | |
| 901 | return -1; |
| 902 | } |
| 903 | |
| 904 | xmlNsPtrcxx . . $ xmlNsPtr# cat_ns = xmlSearchNsByHrefcxx . . $ xmlSearchNsByHref(d0fb0b6b99319c4).(doc, datastream, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! cat_ns_uricxx . . $ cat_ns_uri.); |
| 905 | |
| 906 | xmlNodeSetPtrcxx . . $ xmlNodeSetPtr# nodeset = xpathObj->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.; |
| 907 | if (nodeset != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 908 | { |
| 909 | struct oscap_htablecxx . . $ oscap_htable# *exported = oscap_htable_newcxx . . $ oscap_htable_new(3c1cb2b6f390ad38).(); |
| 910 | char* filepath_cpy = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(oscap_source_readable_origincxx . . $ oscap_source_readable_origin(1485dc36ee4b63be).(component_source)); |
| 911 | char *dir = oscap_dirnamecxx . . $ oscap_dirname(7a9722d75b371431).(filepath_cpy); |
| 912 | |
| 913 | for (int i = 0; i < nodeset->nodeNrcxx . . $ _xmlNodeSet#nodeNr.; i++) |
| 914 | { |
| 915 | xmlNodePtrcxx . . $ xmlNodePtr# node = nodeset->nodeTabcxx . . $ _xmlNodeSet#nodeTab.[i]; |
| 916 | |
| 917 | if (node->typecxx . . $ _xmlNode#type. != XML_ELEMENT_NODEcxx . . $ XML_ELEMENT_NODE.) |
| 918 | continue; |
| 919 | |
| 920 | if (xmlHasPropcxx . . $ xmlHasProp(b74e98cace1a33d3).(node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "href")) |
| 921 | { |
| 922 | char* href = (char*)xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "href"); |
| 923 | if (oscap_htable_getcxx . . $ oscap_htable_get(f5c7e8ff6c970cd3).(exported, href) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 924 | // This path has been already exported. Do not export duplicate. |
| 925 | xmlFreecxx . . $ xmlFree.(href); |
| 926 | continue; |
| 927 | } |
| 928 | oscap_htable_addcxx . . $ oscap_htable_add(d9abe78f59fa00eb).(exported, href, ""); |
| 929 | |
| 930 | if (oscap_acquire_url_is_supportedcxx . . $ oscap_acquire_url_is_supported(c5f7da30cbc0f4e9).(href)) { |
| 931 | /* If the referenced component is remote one, do not include |
| 932 | * it within the DataStream. Such component shall only be |
| 933 | * downloaded once the scan is run. */ |
| 934 | xmlFreecxx . . $ xmlFree.(href); |
| 935 | continue; |
| 936 | } |
| 937 | |
| 938 | // skip over file:// if it's used in the file href |
| 939 | const char *altered_href = oscap_str_startswithcxx . . $ oscap_str_startswith(b7a7aa4a824b7595).(href, "file://") ? href + 7 : href; |
| 940 | |
| 941 | char* real_path = (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dir, "") == 0 || strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dir, ".") == 0 || altered_href[0] == '/') ? |
| 942 | oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(altered_href) : oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("%s/%s", dir, altered_href); |
| 943 | |
| 944 | char* mangled_path = ds_sds_mangle_filepathcxx . . $ ds_sds_mangle_filepath(a8b8e32347182212).(real_path); |
| 945 | char* cref_id = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("scap_org.open-scap_cref_%s", mangled_path); |
| 946 | |
| 947 | int counter = 0; |
| 948 | while (ds_sds_find_component_refcxx . . $ ds_sds_find_component_ref(2d28023bb541569e).(datastream, cref_id) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 949 | // While the given component ID already exists in the document. |
| 950 | freecxx . . $ free(5d22bdacc48458e8).(cref_id); |
| 951 | cref_id = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("scap_org.open-scap_cref_%s%03d", mangled_path, counter++); |
| 952 | } |
| 953 | freecxx . . $ free(5d22bdacc48458e8).(mangled_path); |
| 954 | |
| 955 | char* uri = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("#%s", cref_id); |
| 956 | |
| 957 | // we don't want duplicated uri elements in the catalog |
| 958 | if (ds_sds_compose_catalog_has_uricxx . . $ ds_sds_compose_catalog_has_uri(256fedf1748d1e8f).(doc, catalog, uri) == 0) |
| 959 | { |
| 960 | freecxx . . $ free(5d22bdacc48458e8).(uri); |
| 961 | freecxx . . $ free(5d22bdacc48458e8).(cref_id); |
| 962 | freecxx . . $ free(5d22bdacc48458e8).(real_path); |
| 963 | xmlFreecxx . . $ xmlFree.(href); |
| 964 | continue; |
| 965 | } |
| 966 | |
| 967 | int ret = ds_sds_compose_add_component_with_refcxx . . $ ds_sds_compose_add_component_with_ref(7f8e0434cb01b286).(doc, datastream, real_path, cref_id); |
| 968 | if (ret == 0) { |
| 969 | xmlNodePtrcxx . . $ xmlNodePtr# catalog_uri = xmlNewNodecxx . . $ xmlNewNode(cc9f3f2e425bac4).(cat_ns, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "uri"); |
| 970 | xmlSetPropcxx . . $ xmlSetProp(6ee5a6130c40eb8b).(catalog_uri, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "name", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! href); |
| 971 | xmlSetPropcxx . . $ xmlSetProp(6ee5a6130c40eb8b).(catalog_uri, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "uri", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! uri); |
| 972 | xmlAddChildcxx . . $ xmlAddChild(93e65f4d4ebd68bd).(catalog, catalog_uri); |
| 973 | } |
| 974 | |
| 975 | freecxx . . $ free(5d22bdacc48458e8).(cref_id); |
| 976 | freecxx . . $ free(5d22bdacc48458e8).(uri); |
| 977 | freecxx . . $ free(5d22bdacc48458e8).(real_path); |
| 978 | xmlFreecxx . . $ xmlFree.(href); |
| 979 | |
| 980 | if (ret < 0) { |
| 981 | // oscap_seterr has already been called |
| 982 | oscap_htable_free0cxx . . $ oscap_htable_free0(dbd8f9d05ba37fd5).(exported); |
| 983 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(xpathObj); |
| 984 | xmlXPathFreeContextcxx . . $ xmlXPathFreeContext(a63b128a98dd7774).(xpathCtx); |
| 985 | freecxx . . $ free(5d22bdacc48458e8).(filepath_cpy); |
| 986 | freecxx . . $ free(5d22bdacc48458e8).(dir); |
| 987 | return -1; |
| 988 | } |
| 989 | |
| 990 | } |
| 991 | } |
| 992 | |
| 993 | freecxx . . $ free(5d22bdacc48458e8).(dir); |
| 994 | oscap_htable_free0cxx . . $ oscap_htable_free0(dbd8f9d05ba37fd5).(exported); |
| 995 | freecxx . . $ free(5d22bdacc48458e8).(filepath_cpy); |
| 996 | } |
| 997 | |
| 998 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(xpathObj); |
| 999 | xmlXPathFreeContextcxx . . $ xmlXPathFreeContext(a63b128a98dd7774).(xpathCtx); |
| 1000 | |
| 1001 | return 0; |
| 1002 | } |
| 1003 | |
| 1004 | static int ds_sds_compose_has_component_refcxx . . $ ds_sds_compose_has_component_ref(7f8e0434cb01b286).(xmlDocPtrcxx . . $ xmlDocPtr# doc, xmlNodePtrcxx . . $ xmlNodePtr# datastream, const char* filepath, const char* cref_id) |
| 1005 | { |
| 1006 | xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# xpathCtx = xmlXPathNewContextcxx . . $ xmlXPathNewContext(87a056aba6f65ba7).(doc); |
| 1007 | if (xpathCtx == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1008 | { |
| 1009 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Error: unable to create new XPath context."); |
| 1010 | return -1; |
| 1011 | } |
| 1012 | |
| 1013 | xmlXPathRegisterNscxx . . $ xmlXPathRegisterNs(8fbdd0521ec1038).(xpathCtx, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "ds", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! datastream_ns_uricxx . . $ datastream_ns_uri.); |
| 1014 | xmlXPathRegisterNscxx . . $ xmlXPathRegisterNs(8fbdd0521ec1038).(xpathCtx, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "xlink", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! xlink_ns_uricxx . . $ xlink_ns_uri.); |
| 1015 | |
| 1016 | // limit xpath execution to just the datastream node |
| 1017 | // this is done for performance reasons |
| 1018 | xpathCtx->nodecxx . . $ _xmlXPathContext#node. = datastream; |
| 1019 | |
| 1020 | char *expression = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("*/ds:component-ref[@xlink:href = '#%s' and @id = '%s']", filepath, cref_id); |
| 1021 | if (expression == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1022 | { |
| 1023 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_OSCAPcxx . . $ `src/common/public/oscap_error.h:60:9`!, "Error: Unable to create XPath expression."); |
| 1024 | xmlXPathFreeContextcxx . . $ xmlXPathFreeContext(a63b128a98dd7774).(xpathCtx); |
| 1025 | |
| 1026 | return -1; |
| 1027 | } |
| 1028 | |
| 1029 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# xpathObj = xmlXPathEvalExpressioncxx . . $ xmlXPathEvalExpression(217f200a3c77f61d).( |
| 1030 | BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! expression, |
| 1031 | xpathCtx); |
| 1032 | |
| 1033 | freecxx . . $ free(5d22bdacc48458e8).(expression); |
| 1034 | |
| 1035 | if (xpathObj == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1036 | { |
| 1037 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Error: Unable to evaluate XPath expression."); |
| 1038 | xmlXPathFreeContextcxx . . $ xmlXPathFreeContext(a63b128a98dd7774).(xpathCtx); |
| 1039 | |
| 1040 | return -1; |
| 1041 | } |
| 1042 | |
| 1043 | int result = 1; |
| 1044 | |
| 1045 | xmlNodeSetPtrcxx . . $ xmlNodeSetPtr# nodeset = xpathObj->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.; |
| 1046 | if (nodeset != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1047 | result = nodeset->nodeNrcxx . . $ _xmlNodeSet#nodeNr. > 0 ? 0 : 1; |
| 1048 | |
| 1049 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(xpathObj); |
| 1050 | xmlXPathFreeContextcxx . . $ xmlXPathFreeContext(a63b128a98dd7774).(xpathCtx); |
| 1051 | |
| 1052 | return result; |
| 1053 | } |
| 1054 | |
| 1055 | static int ds_sds_compose_add_component_source_with_refcxx . . $ ds_sds_compose_add_component_source_with_ref(11b694b88a14bb70).(xmlDocPtrcxx . . $ xmlDocPtr# doc, xmlNodePtrcxx . . $ xmlNodePtr# datastream, struct oscap_sourcecxx . . $ oscap_source# *component_source, const char* cref_id) |
| 1056 | { |
| 1057 | xmlNsPtrcxx . . $ xmlNsPtr# ds_ns = xmlSearchNsByHrefcxx . . $ xmlSearchNsByHref(d0fb0b6b99319c4).(doc, datastream, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! datastream_ns_uricxx . . $ datastream_ns_uri.); |
| 1058 | xmlNsPtrcxx . . $ xmlNsPtr# xlink_ns = xmlSearchNsByHrefcxx . . $ xmlSearchNsByHref(d0fb0b6b99319c4).(doc, datastream, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! xlink_ns_uricxx . . $ xlink_ns_uri.); |
| 1059 | xmlNsPtrcxx . . $ xmlNsPtr# cat_ns = xmlSearchNsByHrefcxx . . $ xmlSearchNsByHref(d0fb0b6b99319c4).(doc, datastream, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! cat_ns_uricxx . . $ cat_ns_uri.); |
| 1060 | const char *filepath = oscap_source_get_filepathcxx . . $ oscap_source_get_filepath(e20df36988f50e45).(component_source); |
| 1061 | |
| 1062 | // In case we already have this component we just return, no need to add |
| 1063 | // it twice. We will typically have many references to OVAL files, adding |
| 1064 | // component for each reference would create unnecessarily huge datastreams |
| 1065 | int result = ds_sds_compose_has_component_refcxx . . $ ds_sds_compose_has_component_ref(7f8e0434cb01b286).(doc, datastream, filepath, cref_id); |
| 1066 | if (result == 0) |
| 1067 | { |
| 1068 | return 0; |
| 1069 | } |
| 1070 | |
| 1071 | if (result == -1) |
| 1072 | { |
| 1073 | // no need to free anything |
| 1074 | // oscap_seterr has already been called |
| 1075 | return -1; |
| 1076 | } |
| 1077 | |
| 1078 | xmlNodePtrcxx . . $ xmlNodePtr# cref_catalog = xmlNewNodecxx . . $ xmlNewNode(cc9f3f2e425bac4).(cat_ns, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "catalog"); |
| 1079 | xmlNodePtrcxx . . $ xmlNodePtr# cref_parent; |
| 1080 | |
| 1081 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! extended_component = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 1082 | |
| 1083 | oscap_document_type_tcxx . . $ oscap_document_type_t# doc_type = oscap_source_get_scap_typecxx . . $ oscap_source_get_scap_type(1b623b3fe9f5b871).(component_source); |
| 1084 | if (doc_type == OSCAP_DOCUMENT_XCCDFcxx . . $ OSCAP_DOCUMENT_XCCDF.) |
| 1085 | { |
| 1086 | cref_parent = node_get_child_elementcxx . . $ node_get_child_element(2d28023bb541569e).(datastream, "checklists"); |
| 1087 | if (ds_sds_compose_add_component_dependenciescxx . . $ ds_sds_compose_add_component_dependencies(6e5a60b4303aeb2a).(doc, datastream, component_source, cref_catalog, doc_type) != 0) |
| 1088 | { |
| 1089 | // oscap_seterr has already been called |
| 1090 | return -1; |
| 1091 | } |
| 1092 | } |
| 1093 | else if (doc_type == OSCAP_DOCUMENT_CPE_DICTIONARYcxx . . $ OSCAP_DOCUMENT_CPE_DICTIONARY. || doc_type == OSCAP_DOCUMENT_CPE_LANGUAGEcxx . . $ OSCAP_DOCUMENT_CPE_LANGUAGE.) |
| 1094 | { |
| 1095 | cref_parent = node_get_child_elementcxx . . $ node_get_child_element(2d28023bb541569e).(datastream, "dictionaries"); |
| 1096 | if (cref_parent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1097 | cref_parent = xmlNewNodecxx . . $ xmlNewNode(cc9f3f2e425bac4).(ds_ns, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "dictionaries"); |
| 1098 | // The <ds:dictionaries element must as the first child of the datastream |
| 1099 | xmlNodePtrcxx . . $ xmlNodePtr# first_child = datastream->xmlChildrenNodecxx . . $ `<external>/15370075748625258712/tree.h:908:9`!; |
| 1100 | xmlNodePtrcxx . . $ xmlNodePtr# new_node = (first_child == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? |
| 1101 | xmlAddChildcxx . . $ xmlAddChild(93e65f4d4ebd68bd).(datastream, cref_parent) : xmlAddPrevSiblingcxx . . $ xmlAddPrevSibling(93e65f4d4ebd68bd).(first_child, cref_parent); |
| 1102 | if (new_node == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1103 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Failed to add dictionaries element to the DataStream."); |
| 1104 | xmlFreeNodecxx . . $ xmlFreeNode(5712c9d4a25253).(cref_parent); |
| 1105 | cref_parent = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1106 | } |
| 1107 | } |
| 1108 | if (ds_sds_compose_add_component_dependenciescxx . . $ ds_sds_compose_add_component_dependencies(6e5a60b4303aeb2a).(doc, datastream, component_source, cref_catalog, doc_type) != 0) { |
| 1109 | return -1; |
| 1110 | } |
| 1111 | } |
| 1112 | else if (doc_type == OSCAP_DOCUMENT_OVAL_DEFINITIONScxx . . $ OSCAP_DOCUMENT_OVAL_DEFINITIONS. || doc_type == OSCAP_DOCUMENT_OCILcxx . . $ OSCAP_DOCUMENT_OCIL.) |
| 1113 | { |
| 1114 | cref_parent = node_get_child_elementcxx . . $ node_get_child_element(2d28023bb541569e).(datastream, "checks"); |
| 1115 | } |
| 1116 | else |
| 1117 | { |
| 1118 | // not an XCCDF file, not an OVAL file, not a dict/lang, assume it goes into extended components |
| 1119 | extended_component = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 1120 | cref_parent = node_get_child_elementcxx . . $ node_get_child_element(2d28023bb541569e).(datastream, "extended-components"); |
| 1121 | } |
| 1122 | |
| 1123 | char* mangled_filepath = ds_sds_mangle_filepathcxx . . $ ds_sds_mangle_filepath(a8b8e32347182212).(filepath); |
| 1124 | // extended components (sadly :-/) use a different ID scheme and have |
| 1125 | // a different element name than "normal" components |
| 1126 | char* comp_id = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("scap_org.open-scap_%scomp_%s", |
| 1127 | extended_component ? "e" : "", mangled_filepath); |
| 1128 | |
| 1129 | int counter = 0; |
| 1130 | xmlNodePtrcxx . . $ xmlNodePtr# root = xmlDocGetRootElementcxx . . $ xmlDocGetRootElement(53aa9a676bd496f2).(doc); |
| 1131 | while (lookup_component_in_collectioncxx . . $ lookup_component_in_collection(2d28023bb541569e).(root, comp_id) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1132 | // While a component of the given ID already exists, generate a new one |
| 1133 | freecxx . . $ free(5d22bdacc48458e8).(comp_id); |
| 1134 | comp_id = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("scap_org.open-scap_%scomp_%s%03d", |
| 1135 | extended_component ? "e" : "", mangled_filepath, counter++); |
| 1136 | } |
| 1137 | |
| 1138 | freecxx . . $ free(5d22bdacc48458e8).(mangled_filepath); |
| 1139 | |
| 1140 | result = ds_sds_compose_add_component_internalcxx . . $ ds_sds_compose_add_component_internal(5d8bae95df76c87f).(doc, datastream, component_source, comp_id, extended_component); |
| 1141 | if (result == 0) { |
| 1142 | xmlNodePtrcxx . . $ xmlNodePtr# cref = xmlNewNodecxx . . $ xmlNewNode(cc9f3f2e425bac4).(ds_ns, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "component-ref"); |
| 1143 | xmlAddChildcxx . . $ xmlAddChild(93e65f4d4ebd68bd).(cref, cref_catalog); |
| 1144 | xmlSetPropcxx . . $ xmlSetProp(6ee5a6130c40eb8b).(cref, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! cref_id); |
| 1145 | |
| 1146 | char *xlink_href = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("#%s", comp_id); |
| 1147 | xmlSetNsPropcxx . . $ xmlSetNsProp(9b3cf13d34b7936f).(cref, xlink_ns, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "href", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! xlink_href); |
| 1148 | freecxx . . $ free(5d22bdacc48458e8).(xlink_href); |
| 1149 | |
| 1150 | if (xmlAddChildcxx . . $ xmlAddChild(93e65f4d4ebd68bd).(cref_parent, cref) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1151 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Failed to add component-ref/@id='%s' to the DataStream.", cref_id); |
| 1152 | result = 1; |
| 1153 | } |
| 1154 | } |
| 1155 | |
| 1156 | freecxx . . $ free(5d22bdacc48458e8).(comp_id); |
| 1157 | // the source data stream XSD requires either no catalog or a non-empty one |
| 1158 | if (cref_catalog->childrencxx . . $ _xmlNode#children. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1159 | { |
| 1160 | xmlUnlinkNodecxx . . $ xmlUnlinkNode(5712c9d4a25253).(cref_catalog); |
| 1161 | xmlFreeNodecxx . . $ xmlFreeNode(5712c9d4a25253).(cref_catalog); |
| 1162 | } |
| 1163 | |
| 1164 | return result; |
| 1165 | } |
| 1166 | |
| 1167 | int ds_sds_compose_add_component_with_refcxx . . $ ds_sds_compose_add_component_with_ref(7f8e0434cb01b286).(xmlDocPtrcxx . . $ xmlDocPtr# doc, xmlNodePtrcxx . . $ xmlNodePtr# datastream, const char* filepath, const char* cref_id) |
| 1168 | { |
| 1169 | struct oscap_sourcecxx . . $ oscap_source# *component_source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(filepath); |
| 1170 | int ret = ds_sds_compose_add_component_source_with_refcxx . . $ ds_sds_compose_add_component_source_with_ref(11b694b88a14bb70).(doc, datastream, component_source, cref_id); |
| 1171 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(component_source); |
| 1172 | return ret; |
| 1173 | } |
| 1174 | |
| 1175 | int ds_sds_compose_add_componentcxx . . $ ds_sds_compose_add_component(aea0df7b663a3343).(const char *target_datastream, const char *datastream_id, const char *new_component, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! extended) |
| 1176 | { |
| 1177 | struct oscap_sourcecxx . . $ oscap_source# *sds_source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(target_datastream); |
| 1178 | xmlDoccxx . . $ xmlDoc# *doc = oscap_source_get_xmlDoccxx . . $ oscap_source_get_xmlDoc(51aac4e66711e6e6).(sds_source); |
| 1179 | if (doc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1180 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(sds_source); |
| 1181 | return 1; |
| 1182 | } |
| 1183 | xmlNodePtrcxx . . $ xmlNodePtr# datastream = ds_sds_lookup_datastream_in_collectioncxx . . $ ds_sds_lookup_datastream_in_collection(fa7f9e35a4c9c2b5).(doc, datastream_id); |
| 1184 | if (datastream == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1185 | char *error = datastream_id ? |
| 1186 | oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("Could not find any datastream of id '%s'", datastream_id) : |
| 1187 | oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("Could not find any datastream inside the file"); |
| 1188 | |
| 1189 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "%s", error); |
| 1190 | freecxx . . $ free(5d22bdacc48458e8).(error); |
| 1191 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(sds_source); |
| 1192 | return 1; |
| 1193 | } |
| 1194 | |
| 1195 | char* mangled_path = ds_sds_mangle_filepathcxx . . $ ds_sds_mangle_filepath(a8b8e32347182212).(new_component); |
| 1196 | |
| 1197 | char* cref_id = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("scap_org.open-scap_cref_%s", mangled_path); |
| 1198 | freecxx . . $ free(5d22bdacc48458e8).(mangled_path); |
| 1199 | if (ds_sds_compose_add_component_with_refcxx . . $ ds_sds_compose_add_component_with_ref(7f8e0434cb01b286).(doc, datastream, new_component, cref_id) != 0) { |
| 1200 | freecxx . . $ free(5d22bdacc48458e8).(cref_id); |
| 1201 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(sds_source); |
| 1202 | return 1; |
| 1203 | } |
| 1204 | freecxx . . $ free(5d22bdacc48458e8).(cref_id); |
| 1205 | |
| 1206 | if (oscap_source_save_ascxx . . $ oscap_source_save_as(b44a10f6a0e05d3e).(sds_source, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) != 0) { |
| 1207 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_GLIBCcxx . . $ `src/common/public/oscap_error.h:58:9`!, "Error saving source datastream to '%s'.", target_datastream); |
| 1208 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(sds_source); |
| 1209 | return 1; |
| 1210 | } |
| 1211 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(sds_source); |
| 1212 | return 0; |
| 1213 | } |
| 1214 | |
| 1215 | xmlDocPtrcxx . . $ xmlDocPtr# ds_sds_compose_xmlDoc_from_xccdf_sourcecxx . . $ ds_sds_compose_xmlDoc_from_xccdf_source(51aac4e66711e6e6).(struct oscap_sourcecxx . . $ oscap_source# *xccdf_source) |
| 1216 | { |
| 1217 | xmlDocPtrcxx . . $ xmlDocPtr# doc = xmlNewDoccxx . . $ xmlNewDoc(6ad5ddcc52642397).(BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "1.0"); |
| 1218 | xmlNodePtrcxx . . $ xmlNodePtr# root = xmlNewNodecxx . . $ xmlNewNode(cc9f3f2e425bac4).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "data-stream-collection"); |
| 1219 | xmlDocSetRootElementcxx . . $ xmlDocSetRootElement(ad0e42d5f79fdac5).(doc, root); |
| 1220 | |
| 1221 | xmlNsPtrcxx . . $ xmlNsPtr# ds_ns = xmlNewNscxx . . $ xmlNewNs(f962c8aae91c9a10).(root, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! datastream_ns_uricxx . . $ datastream_ns_uri., BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "ds"); |
| 1222 | xmlSetNscxx . . $ xmlSetNs(cd680be8abdf9ad3).(root, ds_ns); |
| 1223 | |
| 1224 | // we will need this namespace later when creating xlink:href attr in |
| 1225 | // component-ref |
| 1226 | xmlNewNscxx . . $ xmlNewNs(f962c8aae91c9a10).(root, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! xlink_ns_uricxx . . $ xlink_ns_uri., BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "xlink"); |
| 1227 | |
| 1228 | const char *xccdf_file = oscap_source_get_filepathcxx . . $ oscap_source_get_filepath(e20df36988f50e45).(xccdf_source); |
| 1229 | char* mangled_xccdf_file = ds_sds_mangle_filepathcxx . . $ ds_sds_mangle_filepath(a8b8e32347182212).(xccdf_file); |
| 1230 | char* collection_id = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("scap_org.open-scap_collection_from_xccdf_%s", mangled_xccdf_file); |
| 1231 | xmlSetPropcxx . . $ xmlSetProp(6ee5a6130c40eb8b).(root, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! collection_id); |
| 1232 | freecxx . . $ free(5d22bdacc48458e8).(collection_id); |
| 1233 | |
| 1234 | xmlSetPropcxx . . $ xmlSetProp(6ee5a6130c40eb8b).(root, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "schematron-version", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "1.2"); |
| 1235 | |
| 1236 | // we will need this namespace later when creating component-ref |
| 1237 | // dependency catalog |
| 1238 | xmlNewNscxx . . $ xmlNewNs(f962c8aae91c9a10).(root, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! cat_ns_uricxx . . $ cat_ns_uri., BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "cat"); |
| 1239 | |
| 1240 | xmlNodePtrcxx . . $ xmlNodePtr# datastream = xmlNewNodecxx . . $ xmlNewNode(cc9f3f2e425bac4).(ds_ns, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "data-stream"); |
| 1241 | xmlAddChildcxx . . $ xmlAddChild(93e65f4d4ebd68bd).(root, datastream); |
| 1242 | |
| 1243 | char* datastream_id = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("scap_org.open-scap_datastream_from_xccdf_%s", mangled_xccdf_file); |
| 1244 | xmlSetPropcxx . . $ xmlSetProp(6ee5a6130c40eb8b).(datastream, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! datastream_id); |
| 1245 | freecxx . . $ free(5d22bdacc48458e8).(datastream_id); |
| 1246 | |
| 1247 | xmlSetPropcxx . . $ xmlSetProp(6ee5a6130c40eb8b).(datastream, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "scap-version", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "1.2"); |
| 1248 | |
| 1249 | xmlSetPropcxx . . $ xmlSetProp(6ee5a6130c40eb8b).(datastream, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "use-case", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "OTHER"); |
| 1250 | |
| 1251 | xmlNodePtrcxx . . $ xmlNodePtr# dictionaries = xmlNewNodecxx . . $ xmlNewNode(cc9f3f2e425bac4).(ds_ns, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "dictionaries"); |
| 1252 | xmlAddChildcxx . . $ xmlAddChild(93e65f4d4ebd68bd).(datastream, dictionaries); |
| 1253 | |
| 1254 | xmlNodePtrcxx . . $ xmlNodePtr# checklists = xmlNewNodecxx . . $ xmlNewNode(cc9f3f2e425bac4).(ds_ns, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "checklists"); |
| 1255 | xmlAddChildcxx . . $ xmlAddChild(93e65f4d4ebd68bd).(datastream, checklists); |
| 1256 | |
| 1257 | xmlNodePtrcxx . . $ xmlNodePtr# checks = xmlNewNodecxx . . $ xmlNewNode(cc9f3f2e425bac4).(ds_ns, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "checks"); |
| 1258 | xmlAddChildcxx . . $ xmlAddChild(93e65f4d4ebd68bd).(datastream, checks); |
| 1259 | |
| 1260 | xmlNodePtrcxx . . $ xmlNodePtr# extended_components = xmlNewNodecxx . . $ xmlNewNode(cc9f3f2e425bac4).(ds_ns, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "extended-components"); |
| 1261 | xmlAddChildcxx . . $ xmlAddChild(93e65f4d4ebd68bd).(datastream, extended_components); |
| 1262 | |
| 1263 | char* cref_id = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("scap_org.open-scap_cref_%s", mangled_xccdf_file); |
| 1264 | if (ds_sds_compose_add_component_source_with_refcxx . . $ ds_sds_compose_add_component_source_with_ref(11b694b88a14bb70).(doc, datastream, xccdf_source, cref_id) != 0) |
| 1265 | { |
| 1266 | // oscap_seterr already called |
| 1267 | freecxx . . $ free(5d22bdacc48458e8).(cref_id); |
| 1268 | freecxx . . $ free(5d22bdacc48458e8).(mangled_xccdf_file); |
| 1269 | xmlFreeDoccxx . . $ xmlFreeDoc(42de24d0ab3f771).(doc); |
| 1270 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1271 | } |
| 1272 | freecxx . . $ free(5d22bdacc48458e8).(cref_id); |
| 1273 | |
| 1274 | // the XSD of source data stream enforces that the collection elements are |
| 1275 | // not empty if they are there, we will therefore now removes collections |
| 1276 | // where nothing has been added |
| 1277 | |
| 1278 | if (dictionaries->childrencxx . . $ _xmlNode#children. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1279 | { |
| 1280 | xmlUnlinkNodecxx . . $ xmlUnlinkNode(5712c9d4a25253).(dictionaries); |
| 1281 | xmlFreeNodecxx . . $ xmlFreeNode(5712c9d4a25253).(dictionaries); |
| 1282 | } |
| 1283 | if (checklists->childrencxx . . $ _xmlNode#children. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1284 | { |
| 1285 | xmlUnlinkNodecxx . . $ xmlUnlinkNode(5712c9d4a25253).(checklists); |
| 1286 | xmlFreeNodecxx . . $ xmlFreeNode(5712c9d4a25253).(checklists); |
| 1287 | } |
| 1288 | if (checks->childrencxx . . $ _xmlNode#children. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1289 | { |
| 1290 | xmlUnlinkNodecxx . . $ xmlUnlinkNode(5712c9d4a25253).(checks); |
| 1291 | xmlFreeNodecxx . . $ xmlFreeNode(5712c9d4a25253).(checks); |
| 1292 | } |
| 1293 | if (extended_components->childrencxx . . $ _xmlNode#children. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1294 | { |
| 1295 | xmlUnlinkNodecxx . . $ xmlUnlinkNode(5712c9d4a25253).(extended_components); |
| 1296 | xmlFreeNodecxx . . $ xmlFreeNode(5712c9d4a25253).(extended_components); |
| 1297 | } |
| 1298 | |
| 1299 | freecxx . . $ free(5d22bdacc48458e8).(mangled_xccdf_file); |
| 1300 | |
| 1301 | return doc; |
| 1302 | } |
| 1303 | |
| 1304 | xmlDocPtrcxx . . $ xmlDocPtr# ds_sds_compose_xmlDoc_from_xccdfcxx . . $ ds_sds_compose_xmlDoc_from_xccdf(c66d212a4d76caed).(const char *xccdf_file) |
| 1305 | { |
| 1306 | struct oscap_sourcecxx . . $ oscap_source# *xccdf_source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(xccdf_file); |
| 1307 | xmlDocPtrcxx . . $ xmlDocPtr# doc = ds_sds_compose_xmlDoc_from_xccdf_sourcecxx . . $ ds_sds_compose_xmlDoc_from_xccdf_source(51aac4e66711e6e6).(xccdf_source); |
| 1308 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(xccdf_source); |
| 1309 | return doc; |
| 1310 | } |
| 1311 | |
| 1312 | int ds_sds_compose_from_xccdfcxx . . $ ds_sds_compose_from_xccdf(5ae29d726ae57f88).(const char *xccdf_file, const char *target_datastream) |
| 1313 | { |
| 1314 | xmlDocPtrcxx . . $ xmlDocPtr# doc = ds_sds_compose_xmlDoc_from_xccdfcxx . . $ ds_sds_compose_xmlDoc_from_xccdf(c66d212a4d76caed).(xccdf_file); |
| 1315 | if (doc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1316 | return -1; |
| 1317 | } |
| 1318 | if (xmlSaveFileEnccxx . . $ xmlSaveFileEnc(6fcbdbb60028837d).(target_datastream, doc, "utf-8") == -1) |
| 1319 | { |
| 1320 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_GLIBCcxx . . $ `src/common/public/oscap_error.h:58:9`!, "Error saving source datastream to '%s'.", target_datastream); |
| 1321 | xmlFreeDoccxx . . $ xmlFreeDoc(42de24d0ab3f771).(doc); |
| 1322 | return -1; |
| 1323 | } |
| 1324 | |
| 1325 | xmlFreeDoccxx . . $ xmlFreeDoc(42de24d0ab3f771).(doc); |
| 1326 | return 0; |
| 1327 | } |
| 1328 | |
| 1329 | char *ds_sds_detect_versioncxx . . $ ds_sds_detect_version(93c99f8009311dd0).(xmlTextReadercxx . . $ xmlTextReader# *reader) |
| 1330 | { |
| 1331 | /* find root element */ |
| 1332 | while (xmlTextReaderReadcxx . . $ xmlTextReaderRead(82a242a19623f75).(reader) == 1 && xmlTextReaderNodeTypecxx . . $ xmlTextReaderNodeType(82a242a19623f75).(reader) != XML_READER_TYPE_ELEMENTcxx . . $ XML_READER_TYPE_ELEMENT.) |
| 1333 | ; |
| 1334 | |
| 1335 | char *element_name = (char *) xmlTextReaderConstLocalNamecxx . . $ xmlTextReaderConstLocalName(60a5affeeceb06fd).(reader); |
| 1336 | if (!element_name) { |
| 1337 | oscap_setxmlerrcxx . . $ `src/common/_error.h:36:9`!(xmlGetLastError()); |
| 1338 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1339 | } |
| 1340 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(element_name, "data-stream-collection")) { |
| 1341 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_OSCAPcxx . . $ `src/common/public/oscap_error.h:60:9`!, |
| 1342 | "Expected root element name for SCAP source datastream is" \ |
| 1343 | "'data-stream-collection' but actual root element name is '%s'.", |
| 1344 | element_name); |
| 1345 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1346 | } |
| 1347 | char *schematron_version = (char *) xmlTextReaderGetAttributecxx . . $ xmlTextReaderGetAttribute(6d056300a6ef2116).(reader, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "schematron-version"); |
| 1348 | if (!schematron_version) { |
| 1349 | oscap_setxmlerrcxx . . $ `src/common/_error.h:36:9`!(xmlGetLastError()); |
| 1350 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1351 | } |
| 1352 | return schematron_version; |
| 1353 | } |