Open SCAP Library
/home/pvrabec/project/openscap/openscap-0.8.0/src/CVSS/cvss_priv.h
Go to the documentation of this file.
00001 
00009 /*
00010  * Copyright 2009 Red Hat Inc., Durham, North Carolina.
00011  * All Rights Reserved.
00012  *
00013  * This library is free software; you can redistribute it and/or
00014  * modify it under the terms of the GNU Lesser General Public
00015  * License as published by the Free Software Foundation; either
00016  * version 2.1 of the License, or (at your option) any later version.
00017  *
00018  * This library is distributed in the hope that it will be useful, 
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  * Lesser General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public
00024  * License along with this library; if not, write to the Free Software 
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  *
00027  * Authors:
00028  *      Maros Barabas <mbarabas@redhat.com>
00029  *      Lukas Kuklinek <lkuklinek@redhat.com>
00030  */
00031 
00032 #ifndef CVSS_PRIV_H_
00033 #define CVSS_PRIV_H_
00034 
00035 #include <stdlib.h>
00036 #include <libxml/xmlreader.h>
00037 #include <libxml/xmlwriter.h>
00038 
00039 #include "public/cvss.h"
00040 #include "../common/util.h"
00041 
00042 OSCAP_HIDDEN_START;
00043 
00044 #define CVSSMAX(a, b) ((a) > (b) ? (a) : (b))
00045 
00046 struct cvss_impact;
00047 struct cvss_metrics;
00048 
00049 enum cvss_key {
00050     CVSS_KEY_NONE = CVSS_NONE,
00051 
00052     CVSS_KEY_access_vector = CVSS_BASE,
00053     CVSS_KEY_access_complexity,
00054     CVSS_KEY_authentication,
00055     CVSS_KEY_confidentiality_impact,
00056     CVSS_KEY_integrity_impact,
00057     CVSS_KEY_availability_impact,
00058     CVSS_KEY_BASE_END_,
00059     CVSS_KEY_BASE_NUM = CVSS_KEY_BASE_END_ - CVSS_BASE,
00060 
00061     CVSS_KEY_exploitability = CVSS_TEMPORAL,
00062     CVSS_KEY_remediation_level,
00063     CVSS_KEY_report_confidence,
00064     CVSS_KEY_TEMPORAL_END_,
00065     CVSS_KEY_TEMPORAL_NUM = CVSS_KEY_TEMPORAL_END_ - CVSS_TEMPORAL,
00066 
00067     CVSS_KEY_collateral_damage_potential = CVSS_ENVIRONMENTAL,
00068     CVSS_KEY_target_distribution,
00069     CVSS_KEY_confidentiality_requirement,
00070     CVSS_KEY_integrity_requirement,
00071     CVSS_KEY_availability_requirement,
00072     CVSS_KEY_ENVIRONMENTAL_END_,
00073     CVSS_KEY_ENVIRONMENTAL_NUM = CVSS_KEY_ENVIRONMENTAL_END_ - CVSS_ENVIRONMENTAL,
00074 };
00075 
00076 // extract category from key
00077 #define CVSS_CATEGORY(key) ((key) & ~0xff)
00078 // extract key index within the category
00079 #define CVSS_KEY_IDX(key) ((key) & 0xff)
00080 
00081 struct cvss_impact {
00082     struct cvss_metrics *base_metrics;
00083     struct cvss_metrics *temporal_metrics;
00084     struct cvss_metrics *environmental_metrics;
00085 };
00086 
00087 struct cvss_metrics {
00088     enum cvss_category category;
00089     float score;
00090     char *source;
00091     char *upgraded_from_version;
00092     char *generated_on_datetime;
00093     union {
00094         unsigned BASE[CVSS_KEY_BASE_NUM];
00095         unsigned TEMPORAL[CVSS_KEY_TEMPORAL_NUM];
00096         unsigned ENVIRONMENTAL[CVSS_KEY_ENVIRONMENTAL_NUM];
00097         unsigned ANY[CVSSMAX(CVSSMAX(CVSS_KEY_BASE_NUM, CVSS_KEY_TEMPORAL_NUM), CVSS_KEY_ENVIRONMENTAL_NUM)];
00098     } metrics;
00099 };
00100 
00101 struct cvss_impact *cvss_impact_new_from_xml(xmlTextReaderPtr reader);
00102 bool cvss_impact_export(const struct cvss_impact *imp, xmlTextWriterPtr writer);
00103 struct cvss_metrics *cvss_metrics_new_from_xml(xmlTextReaderPtr reader);
00104 bool cvss_metrics_export(const struct cvss_metrics *m, xmlTextWriterPtr writer);
00105 
00106 OSCAP_HIDDEN_END;
00107 
00108 #endif