Skip to content

Commit

Permalink
bug #36400 Allowing empty secrets to be set (weaverryan)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.4 branch.

Discussion
----------

Allowing empty secrets to be set

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | None
| License       | MIT
| Doc PR        | Not needed

Setting secrets to an empty string is a valid value - you can already do this by consuming from an empty file or `stdin` with no input. But it's *not* currently possible to use the interactive prompt to set a secret to an empty string. This fixes that.

Commits
-------

c9bf0c8 Allowing empty secrets to be set
  • Loading branch information
nicolas-grekas committed Apr 10, 2020
2 parents f2d4a29 + c9bf0c8 commit 2dd5fe6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Symfony/Bundle/FrameworkBundle/Command/SecretsSetCommand.php
Expand Up @@ -96,6 +96,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$value = strtr(substr(base64_encode(random_bytes($random)), 0, $random), '+/', '-_');
} elseif (!$file = $input->getArgument('file')) {
$value = $io->askHidden('Please type the secret value');

if (null === $value) {
$io->warning('No value provided: using empty string');
$value = '';
}
} elseif ('-' === $file) {
$value = file_get_contents('php://stdin');
} elseif (is_file($file) && is_readable($file)) {
Expand All @@ -106,12 +111,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
throw new \InvalidArgumentException(sprintf('File is not readable: "%s".', $file));
}

if (null === $value) {
$io->warning('No value provided, aborting.');

return 1;
}

if ($vault->generateKeys()) {
$io->success($vault->getLastMessage());

Expand Down

0 comments on commit 2dd5fe6

Please sign in to comment.