Open SCAP Library: cvss_priv.h Source File

Open SCAP Library

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

cvss_priv.h
Go to the documentation of this file.
1
9 /*
10 * Copyright 2009 Red Hat Inc., Durham, North Carolina.
11 * All Rights Reserved.
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * Authors:
28 * Maros Barabas <mbarabas@redhat.com>
29 * Lukas Kuklinek <lkuklinek@redhat.com>
30 */
31
32 #ifndef CVSS_PRIV_H_
33 #define CVSS_PRIV_H_
34
35 #include <stdlib.h>
36 #include <libxml/xmlreader.h>
37 #include <libxml/xmlwriter.h>
38
39 #include "public/cvss_score.h"
40 #include "common/util.h"
41
42 OSCAP_HIDDEN_START;
43
44 #define CVSSMAX(a, b) ((a) > (b) ? (a) : (b))
45
46 struct cvss_impact;
47 struct cvss_metrics;
48
49 enum cvss_key {
50 CVSS_KEY_NONE = CVSS_NONE,
51
52 CVSS_KEY_access_vector = CVSS_BASE,
53 CVSS_KEY_access_complexity,
54 CVSS_KEY_authentication,
55 CVSS_KEY_confidentiality_impact,
56 CVSS_KEY_integrity_impact,
57 CVSS_KEY_availability_impact,
58 CVSS_KEY_BASE_END_,
59 CVSS_KEY_BASE_NUM = CVSS_KEY_BASE_END_ - CVSS_BASE,
60
61 CVSS_KEY_exploitability = CVSS_TEMPORAL,
62 CVSS_KEY_remediation_level,
63 CVSS_KEY_report_confidence,
64 CVSS_KEY_TEMPORAL_END_,
65 CVSS_KEY_TEMPORAL_NUM = CVSS_KEY_TEMPORAL_END_ - CVSS_TEMPORAL,
66
67 CVSS_KEY_collateral_damage_potential = CVSS_ENVIRONMENTAL,
68 CVSS_KEY_target_distribution,
69 CVSS_KEY_confidentiality_requirement,
70 CVSS_KEY_integrity_requirement,
71 CVSS_KEY_availability_requirement,
72 CVSS_KEY_ENVIRONMENTAL_END_,
73 CVSS_KEY_ENVIRONMENTAL_NUM = CVSS_KEY_ENVIRONMENTAL_END_ - CVSS_ENVIRONMENTAL,
74 };
75
76 // extract category from key
77 #define CVSS_CATEGORY(key) ((key) & ~0xff)
78 // extract key index within the category
79 #define CVSS_KEY_IDX(key) ((key) & 0xff)
80
81 struct cvss_impact {
82 struct cvss_metrics *base_metrics;
83 struct cvss_metrics *temporal_metrics;
84 struct cvss_metrics *environmental_metrics;
85 };
86
87 struct cvss_metrics {
88 enum cvss_category category;
89 float score;
90 char *source;
91 char *upgraded_from_version;
92 char *generated_on_datetime;
93 union {
94 unsigned BASE[CVSS_KEY_BASE_NUM];
95 unsigned TEMPORAL[CVSS_KEY_TEMPORAL_NUM];
96 unsigned ENVIRONMENTAL[CVSS_KEY_ENVIRONMENTAL_NUM];
97 unsigned ANY[CVSSMAX(CVSSMAX(CVSS_KEY_BASE_NUM, CVSS_KEY_TEMPORAL_NUM), CVSS_KEY_ENVIRONMENTAL_NUM)];
98 } metrics;
99 };
100
101 struct cvss_impact *cvss_impact_new_from_xml(xmlTextReaderPtr reader);
102 bool cvss_impact_export(const struct cvss_impact *imp, xmlTextWriterPtr writer);
103 struct cvss_metrics *cvss_metrics_new_from_xml(xmlTextReaderPtr reader);
104 bool cvss_metrics_export(const struct cvss_metrics *m, xmlTextWriterPtr writer);
105
106 OSCAP_HIDDEN_END;
107
108 #endif