| 1 | /* |
| 2 | * Copyright 2014 Red Hat Inc., Durham, North Carolina. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public |
| 16 | * License along with this library; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 22 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 23 | #endif |
| 24 | |
| 25 | #include <string.h> |
| 26 | #ifdef OS_WINDOWS |
| 27 | #include <io.h> |
| 28 | #else |
| 29 | #include <unistd.h> |
| 30 | #endif |
| 31 | |
| 32 | #include <libxml/xpath.h> |
| 33 | #include <libxml/xpathInternals.h> |
| 34 | #include "common/_error.h"cxx . . $ `<file>/src/common/_error.h`/ |
| 35 | #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/ |
| 36 | #include "common/list.h"cxx . . $ `<file>/src/common/list.h`/ |
| 37 | #include "common/util.h"cxx . . $ `<file>/src/common/util.h`/ |
| 38 | #include "ds_sds_session.h"cxx . . $ `<file>/src/DS/public/ds_sds_session.h`/ |
| 39 | #include "DS/ds_sds_session_priv.h"cxx . . $ `<file>/src/DS/ds_sds_session_priv.h`/ |
| 40 | #include "oscap.h"cxx . . $ `<file>/src/common/public/oscap.h`/ |
| 41 | #include "oscap_helpers.h"cxx . . $ `<file>/src/common/public/oscap_helpers.h`/ |
| 42 | #include "oscap_source.h"cxx . . $ `<file>/src/source/public/oscap_source.h`/ |
| 43 | #include "source/oscap_source_priv.h"cxx . . $ `<file>/src/source/oscap_source_priv.h`/ |
| 44 | #include "source/schematron_priv.h"cxx . . $ `<file>/src/source/schematron_priv.h`/ |
| 45 | #include "source/validate_priv.h"cxx . . $ `<file>/src/source/validate_priv.h`/ |
| 46 | #include "source/xslt_priv.h"cxx . . $ `<file>/src/source/xslt_priv.h`/ |
| 47 | |
| 48 | struct oscap_schema_table_entrycxx . . $ oscap_schema_table_entry# OSCAP_SCHEMATRON_TABLEcxx . . $ OSCAP_SCHEMATRON_TABLE.[] = { |
| 49 | {OSCAP_DOCUMENT_OVAL_DEFINITIONScxx . . $ OSCAP_DOCUMENT_OVAL_DEFINITIONS., "5.3", "oval/5.3/oval-definitions-schematron.xsl"}, |
| 50 | {OSCAP_DOCUMENT_OVAL_DEFINITIONScxx . . $ OSCAP_DOCUMENT_OVAL_DEFINITIONS., "5.4", "oval/5.4/oval-definitions-schematron.xsl"}, |
| 51 | {OSCAP_DOCUMENT_OVAL_DEFINITIONScxx . . $ OSCAP_DOCUMENT_OVAL_DEFINITIONS., "5.5", "oval/5.5/oval-definitions-schematron.xsl"}, |
| 52 | {OSCAP_DOCUMENT_OVAL_DEFINITIONScxx . . $ OSCAP_DOCUMENT_OVAL_DEFINITIONS., "5.6", "oval/5.6/oval-definitions-schematron.xsl"}, |
| 53 | {OSCAP_DOCUMENT_OVAL_DEFINITIONScxx . . $ OSCAP_DOCUMENT_OVAL_DEFINITIONS., "5.7", "oval/5.7/oval-definitions-schematron.xsl"}, |
| 54 | {OSCAP_DOCUMENT_OVAL_DEFINITIONScxx . . $ OSCAP_DOCUMENT_OVAL_DEFINITIONS., "5.8", "oval/5.8/oval-definitions-schematron.xsl"}, |
| 55 | {OSCAP_DOCUMENT_OVAL_DEFINITIONScxx . . $ OSCAP_DOCUMENT_OVAL_DEFINITIONS., "5.9", "oval/5.9/oval-definitions-schematron.xsl"}, |
| 56 | {OSCAP_DOCUMENT_OVAL_DEFINITIONScxx . . $ OSCAP_DOCUMENT_OVAL_DEFINITIONS., "5.10", "oval/5.10/oval-definitions-schematron.xsl"}, |
| 57 | {OSCAP_DOCUMENT_OVAL_DEFINITIONScxx . . $ OSCAP_DOCUMENT_OVAL_DEFINITIONS., "5.10.1", "oval/5.10.1/oval-definitions-schematron.xsl"}, |
| 58 | {OSCAP_DOCUMENT_OVAL_DEFINITIONScxx . . $ OSCAP_DOCUMENT_OVAL_DEFINITIONS., "5.11", "oval/5.11/oval-definitions-schematron.xsl"}, |
| 59 | {OSCAP_DOCUMENT_OVAL_DEFINITIONScxx . . $ OSCAP_DOCUMENT_OVAL_DEFINITIONS., "5.11.1", "oval/5.11.1/oval-definitions-schematron.xsl"}, |
| 60 | {OSCAP_DOCUMENT_OVAL_DEFINITIONScxx . . $ OSCAP_DOCUMENT_OVAL_DEFINITIONS., "5.11.2", "oval/5.11.2/oval-definitions-schematron.xsl"}, |
| 61 | {OSCAP_DOCUMENT_OVAL_DEFINITIONScxx . . $ OSCAP_DOCUMENT_OVAL_DEFINITIONS., "5.11.3", "oval/5.11.3/oval-definitions-schematron.xsl"}, |
| 62 | {OSCAP_DOCUMENT_OVAL_SYSCHARcxx . . $ OSCAP_DOCUMENT_OVAL_SYSCHAR., "5.3", "oval/5.3/oval-system-characteristics-schematron.xsl"}, |
| 63 | {OSCAP_DOCUMENT_OVAL_SYSCHARcxx . . $ OSCAP_DOCUMENT_OVAL_SYSCHAR., "5.4", "oval/5.4/oval-system-characteristics-schematron.xsl"}, |
| 64 | {OSCAP_DOCUMENT_OVAL_SYSCHARcxx . . $ OSCAP_DOCUMENT_OVAL_SYSCHAR., "5.5", "oval/5.5/oval-system-characteristics-schematron.xsl"}, |
| 65 | {OSCAP_DOCUMENT_OVAL_SYSCHARcxx . . $ OSCAP_DOCUMENT_OVAL_SYSCHAR., "5.6", "oval/5.6/oval-system-characteristics-schematron.xsl"}, |
| 66 | {OSCAP_DOCUMENT_OVAL_SYSCHARcxx . . $ OSCAP_DOCUMENT_OVAL_SYSCHAR., "5.7", "oval/5.7/oval-system-characteristics-schematron.xsl"}, |
| 67 | {OSCAP_DOCUMENT_OVAL_SYSCHARcxx . . $ OSCAP_DOCUMENT_OVAL_SYSCHAR., "5.8", "oval/5.8/oval-system-characteristics-schematron.xsl"}, |
| 68 | {OSCAP_DOCUMENT_OVAL_SYSCHARcxx . . $ OSCAP_DOCUMENT_OVAL_SYSCHAR., "5.9", "oval/5.9/oval-system-characteristics-schematron.xsl"}, |
| 69 | {OSCAP_DOCUMENT_OVAL_SYSCHARcxx . . $ OSCAP_DOCUMENT_OVAL_SYSCHAR., "5.10", "oval/5.10/oval-system-characteristics-schematron.xsl"}, |
| 70 | {OSCAP_DOCUMENT_OVAL_SYSCHARcxx . . $ OSCAP_DOCUMENT_OVAL_SYSCHAR., "5.10.1", "oval/5.10.1/oval-system-characteristics-schematron.xsl"}, |
| 71 | {OSCAP_DOCUMENT_OVAL_SYSCHARcxx . . $ OSCAP_DOCUMENT_OVAL_SYSCHAR., "5.11", "oval/5.11/oval-system-characteristics-schematron.xsl"}, |
| 72 | {OSCAP_DOCUMENT_OVAL_SYSCHARcxx . . $ OSCAP_DOCUMENT_OVAL_SYSCHAR., "5.11.1", "oval/5.11.1/oval-system-characteristics-schematron.xsl"}, |
| 73 | {OSCAP_DOCUMENT_OVAL_SYSCHARcxx . . $ OSCAP_DOCUMENT_OVAL_SYSCHAR., "5.11.2", "oval/5.11.2/oval-system-characteristics-schematron.xsl"}, |
| 74 | {OSCAP_DOCUMENT_OVAL_SYSCHARcxx . . $ OSCAP_DOCUMENT_OVAL_SYSCHAR., "5.11.3", "oval/5.11.3/oval-system-characteristics-schematron.xsl"}, |
| 75 | {OSCAP_DOCUMENT_OVAL_RESULTScxx . . $ OSCAP_DOCUMENT_OVAL_RESULTS., "5.3", "oval/5.3/oval-results-schematron.xsl"}, |
| 76 | {OSCAP_DOCUMENT_OVAL_RESULTScxx . . $ OSCAP_DOCUMENT_OVAL_RESULTS., "5.4", "oval/5.4/oval-results-schematron.xsl"}, |
| 77 | {OSCAP_DOCUMENT_OVAL_RESULTScxx . . $ OSCAP_DOCUMENT_OVAL_RESULTS., "5.5", "oval/5.5/oval-results-schematron.xsl"}, |
| 78 | {OSCAP_DOCUMENT_OVAL_RESULTScxx . . $ OSCAP_DOCUMENT_OVAL_RESULTS., "5.6", "oval/5.6/oval-results-schematron.xsl"}, |
| 79 | {OSCAP_DOCUMENT_OVAL_RESULTScxx . . $ OSCAP_DOCUMENT_OVAL_RESULTS., "5.7", "oval/5.7/oval-results-schematron.xsl"}, |
| 80 | {OSCAP_DOCUMENT_OVAL_RESULTScxx . . $ OSCAP_DOCUMENT_OVAL_RESULTS., "5.8", "oval/5.8/oval-results-schematron.xsl"}, |
| 81 | {OSCAP_DOCUMENT_OVAL_RESULTScxx . . $ OSCAP_DOCUMENT_OVAL_RESULTS., "5.9", "oval/5.9/oval-results-schematron.xsl"}, |
| 82 | {OSCAP_DOCUMENT_OVAL_RESULTScxx . . $ OSCAP_DOCUMENT_OVAL_RESULTS., "5.10", "oval/5.10/oval-results-schematron.xsl"}, |
| 83 | {OSCAP_DOCUMENT_OVAL_RESULTScxx . . $ OSCAP_DOCUMENT_OVAL_RESULTS., "5.10.1", "oval/5.10.1/oval-results-schematron.xsl"}, |
| 84 | {OSCAP_DOCUMENT_OVAL_RESULTScxx . . $ OSCAP_DOCUMENT_OVAL_RESULTS., "5.11", "oval/5.11/oval-results-schematron.xsl"}, |
| 85 | {OSCAP_DOCUMENT_OVAL_RESULTScxx . . $ OSCAP_DOCUMENT_OVAL_RESULTS., "5.11.1", "oval/5.11.1/oval-results-schematron.xsl"}, |
| 86 | {OSCAP_DOCUMENT_OVAL_RESULTScxx . . $ OSCAP_DOCUMENT_OVAL_RESULTS., "5.11.2", "oval/5.11.2/oval-results-schematron.xsl"}, |
| 87 | {OSCAP_DOCUMENT_OVAL_RESULTScxx . . $ OSCAP_DOCUMENT_OVAL_RESULTS., "5.11.3", "oval/5.11.3/oval-results-schematron.xsl"}, |
| 88 | {OSCAP_DOCUMENT_OVAL_VARIABLEScxx . . $ OSCAP_DOCUMENT_OVAL_VARIABLES., "5.3", "oval/5.3/oval-variables-schematron.xsl"}, |
| 89 | {OSCAP_DOCUMENT_OVAL_VARIABLEScxx . . $ OSCAP_DOCUMENT_OVAL_VARIABLES., "5.4", "oval/5.4/oval-variables-schematron.xsl"}, |
| 90 | {OSCAP_DOCUMENT_OVAL_VARIABLEScxx . . $ OSCAP_DOCUMENT_OVAL_VARIABLES., "5.5", "oval/5.5/oval-variables-schematron.xsl"}, |
| 91 | {OSCAP_DOCUMENT_OVAL_VARIABLEScxx . . $ OSCAP_DOCUMENT_OVAL_VARIABLES., "5.6", "oval/5.6/oval-variables-schematron.xsl"}, |
| 92 | {OSCAP_DOCUMENT_OVAL_VARIABLEScxx . . $ OSCAP_DOCUMENT_OVAL_VARIABLES., "5.7", "oval/5.7/oval-variables-schematron.xsl"}, |
| 93 | {OSCAP_DOCUMENT_OVAL_VARIABLEScxx . . $ OSCAP_DOCUMENT_OVAL_VARIABLES., "5.8", "oval/5.8/oval-variables-schematron.xsl"}, |
| 94 | {OSCAP_DOCUMENT_OVAL_VARIABLEScxx . . $ OSCAP_DOCUMENT_OVAL_VARIABLES., "5.9", "oval/5.9/oval-variables-schematron.xsl"}, |
| 95 | {OSCAP_DOCUMENT_OVAL_VARIABLEScxx . . $ OSCAP_DOCUMENT_OVAL_VARIABLES., "5.10", "oval/5.10/oval-variables-schematron.xsl"}, |
| 96 | {OSCAP_DOCUMENT_OVAL_VARIABLEScxx . . $ OSCAP_DOCUMENT_OVAL_VARIABLES., "5.10.1", "oval/5.10.1/oval-variables-schematron.xsl"}, |
| 97 | {OSCAP_DOCUMENT_OVAL_VARIABLEScxx . . $ OSCAP_DOCUMENT_OVAL_VARIABLES., "5.11", "oval/5.11/oval-variables-schematron.xsl"}, |
| 98 | {OSCAP_DOCUMENT_OVAL_VARIABLEScxx . . $ OSCAP_DOCUMENT_OVAL_VARIABLES., "5.11.1", "oval/5.11.1/oval-variables-schematron.xsl"}, |
| 99 | {OSCAP_DOCUMENT_OVAL_VARIABLEScxx . . $ OSCAP_DOCUMENT_OVAL_VARIABLES., "5.11.2", "oval/5.11.2/oval-variables-schematron.xsl"}, |
| 100 | {OSCAP_DOCUMENT_OVAL_VARIABLEScxx . . $ OSCAP_DOCUMENT_OVAL_VARIABLES., "5.11.3", "oval/5.11.3/oval-variables-schematron.xsl"}, |
| 101 | {OSCAP_DOCUMENT_OVAL_DIRECTIVEScxx . . $ OSCAP_DOCUMENT_OVAL_DIRECTIVES., "5.8", "oval/5.8/oval-directives-schematron.xsl"}, |
| 102 | {OSCAP_DOCUMENT_OVAL_DIRECTIVEScxx . . $ OSCAP_DOCUMENT_OVAL_DIRECTIVES., "5.9", "oval/5.9/oval-directives-schematron.xsl"}, |
| 103 | {OSCAP_DOCUMENT_OVAL_DIRECTIVEScxx . . $ OSCAP_DOCUMENT_OVAL_DIRECTIVES., "5.10", "oval/5.10/oval-directives-schematron.xsl"}, |
| 104 | {OSCAP_DOCUMENT_OVAL_DIRECTIVEScxx . . $ OSCAP_DOCUMENT_OVAL_DIRECTIVES., "5.10.1", "oval/5.10.1/oval-directives-schematron.xsl"}, |
| 105 | {OSCAP_DOCUMENT_OVAL_DIRECTIVEScxx . . $ OSCAP_DOCUMENT_OVAL_DIRECTIVES., "5.11", "oval/5.11/oval-directives-schematron.xsl"}, |
| 106 | {OSCAP_DOCUMENT_OVAL_DIRECTIVEScxx . . $ OSCAP_DOCUMENT_OVAL_DIRECTIVES., "5.11.1", "oval/5.11.1/oval-directives-schematron.xsl"}, |
| 107 | {OSCAP_DOCUMENT_OVAL_DIRECTIVEScxx . . $ OSCAP_DOCUMENT_OVAL_DIRECTIVES., "5.11.2", "oval/5.11.2/oval-directives-schematron.xsl"}, |
| 108 | {OSCAP_DOCUMENT_OVAL_DIRECTIVEScxx . . $ OSCAP_DOCUMENT_OVAL_DIRECTIVES., "5.11.3", "oval/5.11.3/oval-directives-schematron.xsl"}, |
| 109 | {OSCAP_DOCUMENT_XCCDFcxx . . $ OSCAP_DOCUMENT_XCCDF., "1.2", "xccdf/1.2/xccdf_1.2-schematron.xsl"}, |
| 110 | {OSCAP_DOCUMENT_SDScxx . . $ OSCAP_DOCUMENT_SDS., "1.3", "sds/1.3/source-data-stream-1.3.xsl"} |
| 111 | }; |
| 112 | |
| 113 | static int _validate_sds_componentscxx . . $ _validate_sds_components(a38c22d0fd42c683).(struct oscap_sourcecxx . . $ oscap_source# *source) |
| 114 | { |
| 115 | int ret = 0; |
| 116 | struct ds_sds_sessioncxx . . $ ds_sds_session# *session = ds_sds_session_new_from_sourcecxx . . $ ds_sds_session_new_from_source(84081d5e8394044f).(source); |
| 117 | if (ds_sds_session_register_component_with_dependenciescxx . . $ ds_sds_session_register_component_with_dependencies(2e27e35b07e9ac87).(session, "checklists", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) != 0) { |
| 118 | return -1; |
| 119 | } |
| 120 | if (ds_sds_session_register_component_with_dependenciescxx . . $ ds_sds_session_register_component_with_dependencies(2e27e35b07e9ac87).(session, "checks", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) != 0) { |
| 121 | return -1; |
| 122 | } |
| 123 | struct oscap_htablecxx . . $ oscap_htable# *component_sources = ds_sds_session_get_component_sourcescxx . . $ ds_sds_session_get_component_sources(a99418aa193592e1).(session); |
| 124 | struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *it = oscap_htable_iterator_newcxx . . $ oscap_htable_iterator_new(81743c99830972e7).(component_sources); |
| 125 | while (oscap_htable_iterator_has_morecxx . . $ oscap_htable_iterator_has_more(eba4198ab3388c55).(it)) { |
| 126 | struct oscap_sourcecxx . . $ oscap_source# *cs = oscap_htable_iterator_next_valuecxx . . $ oscap_htable_iterator_next_value(4e1156670e4376db).(it); |
| 127 | const char *type = oscap_document_type_to_stringcxx . . $ oscap_document_type_to_string(1cec73a42285d610).(oscap_source_get_scap_typecxx . . $ oscap_source_get_scap_type(1b623b3fe9f5b871).(cs)); |
| 128 | const char *origin = oscap_source_readable_origincxx . . $ oscap_source_readable_origin(1485dc36ee4b63be).(cs); |
| 129 | printfcxx . . $ printf(581fddd72a8db8fc).("Starting schematron validation of %s component '%s':\n", type, origin); |
| 130 | int component_result = oscap_source_validate_schematron_privcxx . . $ oscap_source_validate_schematron_priv(4191b822de29fb8a).(cs, |
| 131 | oscap_source_get_scap_typecxx . . $ oscap_source_get_scap_type(1b623b3fe9f5b871).(cs), |
| 132 | oscap_source_get_schema_versioncxx . . $ oscap_source_get_schema_version(e20df36988f50e45).(cs)); |
| 133 | printfcxx . . $ printf(581fddd72a8db8fc).("Schematron validation of %s component '%s': %s\n\n", type, origin, component_result == 0 ? "PASS" : "FAIL"); |
| 134 | if (component_result != 0) { |
| 135 | ret = component_result; |
| 136 | } |
| 137 | } |
| 138 | oscap_htable_iterator_freecxx . . $ oscap_htable_iterator_free(e07ea5562ff119bd).(it); |
| 139 | ds_sds_session_freecxx . . $ ds_sds_session_free(41ab223cf3ccc737).(session); |
| 140 | return ret; |
| 141 | } |
| 142 | |
| 143 | static char *_xcf_resolve_in_catalogcxx . . $ _xcf_resolve_in_catalog(f87087fc1235b9ea).(xmlNodePtrcxx . . $ xmlNodePtr# resolver_node, const char *uri, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context) |
| 144 | { |
| 145 | if (*uri == '#') { |
| 146 | return oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(uri); |
| 147 | } |
| 148 | if (resolver_node == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 149 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 150 | } |
| 151 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).((char *)resolver_node->namecxx . . $ _xmlNode#name., "uri") == 0) { |
| 152 | char *name = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(resolver_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "name"); |
| 153 | if (name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && strcmpcxx . . $ strcmp(5ae29d726ae57f88).(name, uri) == 0) { |
| 154 | char *resolver_node_uri = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(resolver_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "uri"); |
| 155 | freecxx . . $ free(5d22bdacc48458e8).(name); |
| 156 | return resolver_node_uri; |
| 157 | } else { |
| 158 | freecxx . . $ free(5d22bdacc48458e8).(name); |
| 159 | return _xcf_resolve_in_catalogcxx . . $ _xcf_resolve_in_catalog(f87087fc1235b9ea).(resolver_node->nextcxx . . $ _xmlNode#next., uri, context); |
| 160 | } |
| 161 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).((char *)resolver_node->namecxx . . $ _xmlNode#name., "rewriteURI") == 0) { |
| 162 | char *uri_start_string = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(resolver_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "uriStartString"); |
| 163 | if (oscap_str_startswithcxx . . $ oscap_str_startswith(b7a7aa4a824b7595).(uri, uri_start_string)) { |
| 164 | char *rewrite_prefix = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(resolver_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "rewritePrefix"); |
| 165 | char *concat = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("%s%s", rewrite_prefix, uri + strlencxx . . $ strlen(751346f8406fd082).(uri_start_string) + 1); |
| 166 | freecxx . . $ free(5d22bdacc48458e8).(rewrite_prefix); |
| 167 | freecxx . . $ free(5d22bdacc48458e8).(uri_start_string); |
| 168 | return concat; |
| 169 | } else { |
| 170 | freecxx . . $ free(5d22bdacc48458e8).(uri_start_string); |
| 171 | return _xcf_resolve_in_catalogcxx . . $ _xcf_resolve_in_catalog(f87087fc1235b9ea).(resolver_node->nextcxx . . $ _xmlNode#next., uri, context); |
| 172 | } |
| 173 | } |
| 174 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 175 | } |
| 176 | |
| 177 | static xmlNodePtrcxx . . $ xmlNodePtr# _xcf_get_component_refcxx . . $ _xcf_get_component_ref(70f2ba06a9ead144).(xmlNodePtrcxx . . $ xmlNodePtr# catalog, const char *uri, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context) |
| 178 | { |
| 179 | char *component_ref_uri = _xcf_resolve_in_catalogcxx . . $ _xcf_resolve_in_catalog(f87087fc1235b9ea).(catalog->childrencxx . . $ _xmlNode#children.->nextcxx . . $ _xmlNode#next., uri, context); |
| 180 | if (component_ref_uri == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 181 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't get component_ref URI using check-content-ref href='%s'", uri); |
| 182 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 183 | } |
| 184 | char *cref = component_ref_uri + 1; |
| 185 | xmlNodePtrcxx . . $ xmlNodePtr# component_ref_node = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 186 | char *xpath = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("ancestor::ds:data-stream//ds:component-ref[@id='%s']", cref); |
| 187 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# component_refs = xmlXPathNodeEvalcxx . . $ xmlXPathNodeEval(5aa74ad3adcbce29).(catalog, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! xpath, context); |
| 188 | if (component_refs != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && component_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && component_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeNrcxx . . $ _xmlNodeSet#nodeNr. == 1) { |
| 189 | component_ref_node = component_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeTabcxx . . $ _xmlNodeSet#nodeTab.[0]; |
| 190 | } |
| 191 | if (component_ref_node == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 192 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("component-ref '%s' not found", cref); |
| 193 | } |
| 194 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(component_refs); |
| 195 | freecxx . . $ free(5d22bdacc48458e8).(xpath); |
| 196 | freecxx . . $ free(5d22bdacc48458e8).(component_ref_uri); |
| 197 | |
| 198 | return component_ref_node; |
| 199 | } |
| 200 | |
| 201 | static xmlNodePtrcxx . . $ xmlNodePtr# _xcf_get_componentcxx . . $ _xcf_get_component(8746e3959ef78c26).(xmlNodePtrcxx . . $ xmlNodePtr# component_ref_node, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context) |
| 202 | { |
| 203 | char *xlink_href = (char *) xmlGetNsPropcxx . . $ xmlGetNsProp(3f3adc55d94f1650).(component_ref_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "href", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "http://www.w3.org/1999/xlink"); |
| 204 | char *xpath = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("ancestor::ds:data-stream-collection//ds:component[@id='%s']", xlink_href + 1); |
| 205 | freecxx . . $ free(5d22bdacc48458e8).(xlink_href); |
| 206 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# components = xmlXPathNodeEvalcxx . . $ xmlXPathNodeEval(5aa74ad3adcbce29).(component_ref_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! xpath, context); |
| 207 | xmlNodePtrcxx . . $ xmlNodePtr# component = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 208 | if (components != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && components->nodesetvalcxx . . $ _xmlXPathObject#nodesetval. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && components->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeNrcxx . . $ _xmlNodeSet#nodeNr. == 1) { |
| 209 | component = components->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeTabcxx . . $ _xmlNodeSet#nodeTab.[0]; |
| 210 | } |
| 211 | freecxx . . $ free(5d22bdacc48458e8).(xpath); |
| 212 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(components); |
| 213 | return component; |
| 214 | } |
| 215 | |
| 216 | static xmlNodePtrcxx . . $ xmlNodePtr# _find_catalogcxx . . $ _find_catalog(3a610665e8c694f1).(xmlNodePtrcxx . . $ xmlNodePtr# component_ref_node) |
| 217 | { |
| 218 | /* find $m/catalog */ |
| 219 | xmlNodePtrcxx . . $ xmlNodePtr# catalog = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 220 | xmlNodePtrcxx . . $ xmlNodePtr# cur = component_ref_node->childrencxx . . $ _xmlNode#children.; |
| 221 | while (cur != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 222 | if (!xmlStrcmpcxx . . $ xmlStrcmp(e46526da1a64e2fc).(cur->namecxx . . $ _xmlNode#name., BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "catalog")) { |
| 223 | catalog = cur; |
| 224 | break; |
| 225 | } |
| 226 | cur = cur->nextcxx . . $ _xmlNode#next.; |
| 227 | } |
| 228 | return catalog; |
| 229 | } |
| 230 | |
| 231 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _xcf_is_external_refcxx . . $ _xcf_is_external_ref(6be27bcd423690ab).(xmlNodePtrcxx . . $ xmlNodePtr# catalog, const char *uri, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context) |
| 232 | { |
| 233 | xmlNodePtrcxx . . $ xmlNodePtr# comp_ref = _xcf_get_component_refcxx . . $ _xcf_get_component_ref(70f2ba06a9ead144).(catalog, uri, context); |
| 234 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! res = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 235 | if (comp_ref != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 236 | char *xlink_href = (char *) xmlGetNsPropcxx . . $ xmlGetNsProp(3f3adc55d94f1650).(comp_ref, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "href", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "http://www.w3.org/1999/xlink"); |
| 237 | if (!oscap_str_startswithcxx . . $ oscap_str_startswith(b7a7aa4a824b7595).(xlink_href, "#")) |
| 238 | res = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 239 | freecxx . . $ free(5d22bdacc48458e8).(xlink_href); |
| 240 | } |
| 241 | return res; |
| 242 | } |
| 243 | |
| 244 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _req_src_236_2_sub6cxx . . $ _req_src_236_2_sub6(349b1d0c1571cf0c).(xmlNodePtrcxx . . $ xmlNodePtr# component, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context, const char *name, const char *rule_id) |
| 245 | { |
| 246 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! exists_ocil = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 247 | char *ocil_xpath = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).(".//ocil:questionnaire[@id='%s']", name); |
| 248 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# ocil_questionnaires = xmlXPathNodeEvalcxx . . $ xmlXPathNodeEval(5aa74ad3adcbce29).(component, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! ocil_xpath, context); |
| 249 | if (ocil_questionnaires == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || ocil_questionnaires->nodesetvalcxx . . $ _xmlXPathObject#nodesetval. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 250 | goto cleanup; |
| 251 | for (int m = 0; m < ocil_questionnaires->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeNrcxx . . $ _xmlNodeSet#nodeNr.; m++) { |
| 252 | xmlNodePtrcxx . . $ xmlNodePtr# ocil_questionnaire = ocil_questionnaires->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeTabcxx . . $ _xmlNodeSet#nodeTab.[m]; |
| 253 | char *ocil_questionnaire_id = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(ocil_questionnaire, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 254 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Found OCIL questionnaire id='%s' for rule id='%s'", ocil_questionnaire_id, rule_id); |
| 255 | freecxx . . $ free(5d22bdacc48458e8).(ocil_questionnaire_id); |
| 256 | exists_ocil = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 257 | } |
| 258 | cleanup: |
| 259 | freecxx . . $ free(5d22bdacc48458e8).(ocil_xpath); |
| 260 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(ocil_questionnaires); |
| 261 | return exists_ocil; |
| 262 | } |
| 263 | |
| 264 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _req_src_236_2_sub5cxx . . $ _req_src_236_2_sub5(349b1d0c1571cf0c).(xmlNodePtrcxx . . $ xmlNodePtr# component, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context, const char *name, const char *rule_id) |
| 265 | { |
| 266 | /* exists(xcf:get-component(xcf:get-component-ref($m/cat:catalog, $o/@href))//oval-def:definition[@id eq $o/@name and matches(@class, '^(compliance|patch)$')]) */ |
| 267 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! exists_oval = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 268 | char *oval_xpath = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).(".//oval-def:definition[@id='%s' and (@class='compliance' or @class='patch')]", name); |
| 269 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# oval_definitions = xmlXPathNodeEvalcxx . . $ xmlXPathNodeEval(5aa74ad3adcbce29).(component, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! oval_xpath, context); |
| 270 | if (oval_definitions == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || oval_definitions->nodesetvalcxx . . $ _xmlXPathObject#nodesetval. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 271 | goto cleanup; |
| 272 | for (int m = 0; m < oval_definitions->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeNrcxx . . $ _xmlNodeSet#nodeNr.; m++) { |
| 273 | xmlNodePtrcxx . . $ xmlNodePtr# oval_definition = oval_definitions->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeTabcxx . . $ _xmlNodeSet#nodeTab.[m]; |
| 274 | char *oval_def_id = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(oval_definition, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 275 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Found OVAL definition id='%s' for rule id='%s'", oval_def_id, rule_id); |
| 276 | freecxx . . $ free(5d22bdacc48458e8).(oval_def_id); |
| 277 | exists_oval = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 278 | } |
| 279 | cleanup: |
| 280 | freecxx . . $ free(5d22bdacc48458e8).(oval_xpath); |
| 281 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(oval_definitions); |
| 282 | return exists_oval; |
| 283 | } |
| 284 | |
| 285 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _req_src_236_2_sub4cxx . . $ _req_src_236_2_sub4(d7e6043d832c7f1c).(xmlNodePtrcxx . . $ xmlNodePtr# check_content_ref_node, xmlNodePtrcxx . . $ xmlNodePtr# catalog, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context, const char *rule_id) |
| 286 | { |
| 287 | char *href = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(check_content_ref_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "href"); |
| 288 | /* xcf:get-component(xcf:get-component-ref($m/cat:catalog, $o/@href) */ |
| 289 | xmlNodePtrcxx . . $ xmlNodePtr# component_ref = _xcf_get_component_refcxx . . $ _xcf_get_component_ref(70f2ba06a9ead144).(catalog, href, context); |
| 290 | freecxx . . $ free(5d22bdacc48458e8).(href); |
| 291 | if (component_ref == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 292 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("component_ref not found"); |
| 293 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 294 | } |
| 295 | xmlNodePtrcxx . . $ xmlNodePtr# component = _xcf_get_componentcxx . . $ _xcf_get_component(8746e3959ef78c26).(component_ref, context); |
| 296 | if (component == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 297 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("component not found\n"); |
| 298 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 299 | } |
| 300 | |
| 301 | char *name = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(check_content_ref_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "name"); |
| 302 | |
| 303 | /* exists(xcf:get-component(xcf:get-component-ref($m/cat:catalog, $o/@href))//oval-def:definition[@id eq $o/@name and matches(@class, '^(compliance|patch)$')]) or exists(xcf:get-component(xcf:get-component-ref($m/cat:catalog, $o/@href))//ocil:questionnaire[@id eq $o/@name])) */ |
| 304 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! res = (_req_src_236_2_sub5cxx . . $ _req_src_236_2_sub5(349b1d0c1571cf0c).(component, context, name, rule_id) || _req_src_236_2_sub6cxx . . $ _req_src_236_2_sub6(349b1d0c1571cf0c).(component, context, name, rule_id)); |
| 305 | |
| 306 | freecxx . . $ free(5d22bdacc48458e8).(name); |
| 307 | return res; |
| 308 | } |
| 309 | |
| 310 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _req_src_236_2_sub3cxx . . $ _req_src_236_2_sub3(90ef98cb0b2993e5).(xmlNodePtrcxx . . $ xmlNodePtr# rule_node, xmlNodePtrcxx . . $ xmlNodePtr# catalog, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context) |
| 311 | { |
| 312 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! res = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 313 | char *rule_id = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(rule_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 314 | |
| 315 | /* note: $n is an xccdf:Rule */ |
| 316 | /* if(exists($n/xccdf:check[@system eq 'http://oval.mitre.org/XMLSchema/oval-definitions-5' or @system eq 'http://scap.nist.gov/schema/ocil/2']/xccdf:check-content-ref[exists(@name) and not(xcf:is-external-ref($m/cat:catalog, @href) cast as xsd:boolean)])) then ... else true() */ |
| 317 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# check_content_refs = xmlXPathNodeEvalcxx . . $ xmlXPathNodeEval(5aa74ad3adcbce29).(rule_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "xccdf:check[@system='http://oval.mitre.org/XMLSchema/oval-definitions-5' or @system='http://scap.nist.gov/schema/ocil/2']/xccdf:check-content-ref[@name]", context); |
| 318 | /* TODO: external refs check */ |
| 319 | if (check_content_refs == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || check_content_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 320 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Rule '%s' has no suitable check-content-refs", rule_id); |
| 321 | freecxx . . $ free(5d22bdacc48458e8).(rule_id); |
| 322 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(check_content_refs); |
| 323 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 324 | } |
| 325 | |
| 326 | /* ... then some $o in $n/xccdf:check[@system eq 'http://oval.mitre.org/XMLSchema/oval-definitions-5' or @system eq 'http://scap.nist.gov/schema/ocil/2']/xccdf:check-content-ref[exists(@name) and not(xcf:is-external-ref($m/cat:catalog, @href) cast as xsd:boolean)] satisfies ... */ |
| 327 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! found = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 328 | for (int l = 0; l < check_content_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeNrcxx . . $ _xmlNodeSet#nodeNr.; l++) { |
| 329 | xmlNodePtrcxx . . $ xmlNodePtr# check_content_ref_node = check_content_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeTabcxx . . $ _xmlNodeSet#nodeTab.[l]; |
| 330 | char *href = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(check_content_ref_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "href"); |
| 331 | if (_xcf_is_external_refcxx . . $ _xcf_is_external_ref(6be27bcd423690ab).(catalog, href, context)) { |
| 332 | freecxx . . $ free(5d22bdacc48458e8).(href); |
| 333 | continue; |
| 334 | } |
| 335 | freecxx . . $ free(5d22bdacc48458e8).(href); |
| 336 | if (_req_src_236_2_sub4cxx . . $ _req_src_236_2_sub4(d7e6043d832c7f1c).(check_content_ref_node, catalog, context, rule_id)) { |
| 337 | found = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 338 | break; |
| 339 | } |
| 340 | } |
| 341 | if (!found) { |
| 342 | res = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 343 | } |
| 344 | freecxx . . $ free(5d22bdacc48458e8).(rule_id); |
| 345 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(check_content_refs); |
| 346 | return res; |
| 347 | } |
| 348 | |
| 349 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _req_src_236_2_sub2cxx . . $ _req_src_236_2_sub2(90ef98cb0b2993e5).(xmlNodePtrcxx . . $ xmlNodePtr# component_ref_node, xmlNodePtrcxx . . $ xmlNodePtr# catalog, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context) |
| 350 | { |
| 351 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! res = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 352 | /* every $n in xcf:get-component($m)//xccdf:Rule satisfies ... */ |
| 353 | xmlNodePtrcxx . . $ xmlNodePtr# component_node = _xcf_get_componentcxx . . $ _xcf_get_component(8746e3959ef78c26).(component_ref_node, context); |
| 354 | if (component_node == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 355 | char *xlink_href = (char *) xmlGetNsPropcxx . . $ xmlGetNsProp(3f3adc55d94f1650).(component_ref_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "href", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "http://www.w3.org/1999/xlink"); |
| 356 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't find component using component-ref '%s'", xlink_href); |
| 357 | freecxx . . $ free(5d22bdacc48458e8).(xlink_href); |
| 358 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 359 | } |
| 360 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# rules = xmlXPathNodeEvalcxx . . $ xmlXPathNodeEval(5aa74ad3adcbce29).(component_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! ".//xccdf:Rule", context); |
| 361 | if (rules == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || rules->nodesetvalcxx . . $ _xmlXPathObject#nodesetval. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 362 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(rules); |
| 363 | return res; |
| 364 | } |
| 365 | for (int i = 0; i < rules->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeNrcxx . . $ _xmlNodeSet#nodeNr.; i++) { |
| 366 | xmlNodePtrcxx . . $ xmlNodePtr# rule_node = rules->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeTabcxx . . $ _xmlNodeSet#nodeTab.[i]; |
| 367 | char *rule_id = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(rule_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 368 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Checking xccdf:Rule id='%s'", rule_id); |
| 369 | freecxx . . $ free(5d22bdacc48458e8).(rule_id); |
| 370 | if (!_req_src_236_2_sub3cxx . . $ _req_src_236_2_sub3(90ef98cb0b2993e5).(rule_node, catalog, context)) { |
| 371 | res = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 372 | break; |
| 373 | } |
| 374 | } |
| 375 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(rules); |
| 376 | return res; |
| 377 | } |
| 378 | |
| 379 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _req_src_236_2_sub1cxx . . $ _req_src_236_2_sub1(944ef1d0f7f8902).(xmlNodePtrcxx . . $ xmlNodePtr# data_stream_node, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context) |
| 380 | { |
| 381 | int res = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 382 | /* every $m in ds:checklists/ds:component-ref satisfies ... */ |
| 383 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# component_refs = xmlXPathNodeEvalcxx . . $ xmlXPathNodeEval(5aa74ad3adcbce29).(data_stream_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "ds:checklists/ds:component-ref", context); |
| 384 | if (component_refs == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || component_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 385 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(component_refs); |
| 386 | return res; |
| 387 | } |
| 388 | for (int i = 0; i < component_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeNrcxx . . $ _xmlNodeSet#nodeNr.; i++) { |
| 389 | xmlNodePtrcxx . . $ xmlNodePtr# component_ref_node = component_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeTabcxx . . $ _xmlNodeSet#nodeTab.[i]; |
| 390 | char *component_ref_id = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(component_ref_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 391 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Checking ds:component-ref id='%s'", component_ref_id); |
| 392 | freecxx . . $ free(5d22bdacc48458e8).(component_ref_id); |
| 393 | |
| 394 | /* find $m/catalog */ |
| 395 | xmlNodePtrcxx . . $ xmlNodePtr# catalog = _find_catalogcxx . . $ _find_catalog(3a610665e8c694f1).(component_ref_node); |
| 396 | if (catalog == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 397 | res = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 398 | break; |
| 399 | } |
| 400 | |
| 401 | if (!_req_src_236_2_sub2cxx . . $ _req_src_236_2_sub2(90ef98cb0b2993e5).(component_ref_node, catalog, context)) { |
| 402 | res = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 403 | break; |
| 404 | } |
| 405 | } |
| 406 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(component_refs); |
| 407 | return res; |
| 408 | } |
| 409 | |
| 410 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _req_src_236_2cxx . . $ _req_src_236_2(29efaee24e29d73e).(xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context) |
| 411 | { |
| 412 | /* |
| 413 | * This function implements the check for SCAPVAL requirement SRC-236-2 |
| 414 | * which is implemented in XML Schematron file 'source-data-stream-1.3.sch' |
| 415 | * assert scap-use-case-conf-verification-rule-ref-oval. |
| 416 | * |
| 417 | * <sch:assert id="scap-use-case-conf-verification-rule-ref-oval" test="if( @use-case eq 'CONFIGURATION' ) then every $m in ds:checklists/ds:component-ref satisfies every $n in xcf:get-component($m)//xccdf:Rule satisfies (if(exists($n/ xccdf:check[@system eq 'http://oval.mitre.org/XMLSchema/oval-definitions-5' or @system eq 'http://scap.nist.gov/schema/ocil/2']/xccdf:check-content-ref[exists(@name) and not(xcf:is-external-ref($m/cat:catalog, @href) cast as xsd:boolean)])) then some $o in $n/xccdf:check[@system eq 'http://oval.mitre.org/XMLSchema/oval-definitions-5' or @system eq 'http://scap.nist.gov/schema/ocil/2']/xccdf:check-content-ref[exists(@name) and not(xcf:is-external-ref($m/cat:catalog, @href) cast as xsd:boolean)] satisfies (exists(xcf:get-component(xcf:get-component-ref($m/cat:catalog, $o/@href))//oval-def:definition[@id eq $o/@name and matches(@class,'^(compliance|patch)$')]) or exists(xcf:get-component(xcf: get-component-ref($m/cat:catalog, $o/@href))//ocil:questionnaire[@id eq $o/@name])) else true()) else true()">SRC-236-2|scap:data-stream <sch:value-of select="@id"/></sch:assert> |
| 418 | */ |
| 419 | |
| 420 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! res = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 421 | /* The parent rule element in the schematron matches all scap:data-stream elements */ |
| 422 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# data_streams = xmlXPathEvalcxx . . $ xmlXPathEval(217f200a3c77f61d).(BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "//scap:data-stream", context); |
| 423 | for (int i = 0; i < data_streams->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeNrcxx . . $ _xmlNodeSet#nodeNr.; i++) { |
| 424 | xmlNodePtrcxx . . $ xmlNodePtr# data_stream_node = data_streams->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeTabcxx . . $ _xmlNodeSet#nodeTab.[i]; |
| 425 | /* The assert applies only to configuration use cases */ |
| 426 | /* if(@use-case eq 'CONFIGURATION') then ... else true() */ |
| 427 | char *use_case = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(data_stream_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "use-case"); |
| 428 | if (use_case == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || strcmpcxx . . $ strcmp(5ae29d726ae57f88).(use_case, "CONFIGURATION") != 0) { |
| 429 | continue; |
| 430 | } |
| 431 | freecxx . . $ free(5d22bdacc48458e8).(use_case); |
| 432 | if (!_req_src_236_2_sub1cxx . . $ _req_src_236_2_sub1(944ef1d0f7f8902).(data_stream_node, context)) { |
| 433 | char *data_stream_id = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(data_stream_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 434 | printfcxx . . $ printf(581fddd72a8db8fc).("Error: SRC-236-2|scap:data-stream %s\n", data_stream_id); |
| 435 | freecxx . . $ free(5d22bdacc48458e8).(data_stream_id); |
| 436 | res = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 437 | break; |
| 438 | } |
| 439 | } |
| 440 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(data_streams); |
| 441 | return res; |
| 442 | } |
| 443 | |
| 444 | |
| 445 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _req_src_346_1_sub5cxx . . $ _req_src_346_1_sub5(665a537e84ba7e52).(xmlNodePtrcxx . . $ xmlNodePtr# component, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context, const char *name) |
| 446 | { |
| 447 | /* .//oval-def:definition[@id eq $n/@name]) */ |
| 448 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! exists_oval = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 449 | char *oval_xpath = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).(".//oval-def:definition[@id='%s']", name); |
| 450 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# oval_definitions = xmlXPathNodeEvalcxx . . $ xmlXPathNodeEval(5aa74ad3adcbce29).(component, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! oval_xpath, context); |
| 451 | if (oval_definitions == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || oval_definitions->nodesetvalcxx . . $ _xmlXPathObject#nodesetval. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 452 | goto cleanup; |
| 453 | for (int m = 0; m < oval_definitions->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeNrcxx . . $ _xmlNodeSet#nodeNr.; m++) { |
| 454 | xmlNodePtrcxx . . $ xmlNodePtr# oval_definition = oval_definitions->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeTabcxx . . $ _xmlNodeSet#nodeTab.[m]; |
| 455 | char *oval_def_id = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(oval_definition, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 456 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Found OVAL definition id='%s'", oval_def_id); |
| 457 | freecxx . . $ free(5d22bdacc48458e8).(oval_def_id); |
| 458 | exists_oval = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 459 | } |
| 460 | cleanup: |
| 461 | freecxx . . $ free(5d22bdacc48458e8).(oval_xpath); |
| 462 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(oval_definitions); |
| 463 | return exists_oval; |
| 464 | } |
| 465 | |
| 466 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _req_src_346_1_sub4cxx . . $ _req_src_346_1_sub4(90ef98cb0b2993e5).(xmlNodePtrcxx . . $ xmlNodePtr# check_content_ref_node, xmlNodePtrcxx . . $ xmlNodePtr# catalog, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context) |
| 467 | { |
| 468 | |
| 469 | char *href = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(check_content_ref_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "href"); |
| 470 | /* xcf:get-component(xcf:get-component-ref($m/cat:catalog, $o/@href) */ |
| 471 | xmlNodePtrcxx . . $ xmlNodePtr# component_ref = _xcf_get_component_refcxx . . $ _xcf_get_component_ref(70f2ba06a9ead144).(catalog, href, context); |
| 472 | freecxx . . $ free(5d22bdacc48458e8).(href); |
| 473 | if (component_ref == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 474 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("component_ref not found"); |
| 475 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 476 | } |
| 477 | xmlNodePtrcxx . . $ xmlNodePtr# component = _xcf_get_componentcxx . . $ _xcf_get_component(8746e3959ef78c26).(component_ref, context); |
| 478 | if (component == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 479 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("component not found\n"); |
| 480 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 481 | } |
| 482 | |
| 483 | /* not(exists($n/@name)) or exists(xcf:get-component(xcf:get-component-ref($m/cat:catalog, $n/@href))//oval-def:definition[@id eq $n/@name]) */ |
| 484 | char *name = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(check_content_ref_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "name"); |
| 485 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! res = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 486 | if(name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 487 | res = _req_src_346_1_sub5cxx . . $ _req_src_346_1_sub5(665a537e84ba7e52).(component, context, name); |
| 488 | } |
| 489 | |
| 490 | freecxx . . $ free(5d22bdacc48458e8).(name); |
| 491 | return res; |
| 492 | } |
| 493 | |
| 494 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _req_src_346_1_sub3cxx . . $ _req_src_346_1_sub3(90ef98cb0b2993e5).(xmlNodePtrcxx . . $ xmlNodePtr# rule_node, xmlNodePtrcxx . . $ xmlNodePtr# catalog, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context) |
| 495 | { |
| 496 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! res = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 497 | |
| 498 | /* xccdf:check[@system eq 'http://oval.mitre.org/XMLSchema/oval-definitions-5']//xccdf:check-content-ref[not(xcf:is-external-ref($m/cat:catalog, @href) cast as xsd:boolean)] */ |
| 499 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# check_content_refs = xmlXPathNodeEvalcxx . . $ xmlXPathNodeEval(5aa74ad3adcbce29).(rule_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! ".//xccdf:Rule/xccdf:check[@system='http://oval.mitre.org/XMLSchema/oval-definitions-5']/xccdf:check-content-ref", context); |
| 500 | |
| 501 | if (check_content_refs == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || check_content_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 502 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("There are no check-content-refs elements to be checked."); |
| 503 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(check_content_refs); |
| 504 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 505 | } |
| 506 | |
| 507 | /* ... (not(exists($n/@name)) or exists(xcf:get-component(xcf:get-component-ref($m/cat:catalog, $n/@href))//oval-def:definition[@id eq $n/@name])) */ |
| 508 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! found = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 509 | for (int l = 0; l < check_content_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeNrcxx . . $ _xmlNodeSet#nodeNr.; l++) { |
| 510 | xmlNodePtrcxx . . $ xmlNodePtr# check_content_ref_node = check_content_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeTabcxx . . $ _xmlNodeSet#nodeTab.[l]; |
| 511 | char *href = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(check_content_ref_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "href"); |
| 512 | if (_xcf_is_external_refcxx . . $ _xcf_is_external_ref(6be27bcd423690ab).(catalog, href, context)) { |
| 513 | freecxx . . $ free(5d22bdacc48458e8).(href); |
| 514 | continue; |
| 515 | } |
| 516 | if (!_req_src_346_1_sub4cxx . . $ _req_src_346_1_sub4(90ef98cb0b2993e5).(check_content_ref_node, catalog, context)) { |
| 517 | found = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 518 | break; |
| 519 | } |
| 520 | } |
| 521 | if (!found) { |
| 522 | res = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 523 | } |
| 524 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(check_content_refs); |
| 525 | return res; |
| 526 | } |
| 527 | |
| 528 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _req_src_346_1_sub2cxx . . $ _req_src_346_1_sub2(90ef98cb0b2993e5).(xmlNodePtrcxx . . $ xmlNodePtr# component_ref_node, xmlNodePtrcxx . . $ xmlNodePtr# catalog, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context) |
| 529 | { |
| 530 | /* every $n in xcf:get-component($m)//xccdf:check satisfies ... */ |
| 531 | xmlNodePtrcxx . . $ xmlNodePtr# component_node = _xcf_get_componentcxx . . $ _xcf_get_component(8746e3959ef78c26).(component_ref_node, context); |
| 532 | if (component_node == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 533 | char *xlink_href = (char *) xmlGetNsPropcxx . . $ xmlGetNsProp(3f3adc55d94f1650).(component_ref_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "href", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "http://www.w3.org/1999/xlink"); |
| 534 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't find component using component-ref '%s'", xlink_href); |
| 535 | freecxx . . $ free(5d22bdacc48458e8).(xlink_href); |
| 536 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 537 | } |
| 538 | if (!_req_src_346_1_sub3cxx . . $ _req_src_346_1_sub3(90ef98cb0b2993e5).(component_node, catalog, context)) { |
| 539 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 540 | } |
| 541 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 542 | } |
| 543 | |
| 544 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _req_src_346_1_sub1cxx . . $ _req_src_346_1_sub1(944ef1d0f7f8902).(xmlNodePtrcxx . . $ xmlNodePtr# data_stream_node, xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context) |
| 545 | { |
| 546 | int res = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 547 | /* every $m in ds:checklists/ds:component-ref satisfies ... */ |
| 548 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# component_refs = xmlXPathNodeEvalcxx . . $ xmlXPathNodeEval(5aa74ad3adcbce29).(data_stream_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "ds:checklists/ds:component-ref", context); |
| 549 | if (component_refs == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || component_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 550 | if (component_refs != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 551 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(component_refs); |
| 552 | return res; |
| 553 | } |
| 554 | for (int i = 0; i < component_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeNrcxx . . $ _xmlNodeSet#nodeNr.; i++) { |
| 555 | xmlNodePtrcxx . . $ xmlNodePtr# component_ref_node = component_refs->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeTabcxx . . $ _xmlNodeSet#nodeTab.[i]; |
| 556 | char *component_ref_id = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(component_ref_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 557 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Checking ds:component-ref id='%s'", component_ref_id); |
| 558 | freecxx . . $ free(5d22bdacc48458e8).(component_ref_id); |
| 559 | |
| 560 | /* find $m/catalog */ |
| 561 | xmlNodePtrcxx . . $ xmlNodePtr# catalog = _find_catalogcxx . . $ _find_catalog(3a610665e8c694f1).(component_ref_node); |
| 562 | if (catalog == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 563 | res = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 564 | break; |
| 565 | } |
| 566 | |
| 567 | if (!_req_src_346_1_sub2cxx . . $ _req_src_346_1_sub2(90ef98cb0b2993e5).(component_ref_node, catalog, context)) { |
| 568 | res = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 569 | break; |
| 570 | } |
| 571 | } |
| 572 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(component_refs); |
| 573 | return res; |
| 574 | } |
| 575 | |
| 576 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _req_src_346_1cxx . . $ _req_src_346_1(29efaee24e29d73e).(xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context) |
| 577 | { |
| 578 | /* |
| 579 | * This function implements the check for SCAPVAL requirement SRC-346-1 |
| 580 | * which is implemented in XML Schematron file 'source-data-stream-1.3.sch' |
| 581 | * assert scap-general-scap-content-xccdf-check-content-ref-name-not-req. |
| 582 | * |
| 583 | * <sch:assert id="scap-general-scap-content-xccdf-check-content-ref-name-not-req" test="every $m in ds:checklists/ds:component-ref satisfies every $n in xcf:get-component($m)//xccdf:check[@system eq 'http://oval.mitre.org/XMLSchema/oval-definitions-5']//xccdf:check-content-ref[not(xcf:is-external-ref($m/cat:catalog, @href) cast as xsd:boolean)] satisfies (not(exists($n/@name)) or exists(xcf:get-component(xcf:get-component-ref($m/cat:catalog, $n/@href))//oval-def:definition[@id eq $n/@name]))">SRC-346-1|scap:data-stream <sch:value-of select="@id"/></sch:assert> |
| 584 | */ |
| 585 | |
| 586 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! res = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 587 | /* The parent rule element in the schematron matches all scap:data-stream elements */ |
| 588 | xmlXPathObjectPtrcxx . . $ xmlXPathObjectPtr# data_streams = xmlXPathEvalcxx . . $ xmlXPathEval(217f200a3c77f61d).(BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "//scap:data-stream", context); |
| 589 | for (int i = 0; i < data_streams->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeNrcxx . . $ _xmlNodeSet#nodeNr.; i++) { |
| 590 | xmlNodePtrcxx . . $ xmlNodePtr# data_stream_node = data_streams->nodesetvalcxx . . $ _xmlXPathObject#nodesetval.->nodeTabcxx . . $ _xmlNodeSet#nodeTab.[i]; |
| 591 | if (!_req_src_346_1_sub1cxx . . $ _req_src_346_1_sub1(944ef1d0f7f8902).(data_stream_node, context)) { |
| 592 | char *data_stream_id = (char *) xmlGetPropcxx . . $ xmlGetProp(9828664f081b7881).(data_stream_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 593 | printfcxx . . $ printf(581fddd72a8db8fc).("Error: SRC-346-1|scap:data-stream %s\n", data_stream_id); |
| 594 | freecxx . . $ free(5d22bdacc48458e8).(data_stream_id); |
| 595 | res = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 596 | break; |
| 597 | } |
| 598 | } |
| 599 | xmlXPathFreeObjectcxx . . $ xmlXPathFreeObject(35c1f2c3aee015e6).(data_streams); |
| 600 | return res; |
| 601 | } |
| 602 | |
| 603 | static int _additional_schematron_checkscxx . . $ _additional_schematron_checks(a38c22d0fd42c683).(struct oscap_sourcecxx . . $ oscap_source# *source) |
| 604 | { |
| 605 | xmlDocPtrcxx . . $ xmlDocPtr# doc = oscap_source_get_xmlDoccxx . . $ oscap_source_get_xmlDoc(51aac4e66711e6e6).(source); |
| 606 | xmlXPathContextPtrcxx . . $ xmlXPathContextPtr# context = xmlXPathNewContextcxx . . $ xmlXPathNewContext(87a056aba6f65ba7).(doc); |
| 607 | if (context == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 608 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Error in xmlXPathNewContext"); |
| 609 | return -1; |
| 610 | } |
| 611 | xmlXPathRegisterNscxx . . $ xmlXPathRegisterNs(8fbdd0521ec1038).(context, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "xccdf", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "http://checklists.nist.gov/xccdf/1.2"); |
| 612 | xmlXPathRegisterNscxx . . $ xmlXPathRegisterNs(8fbdd0521ec1038).(context, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "scap", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "http://scap.nist.gov/schema/scap/source/1.2"); |
| 613 | xmlXPathRegisterNscxx . . $ xmlXPathRegisterNs(8fbdd0521ec1038).(context, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "ds", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "http://scap.nist.gov/schema/scap/source/1.2"); |
| 614 | xmlXPathRegisterNscxx . . $ xmlXPathRegisterNs(8fbdd0521ec1038).(context, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "xlink", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "http://www.w3.org/1999/xlink"); |
| 615 | xmlXPathRegisterNscxx . . $ xmlXPathRegisterNs(8fbdd0521ec1038).(context, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "oval-def", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "http://oval.mitre.org/XMLSchema/oval-definitions-5"); |
| 616 | xmlXPathRegisterNscxx . . $ xmlXPathRegisterNs(8fbdd0521ec1038).(context, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "ocil", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "http://scap.nist.gov/schema/ocil/2.0"); |
| 617 | |
| 618 | int res = 0; |
| 619 | /* Assert ID: scap-use-case-conf-verification-benchmark-one-rule-ref-oval-ocil */ |
| 620 | if (!_req_src_236_2cxx . . $ _req_src_236_2(29efaee24e29d73e).(context)) |
| 621 | res = 1; |
| 622 | /* Assert ID: scap-general-scap-content-xccdf-check-content-ref-name-not-req */ |
| 623 | if (!_req_src_346_1cxx . . $ _req_src_346_1(29efaee24e29d73e).(context)) |
| 624 | res = 1; |
| 625 | |
| 626 | xmlXPathFreeContextcxx . . $ xmlXPathFreeContext(a63b128a98dd7774).(context); |
| 627 | return res; |
| 628 | } |
| 629 | |
| 630 | static int _run_schematron_with_warnings_and_errorscxx . . $ _run_schematron_with_warnings_and_errors(b44a10f6a0e05d3e).(struct oscap_sourcecxx . . $ oscap_source# *source, const char *schema_path) |
| 631 | { |
| 632 | int validity = 0; |
| 633 | const char *params[] = { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! }; |
| 634 | char *xslt_output = oscap_source_apply_xslt_path_memcxx . . $ oscap_source_apply_xslt_path_mem(bfc89f1e7ad1e37f).(source, schema_path, params, oscap_path_to_schemascxx . . $ oscap_path_to_schemas(33a1f659e94feb42).()); |
| 635 | if (xslt_output == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 636 | return 1; |
| 637 | } |
| 638 | char *err_substr = strstrcxx . . $ strstr(a713fe7b9a57cf96).(xslt_output, "Error:"); |
| 639 | if (err_substr != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 640 | /* "Error:" found in schematron output */ |
| 641 | validity = 1; |
| 642 | } |
| 643 | putscxx . . $ puts(5c4306d8553b3696).(xslt_output); |
| 644 | freecxx . . $ free(5d22bdacc48458e8).(xslt_output); |
| 645 | return validity; |
| 646 | } |
| 647 | |
| 648 | static int _sds_schematron_validationcxx . . $ _sds_schematron_validation(b44a10f6a0e05d3e).(struct oscap_sourcecxx . . $ oscap_source# *source, const char *schema_path) |
| 649 | { |
| 650 | int validity = 0; |
| 651 | printfcxx . . $ printf(581fddd72a8db8fc).("Starting global schematron validation using the source data stream schematron\n"); |
| 652 | |
| 653 | if (_additional_schematron_checkscxx . . $ _additional_schematron_checks(a38c22d0fd42c683).(source) != 0) { |
| 654 | validity = 1; |
| 655 | } |
| 656 | if (_run_schematron_with_warnings_and_errorscxx . . $ _run_schematron_with_warnings_and_errors(b44a10f6a0e05d3e).(source, schema_path) != 0) { |
| 657 | validity = 1; |
| 658 | } |
| 659 | printfcxx . . $ printf(581fddd72a8db8fc).("Global schematron validation using the source data stream schematron: %s\n\n", validity == 0 ? "PASS" : "FAIL"); |
| 660 | return validity; |
| 661 | } |
| 662 | |
| 663 | int oscap_source_validate_schematron_privcxx . . $ oscap_source_validate_schematron_priv(4191b822de29fb8a).(struct oscap_sourcecxx . . $ oscap_source# *source, oscap_document_type_tcxx . . $ oscap_document_type_t# scap_type, const char *version) |
| 664 | { |
| 665 | const char *origin = oscap_source_readable_origincxx . . $ oscap_source_readable_origin(1485dc36ee4b63be).(source); |
| 666 | if (version == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 667 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_OSCAPcxx . . $ `src/common/public/oscap_error.h:60:9`!, "Could not determine document version for %s", |
| 668 | origin); |
| 669 | return -1; |
| 670 | } |
| 671 | |
| 672 | /* Skip document types that don't have a schematron available */ |
| 673 | if (scap_type == OSCAP_DOCUMENT_CPE_LANGUAGEcxx . . $ OSCAP_DOCUMENT_CPE_LANGUAGE. || |
| 674 | scap_type == OSCAP_DOCUMENT_CPE_DICTIONARYcxx . . $ OSCAP_DOCUMENT_CPE_DICTIONARY. || |
| 675 | scap_type == OSCAP_DOCUMENT_SCE_RESULTcxx . . $ OSCAP_DOCUMENT_SCE_RESULT. || |
| 676 | scap_type == OSCAP_DOCUMENT_OCILcxx . . $ OSCAP_DOCUMENT_OCIL.) { |
| 677 | printfcxx . . $ printf(581fddd72a8db8fc).("Skipped\n"); |
| 678 | return 0; |
| 679 | } |
| 680 | if (scap_type == OSCAP_DOCUMENT_XCCDFcxx . . $ OSCAP_DOCUMENT_XCCDF. && !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(version, "1.1")) { |
| 681 | printfcxx . . $ printf(581fddd72a8db8fc).("Skipped\n"); |
| 682 | return 0; |
| 683 | } |
| 684 | |
| 685 | /* find a right schematron file */ |
| 686 | const char *schematron_path = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 687 | for (struct oscap_schema_table_entrycxx . . $ oscap_schema_table_entry# *entry = OSCAP_SCHEMATRON_TABLEcxx . . $ OSCAP_SCHEMATRON_TABLE.; entry->doc_typecxx . . $ oscap_schema_table_entry#doc_type. != 0; ++entry) { |
| 688 | if (entry->doc_typecxx . . $ oscap_schema_table_entry#doc_type. == scap_type && !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(entry->schema_versioncxx . . $ oscap_schema_table_entry#schema_version., version)) { |
| 689 | schematron_path = entry->schema_pathcxx . . $ oscap_schema_table_entry#schema_path.; |
| 690 | break; |
| 691 | } |
| 692 | } |
| 693 | if (schematron_path == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 694 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_OSCAPcxx . . $ `src/common/public/oscap_error.h:60:9`!, "Schematron rules not found when trying to validate '%s'", origin); |
| 695 | return -1; |
| 696 | } |
| 697 | |
| 698 | /* validate */ |
| 699 | int ret = 0; |
| 700 | if (scap_type == OSCAP_DOCUMENT_SDScxx . . $ OSCAP_DOCUMENT_SDS.) { |
| 701 | int component_validity = _validate_sds_componentscxx . . $ _validate_sds_components(a38c22d0fd42c683).(source); |
| 702 | int global_validity = _sds_schematron_validationcxx . . $ _sds_schematron_validation(b44a10f6a0e05d3e).(source, schematron_path); |
| 703 | if (component_validity != 0 || global_validity != 0) { |
| 704 | ret = 1; |
| 705 | } |
| 706 | printfcxx . . $ printf(581fddd72a8db8fc).("Complete result of schematron validation of '%s': %s\n", origin, ret == 0 ? "PASS" : "FAIL"); |
| 707 | } else if (scap_type == OSCAP_DOCUMENT_XCCDFcxx . . $ OSCAP_DOCUMENT_XCCDF.) { |
| 708 | ret = _run_schematron_with_warnings_and_errorscxx . . $ _run_schematron_with_warnings_and_errors(b44a10f6a0e05d3e).(source, schematron_path); |
| 709 | } else { |
| 710 | const char *params[] = { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! }; |
| 711 | char *xslt_output = oscap_source_apply_xslt_path_memcxx . . $ oscap_source_apply_xslt_path_mem(bfc89f1e7ad1e37f).(source, schematron_path, params, oscap_path_to_schemascxx . . $ oscap_path_to_schemas(33a1f659e94feb42).()); |
| 712 | if (xslt_output != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 713 | ret = 1; |
| 714 | putscxx . . $ puts(5c4306d8553b3696).(xslt_output); |
| 715 | } |
| 716 | freecxx . . $ free(5d22bdacc48458e8).(xslt_output); |
| 717 | } |
| 718 | return ret; |
| 719 | } |