Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Hide sensitive information with SensitiveParameter attribute #46183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,11 @@
<referencedClass name="UnitEnum"/>
</errorLevel>
</UndefinedDocblockClass>
<UndefinedAttributeClass>
<errorLevel type="suppress">
<!-- These classes have been added in PHP 8.2 -->
<referencedClass name="SensitiveParameter"/>
</errorLevel>
</UndefinedAttributeClass>
</issueHandlers>
</psalm>
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function deleteTokenBySeries(string $series)
/**
* {@inheritdoc}
*/
public function updateToken(string $series, string $tokenValue, \DateTime $lastUsed)
public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTime $lastUsed)
{
$sql = 'UPDATE rememberme_token SET value=:value, lastUsed=:lastUsed WHERE series=:series';
$paramValues = [
Expand Down Expand Up @@ -140,7 +140,7 @@ public function createNewToken(PersistentTokenInterface $token)
/**
* {@inheritdoc}
*/
public function verifyToken(PersistentTokenInterface $token, string $tokenValue): bool
public function verifyToken(PersistentTokenInterface $token, #[\SensitiveParameter] string $tokenValue): bool
{
// Check if the token value matches the current persisted token
if (hash_equals($token->getTokenValue(), $tokenValue)) {
Expand Down Expand Up @@ -177,7 +177,7 @@ public function verifyToken(PersistentTokenInterface $token, string $tokenValue)
/**
* {@inheritdoc}
*/
public function updateExistingToken(PersistentTokenInterface $token, string $tokenValue, \DateTimeInterface $lastUsed): void
public function updateExistingToken(PersistentTokenInterface $token, #[\SensitiveParameter] string $tokenValue, \DateTimeInterface $lastUsed): void
{
if (!$token instanceof PersistentToken) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ protected function getUser(): ?UserInterface
* @param string $id The id used when generating the token
* @param string|null $token The actual token sent with the request that should be validated
*/
protected function isCsrfTokenValid(string $id, ?string $token): bool
protected function isCsrfTokenValid(string $id, #[\SensitiveParameter] ?string $token): bool
{
if (!$this->container->has('security.csrf.token_manager')) {
throw new \LogicException('CSRF protection is not enabled in your application. Enable it with the "csrf_protection" key in "config/packages/framework.yaml".');
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/HttpClient/HttpOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function toArray(): array
/**
* @return $this
*/
public function setAuthBasic(string $user, string $password = ''): static
public function setAuthBasic(string $user, #[\SensitiveParameter] string $password = ''): static
{
$this->options['auth_basic'] = $user;

Expand All @@ -46,7 +46,7 @@ public function setAuthBasic(string $user, string $password = ''): static
/**
* @return $this
*/
public function setAuthBearer(string $token): static
public function setAuthBearer(#[\SensitiveParameter] string $token): static
{
$this->options['auth_bearer'] = $token;

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpKernel/UriSigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class UriSigner
* @param string $secret A secret
* @param string $parameter Query string parameter to use
*/
public function __construct(string $secret, string $parameter = '_hash')
public function __construct(#[\SensitiveParameter] string $secret, string $parameter = '_hash')
{
$this->secret = $secret;
$this->parameter = $parameter;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Ldap/Adapter/ConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ public function isBound(): bool;
* @throws ConnectionTimeoutException When the connection can't be created because of an LDAP_TIMEOUT error
* @throws InvalidCredentialsException When the connection can't be created because of an LDAP_INVALID_CREDENTIALS error
*/
public function bind(string $dn = null, string $password = null);
public function bind(string $dn = null, #[\SensitiveParameter] string $password = null);
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function isBound(): bool
*
* @param string $password WARNING: When the LDAP server allows unauthenticated binds, a blank $password will always be valid
*/
public function bind(string $dn = null, string $password = null)
public function bind(string $dn = null, #[\SensitiveParameter] string $password = null)
{
if (!$this->connection) {
$this->connect();
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Ldap/Ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(AdapterInterface $adapter)
/**
* {@inheritdoc}
*/
public function bind(string $dn = null, string $password = null)
public function bind(string $dn = null, #[\SensitiveParameter] string $password = null)
{
$this->adapter->getConnection()->bind($dn, $password);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Ldap/LdapInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface LdapInterface
*
* @throws ConnectionException if dn / password could not be bound
*/
public function bind(string $dn = null, string $password = null);
public function bind(string $dn = null, #[\SensitiveParameter] string $password = null);

/**
* Queries a ldap server for entries matching the given criteria.
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Ldap/Security/LdapUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class LdapUser implements UserInterface, PasswordAuthenticatedUserInterface, Equ
private array $roles;
private array $extraFields;

public function __construct(Entry $entry, string $username, ?string $password, array $roles = [], array $extraFields = [])
public function __construct(Entry $entry, string $username, #[\SensitiveParameter] ?string $password, array $roles = [], array $extraFields = [])
{
if (!$username) {
throw new \InvalidArgumentException('The username cannot be empty.');
Expand Down Expand Up @@ -97,7 +97,7 @@ public function getExtraFields(): array
return $this->extraFields;
}

public function setPassword(string $password)
public function setPassword(#[\SensitiveParameter] string $password)
{
$this->password = $password;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Ldap/Security/LdapUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class LdapUserProvider implements UserProviderInterface, PasswordUpgraderInterfa
private ?string $passwordAttribute;
private array $extraFields;

public function __construct(LdapInterface $ldap, string $baseDn, string $searchDn = null, string $searchPassword = null, array $defaultRoles = [], string $uidKey = null, string $filter = null, string $passwordAttribute = null, array $extraFields = [])
public function __construct(LdapInterface $ldap, string $baseDn, string $searchDn = null, #[\SensitiveParameter] string $searchPassword = null, array $defaultRoles = [], string $uidKey = null, string $filter = null, string $passwordAttribute = null, array $extraFields = [])
{
if (null === $uidKey) {
$uidKey = 'sAMAccountName';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SesSmtpTransport extends EsmtpTransport
/**
* @param string|null $region Amazon SES region
*/
public function __construct(string $username, string $password, string $region = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
public function __construct(string $username, #[\SensitiveParameter] string $password, string $region = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
parent::__construct(sprintf('email-smtp.%s.amazonaws.com', $region ?: 'eu-west-1'), 465, true, $dispatcher, $logger);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class GmailSmtpTransport extends EsmtpTransport
{
public function __construct(string $username, string $password, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
public function __construct(string $username, #[\SensitiveParameter] string $password, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
parent::__construct('smtp.gmail.com', 465, true, $dispatcher, $logger);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MandrillSmtpTransport extends EsmtpTransport
{
use MandrillHeadersTrait;

public function __construct(string $username, string $password, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
public function __construct(string $username, #[\SensitiveParameter] string $password, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
parent::__construct('smtp.mandrillapp.com', 587, false, $dispatcher, $logger);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MailgunSmtpTransport extends EsmtpTransport
{
use MailgunHeadersTrait;

public function __construct(string $username, string $password, string $region = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
public function __construct(string $username, #[\SensitiveParameter] string $password, string $region = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
parent::__construct('us' !== ($region ?: 'us') ? sprintf('smtp.%s.mailgun.org', $region) : 'smtp.mailgun.org', 465, true, $dispatcher, $logger);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class MailjetSmtpTransport extends EsmtpTransport
{
public function __construct(string $username, string $password, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
public function __construct(string $username, #[\SensitiveParameter] string $password, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
parent::__construct('in-v3.mailjet.com', 465, true, $dispatcher, $logger);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
final class SendinblueSmtpTransport extends EsmtpTransport
{
public function __construct(string $username, string $password, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
public function __construct(string $username, #[\SensitiveParameter] string $password, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
parent::__construct('smtp-relay.sendinblue.com', 465, true, $dispatcher, $logger);

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Mailer/Transport/Dsn.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class Dsn
private ?int $port;
private array $options;

public function __construct(string $scheme, string $host, string $user = null, string $password = null, int $port = null, array $options = [])
public function __construct(string $scheme, string $host, string $user = null, #[\SensitiveParameter] string $password = null, int $port = null, array $options = [])
{
$this->scheme = $scheme;
$this->host = $host;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function authenticate(EsmtpTransport $client): void
/**
* Generates a CRAM-MD5 response from a server challenge.
*/
private function getResponse(string $secret, string $challenge): string
private function getResponse(#[\SensitiveParameter] string $secret, string $challenge): string
{
if (\strlen($secret) > 64) {
$secret = pack('H32', md5($secret));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function getUsername(): string
/**
* @return $this
*/
public function setPassword(string $password): static
public function setPassword(#[\SensitiveParameter] string $password): static
{
$this->password = $password;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class DiscordTransport extends AbstractTransport
private string $token;
private string $webhookId;

public function __construct(string $token, string $webhookId, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(#[\SensitiveParameter] string $token, string $webhookId, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
$this->token = $token;
$this->webhookId = $webhookId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class EsendexTransport extends AbstractTransport
private string $accountReference;
private string $from;

public function __construct(string $email, string $password, string $accountReference, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(string $email, #[\SensitiveParameter] string $password, string $accountReference, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
$this->email = $email;
$this->password = $password;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class FirebaseTransport extends AbstractTransport

private string $token;

public function __construct(string $token, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(#[\SensitiveParameter] string $token, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
$this->token = $token;
$this->client = $client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class FreeMobileTransport extends AbstractTransport
private string $password;
private string $phone;

public function __construct(string $login, string $password, string $phone, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(string $login, #[\SensitiveParameter] string $password, string $phone, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
$this->login = $login;
$this->password = $password;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class GitterTransport extends AbstractTransport
private string $token;
private string $roomId;

public function __construct(string $token, string $roomId, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(#[\SensitiveParameter] string $token, string $roomId, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
$this->token = $token;
$this->roomId = $roomId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class GoogleChatTransport extends AbstractTransport
* Subsequent messages with the same thread identifier will be posted into the same thread.
* {@see https://developers.google.com/hangouts/chat/reference/rest/v1/spaces.messages/create#query-parameters}
*/
public function __construct(string $space, string $accessKey, string $accessToken, string $threadKey = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(string $space, string $accessKey, #[\SensitiveParameter] string $accessToken, string $threadKey = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
$this->space = $space;
$this->accessKey = $accessKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class IqsmsTransport extends AbstractTransport
private string $password;
private string $from;

public function __construct(string $login, string $password, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(string $login, #[\SensitiveParameter] string $password, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
$this->login = $login;
$this->password = $password;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class KazInfoTehTransport extends AbstractTransport
private string $password;
private string $sender;

public function __construct(string $username, string $password, string $sender, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(string $username, #[\SensitiveParameter] string $password, string $sender, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
$this->username = $username;
$this->password = $password;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ final class LightSmsTransport extends AbstractTransport
999 => 'Unknown Error',
];

public function __construct(string $login, string $password, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(string $login, #[\SensitiveParameter] string $password, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
$this->login = $login;
$this->password = $password;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class MattermostTransport extends AbstractTransport
private string $channel;
private ?string $path;

public function __construct(string $token, string $channel, string $path = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(#[\SensitiveParameter] string $token, string $channel, string $path = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
$this->token = $token;
$this->channel = $channel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class MessageBirdTransport extends AbstractTransport
private string $token;
private string $from;

public function __construct(string $token, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(#[\SensitiveParameter] string $token, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
$this->token = $token;
$this->from = $from;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class RocketChatTransport extends AbstractTransport
private string $accessToken;
private ?string $chatChannel;

public function __construct(string $accessToken, string $chatChannel = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(#[\SensitiveParameter] string $accessToken, string $chatChannel = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
$this->accessToken = $accessToken;
$this->chatChannel = $chatChannel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class SendberryTransport extends AbstractTransport
private string $authKey;
private string $from;

public function __construct(string $username, string $password, string $authKey, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(string $username, #[\SensitiveParameter] string $password, string $authKey, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
$this->username = $username;
$this->password = $password;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class SlackTransport extends AbstractTransport
private string $accessToken;
private ?string $chatChannel;

public function __construct(string $accessToken, string $channel = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(#[\SensitiveParameter] string $accessToken, string $channel = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
if (!preg_match('/^xox(b-|p-|a-2)/', $accessToken)) {
throw new InvalidArgumentException('A valid Slack token needs to start with "xoxb-", "xoxp-" or "xoxa-2". See https://api.slack.com/authentication/token-types for further information.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class SmsFactorTransport extends AbstractTransport
private ?string $sender;
private ?SmsFactorPushType $pushType;

public function __construct(string $tokenApi, ?string $sender, ?SmsFactorPushType $pushType, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
public function __construct(#[\SensitiveParameter] string $tokenApi, ?string $sender, ?SmsFactorPushType $pushType, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
{
$this->tokenApi = $tokenApi;
$this->sender = $sender;
Expand Down
Loading