|
Open SCAP Library
|
00001 /* 00002 * Copyright 2017 Red Hat Inc., Durham, North Carolina. 00003 * All Rights Reserved. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 * 00019 * Authors: 00020 * Katarina Jankov <kj226@cornell.edu> 00021 * 00022 */ 00023 #ifndef CVRF_PRIV_H_ 00024 #define CVRF_PRIV_H_ 00025 00026 #include <libxml/xmlreader.h> 00027 #include <libxml/tree.h> 00028 #include <libxml/xpath.h> 00029 #include <libxml/parser.h> 00030 #include <libxml/xpathInternals.h> 00031 00032 #include "../common/list.h" 00033 #include "../common/elements.h" 00034 #include "cvrf.h" 00035 00036 OSCAP_HIDDEN_START; 00037 00038 // namespaces 00039 #define CVRF_NS BAD_CAST "http://www.icasi.org/CVRF/schema/cvrf/1.1" 00040 #define PROD_NS BAD_CAST "http://www.icasi.org/CVRF/schema/prod/1.1" 00041 #define VULN_NS BAD_CAST "http://www.icasi.org/CVRF/schema/vuln/1.1" 00042 00043 /*-----------------------------------------------------------------------------------------*\ 00044 | CVRF Enum Definitions | 00045 \*-----------------------------------------------------------------------------------------*/ 00046 00047 /************************************************************************************************ 00048 * Type attribute of a DocumentPublisher element and Party attribute of an Involvement element 00049 * (these must match in the same document) 00050 */ 00051 typedef enum { 00052 CVRF_DOC_PUBLISHER_UNKNOWN = 0, 00053 CVRF_DOC_PUBLISHER_VENDOR, 00054 CVRF_DOC_PUBLISHER_DISCOVERER, 00055 CVRF_DOC_PUBLISHER_COORDINATOR, 00056 CVRF_DOC_PUBLISHER_USER, 00057 CVRF_DOC_PUBLISHER_OTHER, 00058 } cvrf_doc_publisher_type_t; 00059 00066 cvrf_doc_publisher_type_t cvrf_doc_publisher_get_type(struct cvrf_doc_publisher *publisher); 00067 00074 cvrf_doc_publisher_type_t cvrf_involvement_get_party(struct cvrf_involvement *involve); 00075 00081 cvrf_doc_publisher_type_t cvrf_doc_publisher_type_parse(xmlTextReaderPtr reader); 00082 00089 cvrf_doc_publisher_type_t cvrf_involvement_party_parse(xmlTextReaderPtr reader); 00090 00096 const char *cvrf_doc_publisher_type_get_text(cvrf_doc_publisher_type_t type); 00097 00098 /************************************************************************************************ 00099 * Type represented as a child node of the DocumentTracking element 00100 * Refers to stage of completeness of the document and likelihood of it changing 00101 */ 00102 typedef enum { 00103 CVRF_DOC_STATUS_UNKNOWN = 0, 00104 CVRF_DOC_STATUS_DRAFT, 00105 CVRF_DOC_STATUS_INTERIM, 00106 CVRF_DOC_STATUS_FINAL, 00107 } cvrf_doc_status_type_t; 00108 00115 cvrf_doc_status_type_t cvrf_doc_tracking_get_status(struct cvrf_doc_tracking *tracking); 00116 00122 cvrf_doc_status_type_t cvrf_doc_status_type_parse(xmlTextReaderPtr reader); 00123 00129 const char *cvrf_doc_status_type_get_text(cvrf_doc_status_type_t type); 00130 00131 /************************************************************************************************ 00132 * Type attribute of the Note element 00133 * Category of information provided by a Note element 00134 */ 00135 typedef enum { 00136 CVRF_NOTE_UNKNOWN = 0, 00137 CVRF_NOTE_GENERAL, 00138 CVRF_NOTE_DETAILS, 00139 CVRF_NOTE_DESCRIPTION, 00140 CVRF_NOTE_SUMMARY, 00141 CVRF_NOTE_FAQ, 00142 CVRF_NOTE_LEGAL_DISCLAIMER, 00143 CVRF_NOTE_OTHER, 00144 } cvrf_note_type_t; 00145 00152 cvrf_note_type_t cvrf_note_get_note_type(const struct cvrf_note *note); 00153 00159 cvrf_note_type_t cvrf_note_type_parse(xmlTextReaderPtr reader); 00160 00166 const char *cvrf_note_type_get_text(cvrf_note_type_t type); 00167 00168 /************************************************************************************************ 00169 * Type attribute of the Reference element 00170 * Indicates whether the reference refers to a document or to an external source 00171 */ 00172 typedef enum { 00173 CVRF_REFERENCE_UNKNOWN = 0, 00174 CVRF_REFERENCE_EXTERNAL, 00175 CVRF_REFERENCE_SELF, 00176 } cvrf_reference_type_t; 00177 00184 cvrf_reference_type_t cvrf_reference_get_reference_type(struct cvrf_reference *reference); 00185 00191 cvrf_reference_type_t cvrf_reference_type_parse(xmlTextReaderPtr reader); 00192 00198 const char *cvrf_reference_type_get_text(cvrf_reference_type_t type); 00199 00200 /************************************************************************************************ 00201 * Type attribute of the Branch element 00202 * Category and context for the information provided in the Name attribute 00203 */ 00204 typedef enum { 00205 CVRF_BRANCH_UNKNOWN = 0, 00206 CVRF_BRANCH_VENDOR, 00207 CVRF_BRANCH_PRODUCT_FAMILY, 00208 CVRF_BRANCH_PRODUCT_NAME, 00209 CVRF_BRANCH_PRODUCT_VERSION, 00210 CVRF_BRANCH_PATCH_LEVEL, 00211 CVRF_BRANCH_SERVICE_PACK, 00212 CVRF_BRANCH_ARCHITECTURE, 00213 CVRF_BRANCH_LANGUAGE, 00214 CVRF_BRANCH_LEGACY, 00215 CVRF_BRANCH_SPECIFICATION, 00216 } cvrf_branch_type_t; 00217 00224 cvrf_branch_type_t cvrf_branch_get_branch_type(struct cvrf_branch *branch); 00225 00231 cvrf_branch_type_t cvrf_branch_type_parse(xmlTextReaderPtr reader); 00232 00238 const char *cvrf_branch_type_get_text(cvrf_branch_type_t type); 00239 00240 /************************************************************************************************ 00241 * RelationType attribute of the Relationship element 00242 * Defines how the products named in the ProductReference and RelatesToProductReference attributes 00243 * are related 00244 * EX: 00245 * <Relationship ProductReference="A" RelationType="?" RelatesToProductReference="B"> 00246 */ 00247 typedef enum { 00248 CVRF_RELATIONSHIP_UNKNOWN = 0, 00249 CVRF_RELATIONSHIP_DEFAULT_COMPONENT, 00250 CVRF_RELATIONSHIP_OPTIONAL_COMPONENT, 00251 CVRF_RELATIONSHIP_EXTERNAL_COMPONENT, 00252 CVRF_RELATIONSHIP_INSTALLED_ON, 00253 CVRF_RELATIONSHIP_INSTALLED_WITH, 00254 } cvrf_relationship_type_t; 00255 00262 cvrf_relationship_type_t cvrf_relationship_get_relation_type(struct cvrf_relationship *relation); 00263 00269 cvrf_relationship_type_t cvrf_relationship_type_parse(xmlTextReaderPtr reader); 00270 00276 const char *cvrf_relationship_type_get_text(cvrf_relationship_type_t type); 00277 00278 /************************************************************************************************ 00279 * Status attribute of the Involvement element 00280 * Indicates level of involvement of the Party referenced in the Involvement's Party attribute 00281 */ 00282 typedef enum { 00283 CVRF_INVOLVEMENT_UNKNOWN = 0, 00284 CVRF_INVOLVEMENT_OPEN, 00285 CVRF_INVOLVEMENT_DISPUTED, 00286 CVRF_INVOLVEMENT_IN_PROGRESS, 00287 CVRF_INVOLVEMENT_COMPLETED, 00288 CVRF_INVOLVEMENT_CONTACT_ATTEMPTED, 00289 CVRF_INVOLVEMENT_NOT_CONTACTED, 00290 } cvrf_involvement_status_type_t; 00291 00298 cvrf_involvement_status_type_t cvrf_involvement_get_status_type(struct cvrf_involvement *involve); 00299 00305 cvrf_involvement_status_type_t cvrf_involvement_status_type_parse(xmlTextReaderPtr reader); 00306 00312 const char *cvrf_involvement_status_type_get_text(cvrf_involvement_status_type_t type); 00313 00314 00315 /************************************************************************************************ 00316 * Type attribute of the Status element 00317 * Indicates the status of products with regards to a Vulnerability: whether this Vulnerability 00318 * is known to affect the product, whether a fix exists for the version in the release, etc. 00319 */ 00320 typedef enum { 00321 CVRF_PRODUCT_STATUS_UNKNOWN = 0, 00322 CVRF_PRODUCT_STATUS_FIRST_AFFECTED, 00323 CVRF_PRODUCT_STATUS_KNOWN_AFFECTED, 00324 CVRF_PRODUCT_STATUS_KNOWN_NOT_AFFECTED, 00325 CVRF_PRODUCT_STATUS_FIRST_FIXED, 00326 CVRF_PRODUCT_STATUS_FIXED, 00327 CVRF_PRODUCT_STATUS_RECOMMENDED, 00328 CVRF_PRODUCT_STATUS_LAST_AFFECTED, 00329 } cvrf_product_status_type_t; 00330 00331 00338 cvrf_product_status_type_t cvrf_product_status_get_type(struct cvrf_product_status *stat); 00339 00345 cvrf_product_status_type_t cvrf_product_status_type_parse(xmlTextReaderPtr reader); 00346 00352 const char *cvrf_product_status_type_get_text(cvrf_product_status_type_t product_status_type); 00353 00354 /************************************************************************************************ 00355 * Type attribute of the Threat element 00356 * Category of information the Threat provides about the Vulnerability; gives context about 00357 * impact and damage done by the Vulnerability 00358 */ 00359 typedef enum { 00360 CVRF_THREAT_UNKNOWN = 0, 00361 CVRF_THREAT_IMPACT, 00362 CVRF_THREAT_EXPLOIT_STATUS, 00363 CVRF_THREAT_TARGET_SET, 00364 } cvrf_threat_type_t; 00365 00372 cvrf_threat_type_t cvrf_threat_get_threat_type(struct cvrf_threat *threat); 00373 00379 cvrf_threat_type_t cvrf_threat_type_parse(xmlTextReaderPtr reader); 00380 00386 const char *cvrf_threat_type_get_text(cvrf_threat_type_t threat_type); 00387 00388 /************************************************************************************************ 00389 * Type attribute of the Remediation element 00390 * Category of and status about ways to avoid, mitigate, or resolve a Vulnerability 00391 */ 00392 typedef enum { 00393 CVRF_REMEDIATION_UNKNOWN = 0, 00394 CVRF_REMEDIATION_WORKAROUND, 00395 CVRF_REMEDIATION_MITIGATION, 00396 CVRF_REMEDIATION_VENDOR_FIX, 00397 CVRF_REMEDIATION_NONE_AVAILABLE, 00398 CVRF_REMEDIATION_WILL_NOT_FIX, 00399 } cvrf_remediation_type_t; 00400 00407 cvrf_remediation_type_t cvrf_remediation_get_type(struct cvrf_remediation *remed); 00408 00414 cvrf_remediation_type_t cvrf_remediation_type_parse(xmlTextReaderPtr reader); 00415 00421 const char *cvrf_remediation_type_get_text(cvrf_remediation_type_t remediation_type); 00422 00423 00424 /************************************************************************************************ 00425 * @struct cvrf_item_spec 00426 * Maps a cvrf_item_type_t enum to its text representation within a CVRF XML file, 00427 * as well as the parent container (if one exists) 00428 */ 00429 struct cvrf_item_spec; 00430 00431 typedef enum { 00432 CVRF_ITEM_UNKNOWN = 0, 00433 CVRF_DOCUMENT_PUBLISHER, 00434 CVRF_DOCUMENT_TRACKING, 00435 CVRF_REVISION, 00436 CVRF_DOCUMENT_NOTE, 00437 CVRF_DOCUMENT_REFERENCE, 00438 CVRF_ACKNOWLEDGMENT, 00439 CVRF_PRODUCT_TREE, 00440 CVRF_BRANCH, 00441 CVRF_GROUP, 00442 CVRF_RELATIONSHIP, 00443 CVRF_PRODUCT_NAME, 00444 CVRF_VULNERABILITY, 00445 CVRF_VULNERABILITY_CWE, 00446 CVRF_NOTE, 00447 CVRF_INVOLVEMENT, 00448 CVRF_SCORE_SET, 00449 CVRF_PRODUCT_STATUS, 00450 CVRF_THREAT, 00451 CVRF_REMEDIATION, 00452 CVRF_REFERENCE, 00453 } cvrf_item_type_t; 00454 00460 const char *cvrf_item_type_get_text(cvrf_item_type_t type); 00461 00467 cvrf_item_type_t cvrf_item_type_from_text(const char *item); 00468 00473 bool cvrf_is_valid_item_type(const char *item); 00474 00480 const char *cvrf_item_type_get_container(cvrf_item_type_t type); 00481 00488 bool cvrf_item_type_has_container(cvrf_item_type_t type); 00489 00490 00491 /*-----------------------------------------------------------------------------------------*\ 00492 | CVRF Parsing & Serialization Functions | 00493 \*-----------------------------------------------------------------------------------------*/ 00494 00500 struct cvrf_remediation *cvrf_remediation_parse(xmlTextReaderPtr reader); 00501 00507 struct cvrf_score_set *cvrf_score_set_parse(xmlTextReaderPtr reader); 00508 00514 struct cvrf_threat *cvrf_threat_parse(xmlTextReaderPtr reader); 00515 00521 struct cvrf_product_status *cvrf_product_status_parse(xmlTextReaderPtr reader); 00522 00528 struct cvrf_involvement *cvrf_involvement_parse(xmlTextReaderPtr reader); 00529 00535 struct cvrf_vulnerability_cwe *cvrf_vulnerability_cwe_parse(xmlTextReaderPtr reader); 00536 00542 struct cvrf_vulnerability *cvrf_vulnerability_parse(xmlTextReaderPtr reader); 00543 00549 struct cvrf_product_name *cvrf_product_name_parse(xmlTextReaderPtr reader); 00550 00556 struct cvrf_group *cvrf_group_parse(xmlTextReaderPtr reader); 00557 00563 struct cvrf_relationship *cvrf_relationship_parse(xmlTextReaderPtr reader); 00564 00570 struct cvrf_branch *cvrf_branch_parse(xmlTextReaderPtr reader); 00571 00577 struct cvrf_product_tree *cvrf_product_tree_parse(xmlTextReaderPtr reader); 00578 00584 struct cvrf_acknowledgment *cvrf_acknowledgment_parse(xmlTextReaderPtr reader); 00585 00591 struct cvrf_reference *cvrf_reference_parse(xmlTextReaderPtr reader); 00592 00598 struct cvrf_note *cvrf_note_parse(xmlTextReaderPtr reader); 00599 00605 struct cvrf_revision *cvrf_revision_parse(xmlTextReaderPtr reader); 00606 00612 struct cvrf_doc_tracking *cvrf_doc_tracking_parse(xmlTextReaderPtr reader); 00613 00619 struct cvrf_doc_publisher *cvrf_doc_publisher_parse(xmlTextReaderPtr reader); 00620 00627 struct cvrf_document *cvrf_document_parse(xmlTextReaderPtr reader); 00628 00634 struct cvrf_model *cvrf_model_parse(xmlTextReaderPtr reader); 00635 00641 struct cvrf_index *cvrf_index_parse_xml(struct oscap_source *index_source); 00642 00643 00651 void cvrf_element_add_container(struct oscap_list *list, cvrf_item_type_t cvrf_type, xmlNode *parent); 00652 00660 void cvrf_element_add_stringlist(struct oscap_stringlist *list, const char *tag_name, xmlNode *parent); 00661 00669 void cvrf_element_add_attribute(const char *attr_name, const char *attr_value, xmlNode *element); 00670 00678 void cvrf_element_add_child(const char *elm_name, const char *elm_value, xmlNode *parent); 00679 00686 xmlNode *cvrf_element_to_dom(const char *elm_name, const char *elm_value); 00687 00694 xmlNode *cvrf_remediation_to_dom(const struct cvrf_remediation *remed); 00695 00702 xmlNode *cvrf_threat_to_dom(const struct cvrf_threat *threat); 00703 00710 xmlNode *cvrf_score_set_to_dom(const struct cvrf_score_set *score_set); 00711 00718 xmlNode *cvrf_product_status_to_dom(const struct cvrf_product_status *stat); 00719 00726 xmlNode *cvrf_involvement_to_dom(const struct cvrf_involvement *involve); 00727 00734 xmlNode *cvrf_vulnerability_cwe_to_dom(const struct cvrf_vulnerability_cwe *vuln_cwe); 00735 00742 xmlNode *cvrf_vulnerability_to_dom(const struct cvrf_vulnerability *vuln); 00743 00750 xmlNode *cvrf_product_name_to_dom(struct cvrf_product_name *full_name); 00751 00758 xmlNode *cvrf_group_to_dom(const struct cvrf_group *group); 00759 00766 xmlNode *cvrf_relationship_to_dom(const struct cvrf_relationship *relation); 00767 00774 xmlNode *cvrf_branch_to_dom(struct cvrf_branch *branch); 00775 00782 xmlNode *cvrf_product_tree_to_dom(struct cvrf_product_tree *tree); 00783 00790 xmlNode *cvrf_acknowledgment_to_dom(struct cvrf_acknowledgment *ack); 00791 00798 xmlNode *cvrf_reference_to_dom(struct cvrf_reference *ref); 00799 00807 xmlNode *cvrf_note_to_dom(struct cvrf_note *note); 00808 00815 xmlNode *cvrf_revision_to_dom(struct cvrf_revision *revision); 00816 00823 xmlNode *cvrf_doc_tracking_to_dom(struct cvrf_doc_tracking *tracking); 00824 00831 xmlNode *cvrf_doc_publisher_to_dom(struct cvrf_doc_publisher *publisher); 00832 00840 xmlNode *cvrf_document_to_dom(struct cvrf_document *document); 00841 00850 xmlNode *cvrf_model_to_dom(struct cvrf_model *model, xmlDocPtr doc, xmlNode *parent, void *user_args); 00851 00859 xmlNode *cvrf_index_to_dom(struct cvrf_index *index, xmlDocPtr doc, xmlNode *parent, void *user_args); 00860 00861 bool cvrf_product_vulnerability_fixed(struct cvrf_vulnerability *vuln, const char *product); 00862 00863 OSCAP_HIDDEN_END; 00864 00865 #endif /* _CVRF_PRIV_H_ */
1.7.3