Пример #1
0
 /**
  * @dataProvider invalidFiles
  */
 public function testVerifyCleansUpOnFailure($file)
 {
     $v = new PharUtil_RemotePharVerifier($this->fetch_dir, $this->verified_dir, $this->getPubKey());
     try {
         $v->verify($this->remote_dir . $file);
     } catch (PharUtil_SignatureVerificationException $e) {
         $this->assertFileNotExists($this->verified_dir . '/' . $file);
         $files = glob($this->fetch_dir . '/*');
         $this->assertEquals(0, count($files));
         return;
     }
     $this->fail("PharUtil_SignatureVerificationException was not thrown");
 }
Пример #2
0
    $parser->displayError($exc->getMessage());
}
$options = $result->options;
$args = $result->args;
echo $parser->name . ' ' . $parser->version . PHP_EOL . PHP_EOL;
// validate parameters
if (substr($args['phar'], -5) !== '.phar') {
    $parser->displayError("Input Phar must have .phar extension, {$args['phar']} given.", 2);
}
if ($options['nosign']) {
    $options['public'] = null;
    // no public key
}
if ($options['public']) {
    if (!file_exists($options['public']) || !is_readable($options['public'])) {
        $parser->displayError("Public key in '{$options['public']}' does not exist or is not readable.", 4);
    }
}
if (!$options['temp']) {
    $options['temp'] = sys_get_temp_dir();
}
try {
    echo "Verifying Phar archive: {$args['phar']}..." . PHP_EOL;
    $v = new PharUtil_RemotePharVerifier($options['temp'], $options['temp'], $options['public']);
    $v->verify($args['phar']);
    echo "Phar archive successfully verified." . PHP_EOL;
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . PHP_EOL;
    exit(1);
}
echo PHP_EOL . "All done, exiting." . PHP_EOL;