/** * @param $name * @param int $flags * @return null|Vulnerability */ public function getComputedVulnerability($name, $flags = 0) { if (!is_string($name)) { throw new \InvalidArgumentException("Vulnerability name must be a string. Provided: '{$name}'"); } $computeOnlyRoot = (bool) ($flags & self::COMPUTE_ONLY_ROOT); if ($computeOnlyRoot && $this->getParent()) { return $this->getParent()->getComputedVulnerability($name, $flags); } if ($this->cachedVulnerabilities->hasOwnVulnerability($name)) { return $this->cachedVulnerabilities->get($name); } if ($this->vulnerabilitySet->hasOwnVulnerability($name)) { $vuln = $this->vulnerabilitySet->get($name); } else { $parent = $this->getParent(); if ($parent) { $vuln = $this->getParent()->getComputedVulnerability($name, $flags); } else { if ($this->host) { $vuln = $this->host->getParentVulnerability($name, null, null, $computeOnlyRoot); if ($vuln === null) { $vuln = VulnerabilityFactory::instance()->create($name, false); } } else { $vuln = VulnerabilityFactory::instance()->create($name, false); } } } if ($vuln) { if (!$vuln->isTargetedAt($this->targets)) { $this->cachedVulnerabilities->set(false, $name); $vuln = false; } else { $this->cachedVulnerabilities->set($vuln); } } else { $this->cachedVulnerabilities->set(false, $name); $vuln = false; } return $vuln; }