Skip to content

Commit

Permalink
refactor(HasSudoPassword): improve escaping of sudo password
Browse files Browse the repository at this point in the history
- Return sudo password as a string
- Use EscapeArg::escape() to escape sudo password
  • Loading branch information
guanguans committed Jul 14, 2023
1 parent 7bab1d4 commit aa10e5c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Concerns/HasSudoPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function setSudoPassword(?string $sudoPassword): self

protected function getEscapedSudoPassword(): string
{
return EscapeArg::escape($this->sudoPassword);
return EscapeArg::escape((string) $this->sudoPassword);
}

protected function shouldApplySudoPassword(): bool
Expand Down
6 changes: 3 additions & 3 deletions tests/Concerns/WithRunableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ protected function shouldApplySudoPassword(): bool
}
};
$fatalErrorMessages = [
'sudo',
'password',
// 'sudo',
// 'password',
];

$this->expectException(ProcessFailedException::class);
foreach ($fatalErrorMessages as $fatalErrorMessage) {
// $this->expectExceptionMessage($fatalErrorMessage);
$this->expectExceptionMessage($fatalErrorMessage);
}

$soar->setSudoPassword('foo')->setQuery('select bar;')->run();
Expand Down

0 comments on commit aa10e5c

Please sign in to comment.