Skip to content

Commit

Permalink
Merge pull request #38 from SimonFrings/sensitive_parameter
Browse files Browse the repository at this point in the history
Mark passwords and URIs as `#[\SensitiveParameter]` (PHP 8.2+)
  • Loading branch information
clue authored Sep 2, 2022
2 parents d60a5d8 + 869a401 commit a33a624
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/SshProcessConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ class SshProcessConnector implements ConnectorInterface
* @param ?LoopInterface $loop
* @throws \InvalidArgumentException
*/
public function __construct($uri, LoopInterface $loop = null)
{
public function __construct(
#[\SensitiveParameter]
$uri,
LoopInterface $loop = null
) {
// URI must use optional ssh:// scheme, must contain host and neither pass nor target must start with dash
$parts = \parse_url((\strpos($uri, '://') === false ? 'ssh://' : '') . $uri);
$pass = isset($parts['pass']) ? \rawurldecode($parts['pass']) : null;
Expand Down
7 changes: 5 additions & 2 deletions src/SshSocksConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ class SshSocksConnector implements ConnectorInterface
* @param ?LoopInterface $loop
* @throws \InvalidArgumentException
*/
public function __construct($uri, LoopInterface $loop = null)
{
public function __construct(
#[\SensitiveParameter]
$uri,
LoopInterface $loop = null
) {
// URI must use optional ssh:// scheme, must contain host and neither pass nor target must start with dash
$parts = \parse_url((\strpos($uri, '://') === false ? 'ssh://' : '') . $uri);
$pass = isset($parts['pass']) ? \rawurldecode($parts['pass']) : null;
Expand Down

0 comments on commit a33a624

Please sign in to comment.