lockFilePath = $lockFilePath; $this->securityChecker = new SecurityChecker(); } public function check() { try { if (!file_exists($this->lockFilePath) || !is_file($this->lockFilePath)) { return new Failure(sprintf( 'Cannot find composer lock file at %s', $this->lockFilePath ), $this->lockFilePath); } elseif (!is_readable($this->lockFilePath)) { return new Failure(sprintf( 'Cannot open composer lock file at %s', $this->lockFilePath ), $this->lockFilePath); } $advisories = $this->securityChecker->check($this->lockFilePath, 'json'); if (is_string($advisories)) { $advisories = @json_decode($advisories); } if (!is_array($advisories)) { return new Warning('Could not parse response from security advisory service.'); } if (!empty($advisories)) { return new Failure(sprintf( 'Found security advisories for %u composer package(s)', count($advisories) ), $advisories); } } catch (\Exception $e) { return new Warning($e->getMessage()); } return new Success(sprintf( 'There are currently no security advisories for packages specified in %s', $this->lockFilePath )); } }