Esempio n. 1
0
 protected function buildVulnerabilityElementFromArray($data, $conditional = false)
 {
     $vulnerabilities = $this->buildVulnerabilitySetFromArray($data['vuln_list']);
     if ($conditional) {
         $vulnElement = new ConditionalVulnerableElement($vulnerabilities);
         if (is_array($data['conditions'])) {
             $factory = ConditionFactory::instance();
             $conditionSet = new ConditionSet();
             foreach ($data['conditions'] as $name => $conditionData) {
                 $condition = $factory->create($name);
                 $condition->fillFromArray($conditionData);
                 $conditionSet->addCondition($condition);
             }
             $vulnElement->setConditions($conditionSet);
         }
     } else {
         $vulnElement = new VulnerableElement($vulnerabilities);
     }
     if ($data['name']) {
         $vulnElement->setName($data['name']);
     }
     if (is_array($data['children'])) {
         foreach ($data['children'] as $childData) {
             $child = $this->buildVulnerabilityElementFromArray($childData, true);
             $vulnElement->addChild($child);
         }
     }
     return $vulnElement;
 }