Skip to content

Commit 633e88a

Browse files
lucasgranbergLucas Granberg
andauthored
cast keyset generation console arguments to int and remove dangerous defaults (#339)
Co-authored-by: Lucas Granberg <[email protected]>
1 parent c230ee5 commit 633e88a

6 files changed

+8
-33
lines changed

src/Component/Console/EcKeysetGeneratorCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ protected function configure(): void
2828

2929
protected function execute(InputInterface $input, OutputInterface $output): int
3030
{
31-
$quantity = $input->getArgument('quantity');
32-
if (! is_int($quantity)) {
33-
$quantity = 1;
34-
}
31+
$quantity = (int)$input->getArgument('quantity');
3532
if ($quantity < 1) {
3633
throw new InvalidArgumentException('Invalid quantity');
3734
}

src/Component/Console/OctKeyGeneratorCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ protected function configure(): void
2525

2626
protected function execute(InputInterface $input, OutputInterface $output): int
2727
{
28-
$size = $input->getArgument('size');
29-
if (! is_int($size)) {
30-
$size = 1;
31-
}
28+
$size = (int)$input->getArgument('size');
3229
if ($size < 1) {
3330
throw new InvalidArgumentException('Invalid size');
3431
}

src/Component/Console/OctKeysetGeneratorCommand.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,8 @@ protected function configure(): void
2727

2828
protected function execute(InputInterface $input, OutputInterface $output): int
2929
{
30-
$quantity = $input->getArgument('quantity');
31-
if (! is_int($quantity)) {
32-
$quantity = 1;
33-
}
34-
35-
$size = $input->getArgument('size');
36-
if (! is_int($size)) {
37-
$size = 1;
38-
}
30+
$quantity = (int)$input->getArgument('quantity');
31+
$size = (int)$input->getArgument('size');
3932
if ($quantity < 1) {
4033
throw new InvalidArgumentException('Invalid quantity');
4134
}

src/Component/Console/OkpKeysetGeneratorCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ protected function configure(): void
2828

2929
protected function execute(InputInterface $input, OutputInterface $output): int
3030
{
31-
$quantity = $input->getArgument('quantity');
32-
if (! is_int($quantity)) {
33-
$quantity = 1;
34-
}
31+
$quantity = (int)$input->getArgument('quantity');
3532
$curve = $input->getArgument('curve');
3633
if ($quantity < 1) {
3734
throw new InvalidArgumentException('Invalid quantity');

src/Component/Console/RsaKeyGeneratorCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ protected function configure(): void
2525

2626
protected function execute(InputInterface $input, OutputInterface $output): int
2727
{
28-
$size = $input->getArgument('size');
29-
if (! is_int($size)) {
30-
$size = 1;
31-
}
28+
$size = (int)$input->getArgument('size');
3229
$args = $this->getOptions($input);
3330
if ($size < 1) {
3431
throw new InvalidArgumentException('Invalid size');

src/Component/Console/RsaKeysetGeneratorCommand.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,8 @@ protected function configure(): void
2727

2828
protected function execute(InputInterface $input, OutputInterface $output): int
2929
{
30-
$quantity = $input->getArgument('quantity');
31-
if (! is_int($quantity)) {
32-
$quantity = 1;
33-
}
34-
$size = $input->getArgument('size');
35-
if (! is_int($size)) {
36-
$size = 1;
37-
}
30+
$quantity = (int)$input->getArgument('quantity');
31+
$size = (int)$input->getArgument('size');
3832
if ($quantity < 1) {
3933
throw new InvalidArgumentException('Invalid quantity');
4034
}

0 commit comments

Comments
 (0)