Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to skip signature verification #356

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file modified phive 100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion src/commands/install/InstallCommand.php
Expand Up @@ -51,7 +51,7 @@ protected function installRequestedPhar(RequestedPhar $requestedPhar, Directory
$release = $this->resolveToRelease($requestedPhar);
$destination = $this->getDestination($release->getUrl()->getPharName(), $requestedPhar, $targetDirectory);

$this->installService->execute($release, $requestedPhar, $destination, !$this->getConfig()->doNotAddToPhiveXml());
$this->installService->execute($release, $requestedPhar, $destination, !$this->getConfig()->doNotAddToPhiveXml(), $this->getConfig()->skipSignatureVerification());
}

protected function getConfig(): InstallCommandConfig {
Expand Down
4 changes: 4 additions & 0 deletions src/commands/install/InstallCommandConfig.php
Expand Up @@ -83,6 +83,10 @@ public function forceAcceptUnsignedPhars(): bool {
return $this->cliOptions->hasOption('force-accept-unsigned');
}

public function skipSignatureVerification(): bool {
return $this->cliOptions->hasOption('skip-signature-verification');
}

/**
* @throws ConfiguredPharException
*
Expand Down
17 changes: 10 additions & 7 deletions src/commands/install/InstallContext.php
Expand Up @@ -20,19 +20,22 @@ public function requiresValue(string $option): bool {

protected function getKnownOptions(): array {
return [
'target' => 't',
'copy' => 'c',
'global' => 'g',
'temporary' => false,
'trust-gpg-keys' => false,
'force-accept-unsigned' => false
'target' => 't',
'copy' => 'c',
'global' => 'g',
'temporary' => false,
'trust-gpg-keys' => false,
'force-accept-unsigned' => false,
'skip-signature-verification' => false,
];
}

protected function getConflictingOptions(): array {
return [
['global' => 'temporary'],
['global' => 'target']
['global' => 'target'],
['skip-signature-verification' => 'trust-gpg-keys'],
['skip-signature-verification' => 'force-accept-unsigned'],
];
}
}
4 changes: 2 additions & 2 deletions src/services/phar/InstallService.php
Expand Up @@ -49,10 +49,10 @@ public function __construct(
$this->compatibilityService = $compatibilityChecker;
}

public function execute(SupportedRelease $release, RequestedPhar $requestedPhar, Filename $destination, bool $updatePhiveXml): void {
public function execute(SupportedRelease $release, RequestedPhar $requestedPhar, Filename $destination, bool $updatePhiveXml, bool $skipSignatureVerification = false): void {
$versionConstraint = $requestedPhar->getVersionConstraint();
$makeCopy = $requestedPhar->makeCopy();
$phar = $this->pharService->getPharFromRelease($release);
$phar = $this->pharService->getPharFromRelease($release, $skipSignatureVerification);

if (!$this->compatibilityService->canRun($phar)) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/services/phar/PharDownloader.php
Expand Up @@ -42,12 +42,12 @@ public function __construct(
* @throws DownloadFailedException
* @throws InvalidHashException
*/
public function download(SupportedRelease $release): Phar {
public function download(SupportedRelease $release, bool $skipSignatureVerification = false): Phar {
$pharFile = $this->downloadFile($release->getUrl());

$fingerprint = null;

if ($release->hasSignatureUrl()) {
if (!$skipSignatureVerification && $release->hasSignatureUrl()) {
$fingerprint = $this->verifySignature(
$release,
$pharFile,
Expand Down
4 changes: 2 additions & 2 deletions src/services/phar/PharService.php
Expand Up @@ -22,13 +22,13 @@ public function __construct(PharRegistry $registry, PharDownloader $downloader)
$this->downloader = $downloader;
}

public function getPharFromRelease(SupportedRelease $release): Phar {
public function getPharFromRelease(SupportedRelease $release, bool $skipSignatureVerification = false): Phar {
if ($this->registry->hasPhar($release->getName(), $release->getVersion())) {
return $this->registry->getPhar($release->getName(), $release->getVersion());
}

return $this->registry->addPhar(
$this->downloader->download($release)
$this->downloader->download($release, $skipSignatureVerification)
);
}
}