Skip to content
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

Allowing empty secrets to be set #36400

Merged
merged 1 commit into from Apr 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look above at the possible ways to set $value, a null value was only possible when using the askHidden() interactive prompt. So now, it should not be possible to have null at this point.

$io->warning('No value provided, aborting.');

return 1;
}

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

Expand Down