Beispiel #1
0
 /**
  * Sets vulnerabilities of this context.
  * @param array $vulnerabilities
  * @return $this
  * @throws \InvalidArgumentException
  */
 public function setVulnerabilities($vulnerabilities = [])
 {
     // Clear current vulnerabilities
     $this->vulnerabilities = [];
     if (!is_array($vulnerabilities)) {
         $vulnerabilities = (array) $vulnerabilities;
     }
     foreach ($vulnerabilities as $type => $vulnerability) {
         $this->checkValidType($type);
         $this->vulnerabilities[$type] = $vulnerability;
     }
     $parentVulns = $this->parent ? $this->parent->getVulnerabilities() : [];
     $this->vulnerabilities = ArraysHelper::arrayMergeRecursiveDistinct($parentVulns, $this->vulnerabilities);
     return $this;
 }
Beispiel #2
0
 /**
  * @return array
  */
 public function getVulnerabilities()
 {
     return $this->currentContext->getVulnerabilities() ?: [];
 }