Skip to content

Commit 7288552

Browse files
committed
replace uniqid() with random_bytes() to create identifiers
1 parent 05e61ff commit 7288552

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/ConnectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public static function provideIdPatterns(): \Generator
397397
{
398398
yield 'No delay' => ['/^THE_MESSAGE_ID$/', 0, 'xadd', 'THE_MESSAGE_ID'];
399399

400-
yield '100ms delay' => ['/^\w+\.\d+$/', 100, 'rawCommand', '1'];
400+
yield '100ms delay' => ['/^[a-f\d]+$/', 100, 'rawCommand', '1'];
401401
}
402402

403403
public function testInvalidSentinelMasterName()

src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ public function add(string $body, array $headers, int $delayInMs = 0): string
521521

522522
try {
523523
if ($delayInMs > 0) { // the delay is <= 0 for queued messages
524-
$id = uniqid('', true);
524+
$id = bin2hex(random_bytes(4));
525525
$message = json_encode([
526526
'body' => $body,
527527
'headers' => $headers,

src/Symfony/Component/Notifier/Bridge/Iqsms/IqsmsTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected function doSend(MessageInterface $message): SentMessage
6161
'phone' => $message->getPhone(),
6262
'text' => $message->getSubject(),
6363
'sender' => $message->getFrom() ?: $this->from,
64-
'clientId' => uniqid('', true),
64+
'clientId' => bin2hex(random_bytes(4)),
6565
],
6666
],
6767
'login' => $this->login,

src/Symfony/Component/Process/Process.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,7 @@ private function buildShellCommandline(string|array $commandline): string
15431543
private function prepareWindowsCommandLine(string|array $cmd, array &$env): string
15441544
{
15451545
$cmd = $this->buildShellCommandline($cmd);
1546-
$uid = uniqid('', true);
1546+
$uid = bin2hex(random_bytes(4));
15471547
$cmd = preg_replace_callback(
15481548
'/"(?:(
15491549
[^"%!^]*+

src/Symfony/Component/VarDumper/Command/Descriptor/HtmlDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function describe(OutputInterface $output, Data $data, array $context, in
5050
$title = '<code>$ </code>'.$context['cli']['command_line'];
5151
$dedupIdentifier = $context['cli']['identifier'];
5252
} else {
53-
$dedupIdentifier = uniqid('', true);
53+
$dedupIdentifier = bin2hex(random_bytes(4));
5454
}
5555

5656
$sourceDescription = '';

0 commit comments

Comments
 (0)