diff --git a/src/ProcessManager.php b/src/ProcessManager.php index f7d0930..d9358f5 100644 --- a/src/ProcessManager.php +++ b/src/ProcessManager.php @@ -260,7 +260,7 @@ public static function obscure(string $secret): string throw new InvalidArgumentException('Cannot obscure an empty secret.'); } - $process = new Process([self::getBin(), 'obscure', $secret]); + $process = new Process([self::getBin(), 'obscure', '--', $secret]); $process->setTimeout(3); $process->mustRun(); diff --git a/tests/Unit/EdgeCasesTest.php b/tests/Unit/EdgeCasesTest.php index 00a9cd1..04e7c1a 100644 --- a/tests/Unit/EdgeCasesTest.php +++ b/tests/Unit/EdgeCasesTest.php @@ -169,6 +169,14 @@ public function format_bytes_edge_cases(): void $this->assertEquals('1 MiB', StatsParser::formatBytes(1048576)); } + #[Test] + public function obscure_with_hyphen(): void + { + $obscured = \Verseles\Flyclone\ProcessManager::obscure('-my-password'); + $this->assertNotEmpty($obscured); + $this->assertStringNotContainsString('-my-password', $obscured); + } + #[Test] public function deeply_nested_directory_structure(): void {