| 1 | /** |
| 2 | * @file cpelang_priv.h |
| 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 | * Maros Barabas <[email protected]> |
| 28 | */ |
| 29 | |
| 30 | #ifndef CPELANG_PRIV_H_ |
| 31 | #define CPELANG_PRIV_H_ |
| 32 | |
| 33 | #include <libxml/xmlreader.h> |
| 34 | #include <libxml/xmlwriter.h> |
| 35 | |
| 36 | #include "cpe_lang.h" |
| 37 | #include "../common/util.h" |
| 38 | #include "../common/list.h" |
| 39 | #include "../common/elements.h" |
| 40 | #include "../common/public/oscap.h" |
| 41 | |
| 42 | /** |
| 43 | * @cond INTERNAL |
| 44 | */ |
| 45 | /* @endcond */ |
| 46 | |
| 47 | /** |
| 48 | * @struct cpe_testexpr |
| 49 | * CPE language boolean expression |
| 50 | */ |
| 51 | struct cpe_testexpr { |
| 52 | cpe_lang_oper_t oper; ///< operator |
| 53 | union { |
| 54 | struct oscap_list *expr; ///< array of subexpressions for operators |
| 55 | struct cpe_name *cpe; ///< CPE for match operation |
| 56 | struct { |
| 57 | char* system; |
| 58 | char* href; |
| 59 | char* id; |
| 60 | } check; |
| 61 | } meta; ///< operation metadata |
| 62 | }; |
| 63 | |
| 64 | /** |
| 65 | * @struct cpe_lang_model |
| 66 | * CPE platform specification |
| 67 | */ |
| 68 | struct cpe_lang_model; |
| 69 | |
| 70 | /** |
| 71 | * @struct cpe_platform |
| 72 | * Single platform representation in CPE language |
| 73 | */ |
| 74 | struct cpe_platform; |
| 75 | |
| 76 | /** |
| 77 | * Parse function for CPE Lang model |
| 78 | * @param reader xmlTextReaderPtr structure representing XML model |
| 79 | */ |
| 80 | struct cpe_lang_model *cpe_lang_model_parse(xmlTextReaderPtr reader); |
| 81 | |
| 82 | /** |
| 83 | * Parse CPE platform structure |
| 84 | * @param reader xmlTextReaderPtr structure representing XML model |
| 85 | * @return cpe_platform structure with CPE platform item |
| 86 | */ |
| 87 | struct cpe_platform *cpe_platform_parse(xmlTextReaderPtr reader); |
| 88 | |
| 89 | /** |
| 90 | * Parse CPE test expression structure |
| 91 | * @param reader xmlTextReaderPtr structure representing XML model |
| 92 | * @return cpe_testexpr structure with CPE test expression item |
| 93 | */ |
| 94 | struct cpe_testexpr *cpe_testexpr_parse(xmlTextReaderPtr reader); |
| 95 | |
| 96 | /** |
| 97 | * Function for export CPE language model to XML |
| 98 | * @param spec CPE language model structure |
| 99 | * @param file filename |
| 100 | */ |
| 101 | void cpe_lang_model_export_xml(const struct cpe_lang_model *spec, const char *file); |
| 102 | |
| 103 | /** |
| 104 | * Function for export CPE language top element |
| 105 | * @param writer xmlTextWriterPtr structure representing XML model |
| 106 | * @param spec CPE language model structure |
| 107 | */ |
| 108 | void cpe_lang_export(const struct cpe_lang_model *spec, xmlTextWriterPtr writer); |
| 109 | |
| 110 | /** |
| 111 | * Function for export CPE platform element |
| 112 | * @param writer xmlTextWriterPtr structure representing XML model |
| 113 | * @param platform CPE platform structure |
| 114 | */ |
| 115 | void cpe_platform_export(const struct cpe_platform *platform, xmlTextWriterPtr writer); |
| 116 | |
| 117 | /** |
| 118 | * Function for export CPE test expression element |
| 119 | * @param writer xmlTextWriterPtr structure representing XML model |
| 120 | * @param expr CPE test expression structure |
| 121 | */ |
| 122 | void cpe_testexpr_export(const struct cpe_testexpr *expr, xmlTextWriterPtr writer); |
| 123 | |
| 124 | char *cpe_lang_model_detect_version_priv(xmlTextReader *reader); |
| 125 | |
| 126 | /** |
| 127 | * Sets the origin file hint |
| 128 | * @see cpe_lang_model_get_origin_file |
| 129 | */ |
| 130 | bool cpe_lang_model_set_origin_file(struct cpe_lang_model* lang_model, const char* origin_file); |
| 131 | |
| 132 | /** |
| 133 | * Gets the file the CPE dict model was loaded from |
| 134 | * This is necessary to figure out the full OVAL file path for applicability |
| 135 | * testing. We can't do applicability here in the CPE module because that |
| 136 | * would create awful interdependencies. |
| 137 | */ |
| 138 | const char* cpe_lang_model_get_origin_file(const struct cpe_lang_model* lang_model); |
| 139 | |
| 140 | |
| 141 | /** |
| 142 | * @cond INTERNAL |
| 143 | */ |
| 144 | /* @endcond */ |
| 145 | |
| 146 | #endif |