コード例 #1
0
 /**
  * @override
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $verbose = OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity();
     $phar = $input->getArgument('phar');
     if ($verbose) {
         $output->writeln('Verifying the Phar...');
     }
     if (false === is_file($phar)) {
         $output->writeln(sprintf('<error>The path "%s" is not a file or does not exist.</error>', $phar));
         return 1;
     }
     $signature = null;
     $verified = false;
     try {
         if (!$input->getOption('no-extension') && extension_loaded('phar')) {
             $phar = new Phar($phar);
             $verified = true;
             $signature = $phar->getSignature();
         } else {
             $phar = new Signature($phar);
             $verified = $phar->verify();
             $signature = $phar->get();
         }
     } catch (Exception $exception) {
     }
     if ($verified) {
         $output->writeln('<info>The Phar passed verification.</info>');
         if ($verbose) {
             $output->writeln($signature['hash_type'] . ' Signature:');
             $output->writeln($signature['hash']);
         }
         return 1;
     }
     $output->writeln('<error>The Phar failed verification.</error>');
     if ($verbose && isset($exception)) {
         throw $exception;
     }
     return 0;
 }
コード例 #2
0
ファイル: SignatureTest.php プロジェクト: ajbm6/box2-lib
 /**
  * @dataProvider getPhars
  */
 public function testVerify($path)
 {
     $sig = new Signature($path);
     $this->assertTrue($sig->verify());
 }
コード例 #3
0
ファイル: Box.php プロジェクト: ajbm6/box2-lib
 /**
  * Returns the signature of the phar.
  *
  * This method does not use the extension to extract the phar's signature.
  *
  * @param string  $path The phar file path.
  *
  * @return array The signature.
  */
 public static function getSignature($path)
 {
     return Signature::create($path)->get();
 }