diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsListCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsListCommand.php index abfe2064f8222..8422d2c91a023 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsListCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsListCommand.php @@ -86,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } foreach ($localSecrets ?? [] as $name => $value) { - if (isset($rows[$name]) && !\in_array($value, ['', false, null], true)) { + if (isset($rows[$name])) { $rows[$name][] = $dump($value); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php b/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php index db4891c34b337..994b31d18be59 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php +++ b/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php @@ -52,9 +52,9 @@ public function reveal(string $name): ?string { $this->lastMessage = null; $this->validateName($name); - $v = \is_string($_SERVER[$name] ?? null) && !str_starts_with($name, 'HTTP_') ? $_SERVER[$name] : ($_ENV[$name] ?? null); + $v = $_ENV[$name] ?? (str_starts_with($name, 'HTTP_') ? null : ($_SERVER[$name] ?? null)); - if (null === $v) { + if ('' === ($v ?? '')) { $this->lastMessage = sprintf('Secret "%s" not found in "%s".', $name, $this->getPrettyPath($this->dotenvFile)); return null; @@ -89,13 +89,13 @@ public function list(bool $reveal = false): array $secrets = []; foreach ($_ENV as $k => $v) { - if (preg_match('/^\w+$/D', $k)) { + if ('' !== ($v ?? '') && preg_match('/^\w+$/D', $k)) { $secrets[$k] = $reveal ? $v : null; } } foreach ($_SERVER as $k => $v) { - if (\is_string($v) && preg_match('/^\w+$/D', $k)) { + if ('' !== ($v ?? '') && preg_match('/^\w+$/D', $k)) { $secrets[$k] = $reveal ? $v : null; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsListCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsListCommandTest.php index 933cafcf7c74c..12d3ab2e8ac28 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsListCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsListCommandTest.php @@ -14,16 +14,22 @@ use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Command\SecretsListCommand; use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault; +use Symfony\Bundle\FrameworkBundle\Secrets\DotenvVault; use Symfony\Component\Console\Tester\CommandTester; class SecretsListCommandTest extends TestCase { + /** + * @backupGlobals enabled + */ public function testExecute() { $vault = $this->createMock(AbstractVault::class); $vault->method('list')->willReturn(['A' => 'a', 'B' => 'b', 'C' => null, 'D' => null, 'E' => null]); - $localVault = $this->createMock(AbstractVault::class); - $localVault->method('list')->willReturn(['A' => '', 'B' => 'A', 'C' => '', 'D' => false, 'E' => null]); + + $_ENV = ['A' => '', 'B' => 'A', 'C' => '', 'D' => false, 'E' => null]; + $localVault = new DotenvVault('/not/a/path'); + $command = new SecretsListCommand($vault, $localVault); $tester = new CommandTester($command); $this->assertSame(0, $tester->execute([])); @@ -37,9 +43,9 @@ public function testExecute() Secret Value Local Value -------- -------- ------------- A "a" - B "b" "A" + B "b" ****** C ****** - D ****** + D ****** ****** E ****** -------- -------- -------------
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: