| 1 | /** |
| 2 | * @file cpelang.c |
| 3 | * \brief Interface to Common Platform Enumeration (CPE) Language |
| 4 | * |
| 5 | * See more details at http://nvd.nist.gov/cpe.cfm |
| 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * Copyright 2009 Red Hat Inc., Durham, North Carolina. |
| 10 | * All Rights Reserved. |
| 11 | * |
| 12 | * This library is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU Lesser General Public |
| 14 | * License as published by the Free Software Foundation; either |
| 15 | * version 2.1 of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This library is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 20 | * Lesser General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU Lesser General Public |
| 23 | * License along with this library; if not, write to the Free Software |
| 24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 | * |
| 26 | * Authors: |
| 27 | * Lukas Kuklinek <[email protected]> |
| 28 | * Maros Barabas <[email protected]> |
| 29 | */ |
| 30 | |
| 31 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 32 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 33 | #endif |
| 34 | |
| 35 | #include <libxml/tree.h> |
| 36 | #include <string.h> |
| 37 | |
| 38 | #include "public/cpe_lang.h"cxx . . $ `<file>/src/CPE/public/cpe_lang.h`/ |
| 39 | #include "cpelang_priv.h"cxx . . $ `<file>/src/CPE/cpelang_priv.h`/ |
| 40 | #include "common/util.h"cxx . . $ `<file>/src/common/util.h`/ |
| 41 | #include "common/list.h"cxx . . $ `<file>/src/common/list.h`/ |
| 42 | #include "source/public/oscap_source.h"cxx . . $ `<file>/src/source/public/oscap_source.h`/ |
| 43 | |
| 44 | #define CPE_LANG_SUPPORTEDcxx . . $ `src/CPE/cpelang.c:44:9`! "2.2" |
| 45 | |
| 46 | void cpe_lang_model_exportcxx . . $ cpe_lang_model_export(4858f5190288acad).(const struct cpe_lang_modelcxx . . $ cpe_lang_model# *spec, const char *file) |
| 47 | { |
| 48 | |
| 49 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(spec); |
| 50 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(file); |
| 51 | |
| 52 | if (file == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 53 | return; |
| 54 | |
| 55 | cpe_lang_model_export_xmlcxx . . $ cpe_lang_model_export_xml(4858f5190288acad).(spec, file); |
| 56 | } |
| 57 | |
| 58 | const char * cpe_lang_model_supportedcxx . . $ cpe_lang_model_supported(33a1f659e94feb42).(void) |
| 59 | { |
| 60 | return CPE_LANG_SUPPORTEDcxx . . $ `src/CPE/cpelang.c:44:9`!; |
| 61 | } |
| 62 | |
| 63 | char *cpe_lang_model_detect_version_privcxx . . $ cpe_lang_model_detect_version_priv(93c99f8009311dd0).(xmlTextReadercxx . . $ xmlTextReader# *reader) |
| 64 | { |
| 65 | // FIXME: There is no detection logic in there, since there is only |
| 66 | // one version of CPE language so we just return that. |
| 67 | return oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).("2.3"); |
| 68 | } |
| 69 | |
| 70 | /* |
| 71 | bool cpe_language_match_str(const char* cpe, const struct cpe_platform* platform) |
| 72 | { |
| 73 | |
| 74 | __attribute__nonnull__(cpe); |
| 75 | __attribute__nonnull__(platform); |
| 76 | |
| 77 | struct cpe_name* cpe_; |
| 78 | bool ret; |
| 79 | |
| 80 | cpe_ = cpe_new(cpe); |
| 81 | if (cpe_ == NULL) return false; |
| 82 | ret = cpe_language_match_cpe(cpe_, platform); |
| 83 | cpe_free(cpe_); |
| 84 | return ret; |
| 85 | } |
| 86 | */ |
| 87 | |
| 88 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_testexpr_evaluatecxx . . $ cpe_testexpr_evaluate(f6a281a4ee3882e3).(const struct cpe_testexprcxx . . $ cpe_testexpr#* expr, cpe_check_fncxx . . $ cpe_check_fn# check_cb, cpe_dict_fncxx . . $ cpe_dict_fn# dict_cb, void* usr) |
| 89 | { |
| 90 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ret = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 91 | |
| 92 | switch (cpe_testexpr_get_opercxx . . $ cpe_testexpr_get_oper(3e064e29640ede32).(expr) & CPE_LANG_OPER_MASKcxx . . $ CPE_LANG_OPER_MASK.) { |
| 93 | case CPE_LANG_OPER_ANDcxx . . $ CPE_LANG_OPER_AND.: |
| 94 | ret = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 95 | OSCAP_FOREACHcxx . . $ `src/common/list.h:128:9`!(cpe_testexpr, cur, cpe_testexpr_get_meta_expr(expr), |
| 96 | if (!cpe_testexpr_evaluate(cur, check_cb, dict_cb, usr)) { |
| 97 | ret = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 98 | break; |
| 99 | } |
| 100 | ) |
| 101 | break; |
| 102 | case CPE_LANG_OPER_ORcxx . . $ CPE_LANG_OPER_OR.: |
| 103 | OSCAP_FOREACHcxx . . $ `src/common/list.h:128:9`!(cpe_testexpr, cur, cpe_testexpr_get_meta_expr(expr), |
| 104 | if (cpe_testexpr_evaluate(cur, check_cb, dict_cb, usr)) { |
| 105 | ret = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 106 | break; |
| 107 | } |
| 108 | ) |
| 109 | break; |
| 110 | case CPE_LANG_OPER_MATCHcxx . . $ CPE_LANG_OPER_MATCH.: |
| 111 | ret = dict_cb(cpe_testexpr_get_meta_cpecxx . . $ cpe_testexpr_get_meta_cpe(c4e3bde4985cd277).(expr), usr); |
| 112 | break; |
| 113 | case CPE_LANG_OPER_CHECKcxx . . $ CPE_LANG_OPER_CHECK.: |
| 114 | ret = check_cb(cpe_testexpr_get_meta_check_systemcxx . . $ cpe_testexpr_get_meta_check_system(7874a5a4db6d0ea3).(expr), cpe_testexpr_get_meta_check_hrefcxx . . $ cpe_testexpr_get_meta_check_href(7874a5a4db6d0ea3).(expr), cpe_testexpr_get_meta_check_idcxx . . $ cpe_testexpr_get_meta_check_id(7874a5a4db6d0ea3).(expr), usr); |
| 115 | break; |
| 116 | default: |
| 117 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(false); |
| 118 | } |
| 119 | |
| 120 | return (cpe_testexpr_get_opercxx . . $ cpe_testexpr_get_oper(3e064e29640ede32).(expr) & CPE_LANG_OPER_NOTcxx . . $ CPE_LANG_OPER_NOT.) ? !ret : ret; |
| 121 | } |
| 122 | |
| 123 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_platform_applicable_lang_modelcxx . . $ cpe_platform_applicable_lang_model(1e40406a95e00665).(const char* platform, struct cpe_lang_modelcxx . . $ cpe_lang_model# *lang_model, cpe_check_fncxx . . $ cpe_check_fn# check_cb, cpe_dict_fncxx . . $ cpe_dict_fn# dict_fn, void* usr) |
| 124 | { |
| 125 | struct cpe_platformcxx . . $ cpe_platform#* plat = cpe_lang_model_get_itemcxx . . $ cpe_lang_model_get_item(dc6ef1735840ff3a).(lang_model, platform); |
| 126 | |
| 127 | if (plat == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) // can't find any matching platform implies not applicable |
| 128 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 129 | |
| 130 | const struct cpe_testexprcxx . . $ cpe_testexpr#* expr = cpe_platform_get_exprcxx . . $ cpe_platform_get_expr(bf8f903aa86dc72).(plat); |
| 131 | return cpe_testexpr_evaluatecxx . . $ cpe_testexpr_evaluate(f6a281a4ee3882e3).(expr, check_cb, dict_fn, usr); |
| 132 | } |