From c9bf0c8683fd72a56d5b990692cf5e1d6987cf67 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 9 Apr 2020 10:29:41 -0400 Subject: [PATCH] Allowing empty secrets to be set --- .../FrameworkBundle/Command/SecretsSetCommand.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsSetCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsSetCommand.php index 5cca8d7011fa..91e0031299c3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsSetCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsSetCommand.php @@ -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)) { @@ -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());