Open SCAP Library
cvss_score.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2009 Red Hat Inc., Durham, North Carolina.
3  * All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors:
20  * Tomas Heinrich <theinric@redhat.com>
21  * Peter Vrabec <pvrabec@redhat.com>
22  * Brandon Dixon <Brandon.Dixon@g2-inc.com>
23  * Lukas Kuklinek <lkuklinek@redhat.com>
24  */
35 #ifndef _CVSSCALC_H_
36 #define _CVSSCALC_H_
37 
38 #include <stdbool.h>
39 #include <time.h>
40 #include <stdio.h>
41 
42 
44 const char *cvss_model_supported(void);
45 
48  CVSS_NONE = 0x0000,
49  CVSS_BASE = 0x0100,
50  CVSS_TEMPORAL = 0x0200,
51  CVSS_ENVIRONMENTAL = 0x0300,
52 };
53 
56  CVSS_AV_NOT_SET,
57  CVSS_AV_LOCAL,
58  CVSS_AV_ADJACENT_NETWORK,
59  CVSS_AV_NETWORK,
60  CVSS_AV_END_
61 };
62 
65  CVSS_AC_NOT_SET,
66  CVSS_AC_HIGH,
67  CVSS_AC_MEDIUM,
68  CVSS_AC_LOW,
69  CVSS_AC_END_
70 };
71 
74  CVSS_AU_NOT_SET,
75  CVSS_AU_MULTIPLE,
76  CVSS_AU_SINGLE,
77  CVSS_AU_NONE,
78  CVSS_AU_END_
79 };
80 
83  CVSS_IMP_NOT_SET,
84  CVSS_IMP_NONE,
85  CVSS_IMP_PARTIAL,
86  CVSS_IMP_COMPLETE,
87  CVSS_IMP_END_
88 };
89 
92  CVSS_E_NOT_DEFINED,
93  CVSS_E_UNPROVEN,
94  CVSS_E_PROOF_OF_CONCEPT,
95  CVSS_E_FUNCTIONAL,
96  CVSS_E_HIGH,
97  CVSS_E_END_
98 };
99 
102  CVSS_RL_NOT_DEFINED,
103  CVSS_RL_OFFICIAL_FIX,
104  CVSS_RL_TEMPORARY_FIX,
105  CVSS_RL_WORKAROUND,
106  CVSS_RL_UNAVAILABLE,
107  CVSS_RL_END_
108 };
109 
112  CVSS_RC_NOT_DEFINED,
113  CVSS_RC_UNCONFIRMED,
114  CVSS_RC_UNCORROBORATED,
115  CVSS_RC_CONFIRMED,
116  CVSS_RC_END_
117 };
118 
121  CVSS_CDP_NOT_DEFINED,
122  CVSS_CDP_NONE,
123  CVSS_CDP_LOW,
124  CVSS_CDP_LOW_MEDIUM,
125  CVSS_CDP_MEDIUM_HIGH,
126  CVSS_CDP_HIGH,
127  CVSS_CDP_END_
128 };
129 
132  CVSS_TD_NOT_DEFINED,
133  CVSS_TD_NONE,
134  CVSS_TD_LOW,
135  CVSS_TD_MEDIUM,
136  CVSS_TD_HIGH,
137  CVSS_TD_END_
138 };
139 
142  CVSS_REQ_NOT_DEFINED,
143  CVSS_REQ_LOW,
144  CVSS_REQ_MEDIUM,
145  CVSS_REQ_HIGH,
146  CVSS_REQ_END_
147 };
148 
155 struct cvss_impact;
156 
163 struct cvss_metrics;
164 
166 float cvss_round(float x);
167 
169 struct cvss_impact *cvss_impact_new(void);
171 struct cvss_impact *cvss_impact_new_from_vector(const char *cvss_vector);
173 struct cvss_impact *cvss_impact_clone(const struct cvss_impact* impact);
175 //struct cvss_impact *cvss_impact_new_parse(const char *filename);
177 void cvss_impact_free(struct cvss_impact* impact);
184 void cvss_impact_describe(const struct cvss_impact *impact, FILE *f);
185 
187 struct cvss_metrics *cvss_impact_get_base_metrics(const struct cvss_impact* impact);
189 struct cvss_metrics *cvss_impact_get_temporal_metrics(const struct cvss_impact* impact);
194 bool cvss_impact_set_metrics(struct cvss_impact* impact, struct cvss_metrics *metrics);
196 char *cvss_impact_to_vector(const struct cvss_impact* impact);
197 
219 float cvss_impact_base_exploitability_subscore(const struct cvss_impact* impact);
220 
229 float cvss_impact_base_impact_subscore(const struct cvss_impact* impact);
230 
243 float cvss_impact_base_score(const struct cvss_impact* impact);
244 
258 float cvss_impact_temporal_multiplier(const struct cvss_impact* impact);
259 
269 float cvss_impact_temporal_score(const struct cvss_impact* impact);
270 
279 float cvss_impact_base_adjusted_impact_subscore(const struct cvss_impact* impact);
280 
288 float cvss_impact_adjusted_base_score(const struct cvss_impact* impact);
289 
297 float cvss_impact_adjusted_temporal_score(const struct cvss_impact* impact);
298 
310 float cvss_impact_environmental_score(const struct cvss_impact* impact);
311 
314 
315 struct cvss_metrics *cvss_metrics_new(enum cvss_category category);
317 struct cvss_metrics *cvss_metrics_clone(const struct cvss_metrics* metrics);
319 void cvss_metrics_free(struct cvss_metrics* metrics);
321 enum cvss_category cvss_metrics_get_category(const struct cvss_metrics* metrics);
323 const char *cvss_metrics_get_source(const struct cvss_metrics* metrics);
325 bool cvss_metrics_set_source(struct cvss_metrics* metrics, const char *new_source);
327 const char *cvss_metrics_get_generated_on_datetime(const struct cvss_metrics* metrics);
329 bool cvss_metrics_set_generated_on_datetime(struct cvss_metrics* metrics, const char *new_datetime);
331 const char *cvss_metrics_get_upgraded_from_version(const struct cvss_metrics* metrics);
333 bool cvss_metrics_set_upgraded_from_version(struct cvss_metrics* metrics, const char *new_upgraded_from_version);
335 float cvss_metrics_get_score(const struct cvss_metrics* metrics);
337 bool cvss_metrics_set_score(struct cvss_metrics* metrics, float score);
342 bool cvss_metrics_is_valid(const struct cvss_metrics* metrics);
343 
354 
382 
411 
412 
416 #endif // _CVSSCALC_H_