Skip to content

Commit b7464ed

Browse files
Check whether secrets are empty and mark them all as sensitive
1 parent 9a1a42e commit b7464ed

File tree

25 files changed

+75
-31
lines changed

25 files changed

+75
-31
lines changed

src/Symfony/Component/HttpFoundation/UriSigner.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
namespace Symfony\Component\HttpFoundation;
1313

1414
/**
15-
* Signs URIs.
16-
*
1715
* @author Fabien Potencier <fabien@symfony.com>
1816
*/
1917
class UriSigner
@@ -22,11 +20,15 @@ class UriSigner
2220
private string $parameter;
2321

2422
/**
25-
* @param string $secret A secret
2623
* @param string $parameter Query string parameter to use
2724
*/
2825
public function __construct(#[\SensitiveParameter] string $secret, string $parameter = '_hash')
2926
{
27+
if (!$secret) {
28+
trigger_deprecation('symfony/http-foundation', '6.4', 'Calling "%s()" with an empty secret is deprecated. A non-empty secret will be mandatory in version 7.0.', __METHOD__);
29+
// throw new \InvalidArgumentException('A non-empty secret is required.');
30+
}
31+
3032
$this->secret = $secret;
3133
$this->parameter = $parameter;
3234
}

src/Symfony/Component/Mailer/Bridge/Brevo/Webhook/BrevoRequestParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function getRequestMatcher(): RequestMatcherInterface
4141
]);
4242
}
4343

44-
protected function doParse(Request $request, string $secret): ?AbstractMailerEvent
44+
protected function doParse(Request $request, #[\SensitiveParameter] string $secret): ?AbstractMailerEvent
4545
{
4646
$content = $request->toArray();
4747
if (

src/Symfony/Component/Mailer/Bridge/Mailgun/Webhook/MailgunRequestParser.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@ protected function getRequestMatcher(): RequestMatcherInterface
3737
]);
3838
}
3939

40-
protected function doParse(Request $request, string $secret): ?AbstractMailerEvent
40+
protected function doParse(Request $request, #[\SensitiveParameter] string $secret): ?AbstractMailerEvent
4141
{
42+
if (!$secret) {
43+
trigger_deprecation('symfony/mailer', '6.4', 'Calling "%s()" with an empty secret is deprecated. A non-empty secret will be mandatory in version 7.0.', __METHOD__);
44+
// throw new \Symfony\Component\Mailer\Exception\InvalidArgumentException('A non-empty secret is required.');
45+
}
46+
4247
$content = $request->toArray();
4348
if (
4449
!isset($content['signature']['timestamp'])
@@ -60,7 +65,7 @@ protected function doParse(Request $request, string $secret): ?AbstractMailerEve
6065
}
6166
}
6267

63-
private function validateSignature(array $signature, string $secret): void
68+
private function validateSignature(array $signature, #[\SensitiveParameter] string $secret): void
6469
{
6570
// see https://documentation.mailgun.com/en/latest/user_manual.html#webhooks-1
6671
if (!hash_equals($signature['signature'], hash_hmac('sha256', $signature['timestamp'].$signature['token'], $secret))) {

src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=8.1",
20+
"symfony/deprecation-contracts": "^2.5|^3",
2021
"symfony/mailer": "^5.4.21|^6.2.7|^7.0"
2122
},
2223
"require-dev": {

src/Symfony/Component/Mailer/Bridge/Mailjet/Webhook/MailjetRequestParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected function getRequestMatcher(): RequestMatcherInterface
3737
]);
3838
}
3939

40-
protected function doParse(Request $request, string $secret): ?AbstractMailerEvent
40+
protected function doParse(Request $request, #[\SensitiveParameter] string $secret): ?AbstractMailerEvent
4141
{
4242
try {
4343
return $this->converter->convert($request->toArray());

src/Symfony/Component/Mailer/Bridge/Postmark/Webhook/PostmarkRequestParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function getRequestMatcher(): RequestMatcherInterface
4141
]);
4242
}
4343

44-
protected function doParse(Request $request, string $secret): ?AbstractMailerEvent
44+
protected function doParse(Request $request, #[\SensitiveParameter] string $secret): ?AbstractMailerEvent
4545
{
4646
$payload = $request->toArray();
4747
if (

src/Symfony/Component/Mailer/Bridge/Sendgrid/Webhook/SendgridRequestParser.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ protected function doParse(Request $request, string $secret): ?AbstractMailerEve
8686
*
8787
* @see https://docs.sendgrid.com/for-developers/tracking-events/getting-started-event-webhook-security-features
8888
*/
89-
private function validateSignature(
90-
string $signature,
91-
string $timestamp,
92-
string $payload,
93-
string $secret,
94-
): void {
89+
private function validateSignature(string $signature, string $timestamp, string $payload, #[\SensitiveParameter] string $secret): void
90+
{
91+
if (!$secret) {
92+
trigger_deprecation('symfony/mailer', '6.4', 'Calling "%s()" with an empty secret is deprecated. A non-empty secret will be mandatory in version 7.0.', __METHOD__);
93+
// throw new \Symfony\Component\Mailer\Exception\InvalidArgumentException('A non-empty secret is required.');
94+
}
95+
9596
$timestampedPayload = $timestamp.$payload;
9697

9798
// Sendgrid provides the verification key as base64-encoded DER data. Openssl wants a PEM format, which is a multiline version of the base64 data.

src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=8.1",
20+
"symfony/deprecation-contracts": "^2.5|^3",
2021
"symfony/mailer": "^5.4.21|^6.2.7|^7.0"
2122
},
2223
"require-dev": {

src/Symfony/Component/Mailer/Transport/Smtp/Auth/CramMd5Authenticator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public function authenticate(EsmtpTransport $client): void
4141
*/
4242
private function getResponse(#[\SensitiveParameter] string $secret, string $challenge): string
4343
{
44+
if (!$secret) {
45+
trigger_deprecation('symfony/mailer', '6.4', 'Calling "%s()" with an empty secret is deprecated. A non-empty secret will be mandatory in version 7.0.', __METHOD__);
46+
// throw new \Symfony\Component\Mailer\Exception\InvalidArgumentException('A non-empty secret is required.');
47+
}
48+
4449
if (\strlen($secret) > 64) {
4550
$secret = pack('H32', md5($secret));
4651
}

src/Symfony/Component/Mailer/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"egulias/email-validator": "^2.1.10|^3|^4",
2121
"psr/event-dispatcher": "^1",
2222
"psr/log": "^1|^2|^3",
23+
"symfony/deprecation-contracts": "^2.5|^3",
2324
"symfony/event-dispatcher": "^5.4|^6.0|^7.0",
2425
"symfony/mime": "^6.2|^7.0",
2526
"symfony/service-contracts": "^2.5|^3"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy