Ejemplo n.º 1
0
 protected function buildAllConditionsForm()
 {
     $allConditionsSet = new ConditionSet();
     $conditionNames = ConditionFactory::instance()->getAllConditionNames();
     foreach ($conditionNames as $name) {
         $conditionClass = 'VulnModule\\Config\\Condition\\' . $name;
         if (class_exists($conditionClass)) {
             $condition = new $conditionClass();
         } else {
             $condition = new Condition();
         }
         if (!$condition::IS_ACTIVE) {
             continue;
         }
         $allConditionsSet->addCondition($condition);
     }
     $vulnBuilder = $this->getFormFactory()->createBuilder('form', ['__ALL_CONDITIONS__' => $allConditionsSet])->add('__ALL_CONDITIONS__', 'condition_set');
     return $vulnBuilder->getForm();
 }
Ejemplo n.º 2
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;
 }
 public function hasConditions()
 {
     return $this->conditions->count() > 0;
 }