Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a46c659

Browse filesBrowse files
[FrameworkBundle] Fix secrets:list not displaying local vars
1 parent 5b66f26 commit a46c659
Copy full SHA for a46c659

File tree

Expand file treeCollapse file tree

3 files changed

+15
-9
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+15
-9
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Command/SecretsListCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/SecretsListCommand.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8686
}
8787

8888
foreach ($localSecrets ?? [] as $name => $value) {
89-
if (isset($rows[$name]) && !\in_array($value, ['', false, null], true)) {
89+
if (isset($rows[$name])) {
9090
$rows[$name][] = $dump($value);
9191
}
9292
}

‎src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public function reveal(string $name): ?string
5252
{
5353
$this->lastMessage = null;
5454
$this->validateName($name);
55-
$v = \is_string($_SERVER[$name] ?? null) && !str_starts_with($name, 'HTTP_') ? $_SERVER[$name] : ($_ENV[$name] ?? null);
55+
$v = $_ENV[$name] ?? (str_starts_with($name, 'HTTP_') ? null : ($_SERVER[$name] ?? null));
5656

57-
if (null === $v) {
57+
if ('' === ($v ?? '')) {
5858
$this->lastMessage = sprintf('Secret "%s" not found in "%s".', $name, $this->getPrettyPath($this->dotenvFile));
5959

6060
return null;
@@ -89,13 +89,13 @@ public function list(bool $reveal = false): array
8989
$secrets = [];
9090

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

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

‎src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsListCommandTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsListCommandTest.php
+10-4Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bundle\FrameworkBundle\Command\SecretsListCommand;
1616
use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault;
17+
use Symfony\Bundle\FrameworkBundle\Secrets\DotenvVault;
1718
use Symfony\Component\Console\Tester\CommandTester;
1819

1920
class SecretsListCommandTest extends TestCase
2021
{
22+
/**
23+
* @backupGlobals enabled
24+
*/
2125
public function testExecute()
2226
{
2327
$vault = $this->createMock(AbstractVault::class);
2428
$vault->method('list')->willReturn(['A' => 'a', 'B' => 'b', 'C' => null, 'D' => null, 'E' => null]);
25-
$localVault = $this->createMock(AbstractVault::class);
26-
$localVault->method('list')->willReturn(['A' => '', 'B' => 'A', 'C' => '', 'D' => false, 'E' => null]);
29+
30+
$_ENV = ['A' => '', 'B' => 'A', 'C' => '', 'D' => false, 'E' => null];
31+
$localVault = new DotenvVault('/not/a/path');
32+
2733
$command = new SecretsListCommand($vault, $localVault);
2834
$tester = new CommandTester($command);
2935
$this->assertSame(0, $tester->execute([]));
@@ -37,9 +43,9 @@ public function testExecute()
3743
Secret Value Local Value
3844
-------- -------- -------------
3945
A "a"
40-
B "b" "A"
46+
B "b" ******
4147
C ******
42-
D ******
48+
D ****** ******
4349
E ******
4450
-------- -------- -------------
4551

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.