73 #define AV_NETWORK 1.0 74 #define AV_ADJACENT_NETWORK 0.646 75 #define AV_LOCAL 0.395 79 #define AC_MEDIUM 0.61 83 #define Au_MULTIPLE_INSTANCES 0.45 84 #define Au_SINGLE_INSTANCE 0.56 89 #define C_PARTIAL 0.275 90 #define C_COMPLETE 0.660 94 #define I_PARTIAL 0.275 95 #define I_COMPLETE 0.660 99 #define A_PARTIAL 0.275 100 #define A_COMPLETE 0.660 128 static const struct impact_item impact_map[][3] = {
174 if (g_strcmp0 (str,
"A") == 0)
176 else if (g_strcmp0 (str,
"I") == 0)
178 else if (g_strcmp0 (str,
"C") == 0)
180 else if (g_strcmp0 (str,
"Au") == 0)
182 else if (g_strcmp0 (str,
"AU") == 0)
184 else if (g_strcmp0 (str,
"AV") == 0)
186 else if (g_strcmp0 (str,
"AC") == 0)
203 get_impact_subscore (
const struct cvss *
cvss)
220 get_exploitability_subscore (
const struct cvss *
cvss)
236 set_impact_from_str (
const char *value,
enum base_metrics metric,
241 for (i = 0; i < 3; i++)
245 impact = &impact_map[metric][i];
247 if (g_strcmp0 (impact->
name, value) == 0)
293 __get_cvss_score (
struct cvss *
cvss)
295 double impact = 1.176;
297 double exploitability_sub;
299 impact_sub = get_impact_subscore (
cvss);
300 exploitability_sub = get_exploitability_subscore (
cvss);
302 if (impact_sub < 0.1)
305 return (((0.6 * impact_sub) + (0.4 * exploitability_sub) - 1.5) * impact)
322 memset(&
cvss, 0x00,
sizeof(
struct cvss));
324 if (cvss_str == NULL)
327 base_str =
base_metrics = g_strdup_printf (
"%s/", cvss_str);
332 char *metric_name = token2;
339 if (metric_name == NULL)
342 metric_value = strtok (NULL,
":");
344 if (metric_value == NULL)
347 rc = toenum (metric_name, &mval);
351 if (set_impact_from_str (metric_value, mval, &
cvss))
358 return __get_cvss_score (&
cvss);
#define Au_SINGLE_INSTANCE
#define AV_ADJACENT_NETWORK
double get_cvss_score_from_base_metrics(const char *cvss_str)
Calculate CVSS Score.
#define Au_MULTIPLE_INSTANCES
Describe a CVSS impact element.