Skip to content

Commit

Permalink
2.0.3
Browse files Browse the repository at this point in the history
Cleaner Code push by @faynwol
  • Loading branch information
security-database committed Feb 10, 2017
1 parent 1973350 commit b78cc19
Showing 1 changed file with 11 additions and 31 deletions.
42 changes: 11 additions & 31 deletions src/Cvss3.php
Expand Up @@ -580,36 +580,17 @@ private function constructWeights()

//Modified
foreach ($this->vector_input_array as $metric => $value) {
if ($metric == "MPR" && isset(self::$metrics_level_modified[$metric][$value])) {

if (isset($this->vector_input_array["MS"]) === false || $this->vector_input_array["MS"] == "X") {
if ($this->vector_input_array["S"] == "C" && ($value == "L" || $value == "H")) {
$this->weight[$metric] = (float)self::$metrics_level_modified[$metric][$value]["Scope"];
} elseif ($this->vector_input_array["S"] == "U" && ($value == "L" || $value == "H")) {
$this->weight[$metric] = (float)self::$metrics_level_modified[$metric][$value]["Default"];
} elseif ($value != 'X') {
$this->weight[$metric] = (float)self::$metrics_level_modified[$metric][$value];
} else {
$this->weight[$metric] = (float)$this->weight[substr($metric, 1)];
}
} else {
if ((isset($this->vector_input_array["MS"]) === false
|| $this->vector_input_array["MS"] == "X"
|| $this->vector_input_array["MS"] == "C")
&& ($value == "L" || $value == "H")
) {
$this->weight[$metric] = (float)self::$metrics_level_modified[$metric][$value]["Scope"];
} elseif ((isset($this->vector_input_array["MS"]) === false
|| $this->vector_input_array["MS"] == "X"
|| $this->vector_input_array["MS"] == "U")
&& ($value == "L" || $value == "H")
) {
$this->weight[$metric] = (float)self::$metrics_level_modified[$metric][$value]["Default"];
} elseif ($value != 'X') {
$this->weight[$metric] = (float)self::$metrics_level_modified[$metric][$value];
} else {
$this->weight[$metric] = (float)$this->weight[substr($metric, 1)];
}
if ($metric == "MPR" && ($value == "L" || $value == "H")) {
if (
(isset($this->vector_input_array["MS"]) == false || $this->vector_input_array["MS"] == "X")
&& $this->vector_input_array['S'] == 'C'
|| (isset($this->vector_input_array["MS"]) == true && $this->vector_input_array["MS"] == "C")) {
$this->weight[$metric] = (float)self::$metrics_level_modified[$metric][$value]["Scope"];
} elseif (
(isset($this->vector_input_array["MS"]) == false || $this->vector_input_array["MS"] == "X")
&& $this->vector_input_array['S'] == 'U'
|| (isset($this->vector_input_array["MS"]) == true && $this->vector_input_array["MS"] == "U")) {
$this->weight[$metric] = (float)self::$metrics_level_modified[$metric][$value]["Default"];
}
} else {
if (isset(self::$metrics_level_modified[$metric][$value])) {
Expand All @@ -622,7 +603,6 @@ private function constructWeights()
}
}


foreach (self::$metrics_level_mandatory as $metric => $level) {
if (isset($this->weight[$metric]) === false) {
throw new Exception("ERROR in mandatory Scores", __LINE__);
Expand Down

0 comments on commit b78cc19

Please sign in to comment.