Skip to content

Commit 5b286e8

Browse files
committed
Mark passwords and URIs as #[\SensitiveParameter] (PHP 8.2+)
1 parent 9c3f918 commit 5b286e8

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/Client.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,11 @@ private function setProtocolVersionFromScheme($scheme)
9797
* @param string $password
9898
* @link http://tools.ietf.org/html/rfc1929
9999
*/
100-
private function setAuth($username, $password)
101-
{
100+
private function setAuth(
101+
$username,
102+
#[\SensitiveParameter]
103+
$password
104+
) {
102105
if (strlen($username) > 255 || strlen($password) > 255) {
103106
throw new InvalidArgumentException('Both username and password MUST NOT exceed a length of 255 bytes each');
104107
}

src/Server.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ final class Server
5757
* @param ?ConnectorInterface $connector
5858
* @param null|array|callable $auth
5959
*/
60-
public function __construct(LoopInterface $loop = null, ConnectorInterface $connector = null, $auth = null)
61-
{
60+
public function __construct(
61+
LoopInterface $loop = null,
62+
ConnectorInterface $connector = null,
63+
#[\SensitiveParameter]
64+
$auth = null
65+
) {
6266
if (\is_array($auth)) {
6367
// wrap authentication array in authentication callback
6468
$this->auth = function ($username, $password) use ($auth) {
@@ -215,8 +219,12 @@ public function handleSocks4(ConnectionInterface $stream, StreamReader $reader)
215219
}
216220

217221
/** @internal */
218-
public function handleSocks5(ConnectionInterface $stream, $auth, StreamReader $reader)
219-
{
222+
public function handleSocks5(
223+
ConnectionInterface $stream,
224+
#[\SensitiveParameter]
225+
$auth,
226+
StreamReader $reader
227+
) {
220228
$remote = $stream->getRemoteAddress();
221229
if ($remote !== null) {
222230
// remove transport scheme and prefix socks5:// instead

0 commit comments

Comments
 (0)