コード例 #1
0
 /**
  * @param $argument
  * @param $option
  */
 private function hardWork($argument, $option)
 {
     $this->line('path: <info>' . $argument['path'] . '</info>.\\nCheck composer.lock files...');
     $lockFiles = $this->findFilesComposerLock($argument['path']);
     $this->line('Find <info>' . count($lockFiles) . '</info> composer.lock files.');
     $this->tableVulnerabilities = [];
     $tuttoOk = true;
     $numLock = 0;
     //whitelist
     $whitelist = $this->adjustWhiteList($option['whitelist']);
     foreach ($lockFiles as $fileLock) {
         $this->line("Analizing <info>" . ($numLock + 1) . "</info> di <info>" . count($lockFiles) . "</info>: {$fileLock} ...");
         $this->tableVulnerabilities[] = ['name' => $fileLock, 'version' => '', 'advisories' => '', 'isOk' => ''];
         $sensiolab = new SensiolabHelper($this->guzzle, $this);
         $response = $sensiolab->getSensiolabVulnerabilties($fileLock);
         if ($response == null | !is_array($response)) {
             $this->error("Errore Response not vaild or null.");
             continue;
         }
         if (count($response) > 0) {
             $this->error("Trovate " . count($response) . " vulnerabilita' in {$fileLock}");
         }
         foreach ($response as $key => $vulnerability) {
             $tuttoOk = in_array(rtrim(str_replace('\\', '/', $fileLock), 'composer.lock'), $whitelist);
             foreach ($sensiolab->parseVulnerability($key, $vulnerability) as $vul) {
                 $this->tableVulnerabilities[] = array_merge($vul, array('isOk' => $tuttoOk));
             }
         }
         $numLock++;
     }
     $this->notifyResult($option['mail'], $tuttoOk);
 }
コード例 #2
0
 /**
  * @param $argument
  * @param $option
  */
 private function hardWork($argument, $option)
 {
     $this->line('path: <info>' . $argument['path'] . '</info>.\\nCheck composer.lock files...');
     $lockFiles = $this->findFilesComposerLock($argument['path']);
     $this->line('Find <info>' . count($lockFiles) . '</info> composer.lock files.');
     $this->tableVulnerabilities = [];
     $tuttoOk = true;
     $numLock = 0;
     foreach ($lockFiles as $fileLock) {
         $this->line("Analizing <info>" . ($numLock + 1) . "</info> di <info>" . count($lockFiles) . "</info>: {$fileLock} ...");
         $this->tableVulnerabilities[] = ['name' => $fileLock, 'version' => '', 'advisories' => ''];
         $sensiolab = new SensiolabHelper($this->guzzle, $this);
         $response = $sensiolab->getSensiolabVulnerabilties($fileLock);
         if ($response == null | !is_array($response)) {
             $this->error("Errore Response not vaild or null.");
             continue;
         }
         if (count($response) > 0) {
             $this->error("Trovate " . count($response) . " vulnerabilita' in {$fileLock}");
         }
         foreach ($response as $key => $vulnerability) {
             $tuttoOk = false;
             foreach ($sensiolab->parseVulnerability($key, $vulnerability) as $vul) {
                 $this->tableVulnerabilities[] = $vul;
             }
         }
         $numLock++;
     }
     $esito = Config::get('composer-security-check.mailSubjectSuccess');
     if (!$tuttoOk) {
         $esito = Config::get('composer-security-check.mailSubjetcAlarm');
         $this->error($esito);
     } else {
         $this->line($esito);
     }
     //print to console
     $this->table($this->headersTableConsole, $this->tableVulnerabilities);
     //send email
     $mail = $option['mail'];
     if ($mail != '') {
         $email = new MailHelper($this);
         $email->sendEmail($tuttoOk, $mail, $this->tableVulnerabilities);
     }
 }