Skip to content

[FrameworkBundle] Fixes getting a type error when the secret you are trying to reveal could not be decrypted #60774

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if (!\array_key_exists($name, $secrets)) {
$io->error(\sprintf('The secret "%s" does not exist.', $name));

return self::INVALID;
} elseif (null === $secrets[$name]) {
$io->error(\sprintf('The secret "%s" could not be decrypted.', $name));

return self::INVALID;
}

Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Secrets/AbstractVault.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ abstract public function reveal(string $name): ?string;

abstract public function remove(string $name): bool;

/**
* @return array<string, string|null>
*/
abstract public function list(bool $reveal = false): array;

protected function validateName(string $name): void
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public function list(bool $reveal = false): array

foreach ($_ENV as $k => $v) {
if ('' !== ($v ?? '') && preg_match('/^\w+$/D', $k)) {
$secrets[$k] = $reveal ? $v : null;
$secrets[$k] = \is_string($v) && $reveal ? $v : null;
}
}

foreach ($_SERVER as $k => $v) {
if ('' !== ($v ?? '') && preg_match('/^\w+$/D', $k)) {
$secrets[$k] = $reveal ? $v : null;
$secrets[$k] = \is_string($v) && $reveal ? $v : null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ public function testInvalidName()
$this->assertStringContainsString('The secret "undefinedKey" does not exist.', trim($tester->getDisplay(true)));
}

public function testFailedDecrypt()
{
$vault = $this->createMock(AbstractVault::class);
$vault->method('list')->willReturn(['secretKey' => null]);

$command = new SecretsRevealCommand($vault);

$tester = new CommandTester($command);
$this->assertSame(Command::INVALID, $tester->execute(['name' => 'secretKey']));

$this->assertStringContainsString('The secret "secretKey" could not be decrypted.', trim($tester->getDisplay(true)));
}

/**
* @backupGlobals enabled
*/
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy