8000 use more entropy with `uniqid()` by xabbuh · Pull Request #57726 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

use more entropy with uniqid() #57726

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 15, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function testCreateUploadedFile()
$symfonyUploadedFile = $this->callCreateUploadedFile($uploadedFile);
$size = $symfonyUploadedFile->getSize();

$uniqid = uniqid();
$uniqid = uniqid('', true);
$symfonyUploadedFile->move($this->tmpDir, $uniqid);

$this->assertEquals($uploadedFile->getSize(), $size);
Expand All @@ -198,7 +198,7 @@ public function testCreateUploadedFileWithError()

private function createUploadedFile(string $content, int $error, string $clientFileName, string $clientMediaType): UploadedFile
{
$filePath = tempnam($this->tmpDir, uniqid());
$filePath = tempnam($this->tmpDir, uniqid('', true));
file_put_contents($filePath, $content);

return new UploadedFile($filePath, filesize($filePath), $error, $clientFileName, $clientMediaType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function testGetContentCanBeCalledAfterRequestCreation()

private function createUploadedFile(string $content, string $originalName, string $mimeType, int $error): UploadedFile
{
$path = tempnam($this->tmpDir, uniqid());
$path = tempnam($this->tmpDir, uniqid('', true));
file_put_contents($path, $content);

return new UploadedFile($path, $originalName, $mimeType, $error, true);
Expand Down Expand Up @@ -182,7 +182,7 @@ public function testCreateResponseFromStreamed()

public function testCreateResponseFromBinaryFile()
{
$path = tempnam($this->tmpDir, uniqid());
$path = tempnam($this->tmpDir, uniqid('', true));
file_put_contents($path, 'Binary');

$response = new BinaryFileResponse($path);
Expand All @@ -194,7 +194,7 @@ public function testCreateResponseFromBinaryFile()

public function testCreateResponseFromBinaryFileWithRange()
{
$path = tempnam($this->tmpDir, uniqid());
$path = tempnam($this->tmpDir, uniqid('', true));
file_put_contents($path, 'Binary');

$request = new Request();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public static function responseProvider(): array

private static function createUploadedFile(string $content, string $originalName, string $mimeType, int $error): UploadedFile
{
$path = tempnam(sys_get_temp_dir(), uniqid());
$path = tempnam(sys_get_temp_dir(), uniqid('', true));
file_put_contents($path, $content);

return new UploadedFile($path, $originalName, $mimeType, $error, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public function testInvalidSentinelMasterName()
}

$master = getenv('MESSENGER_REDIS_DSN');
$uid = uniqid('sentinel_');
$uid = uniqid('sentinel_', true);

$exp = explode('://', $master, 2)[1];
$this->expectException(\InvalidArgumentException::class);
Expand Down
12 changes: 6 additions & 6 deletions src/Symfony/Component/Serializer/Debug/TraceableSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(

public function serialize(mixed $data, string $format, array $context = []): string
{
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid();
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid('', true);

$startTime = microtime(true);
$result = $this->serializer->serialize($data, $format, $context);
Expand All @@ -56,7 +56,7 @@ public function serialize(mixed $data, string $format, array $context = []): str

public function deserialize(mixed $data, string $type, string $format, array $context = []): mixed
{
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid();
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid('', true);

$startTime = microtime(true);
$result = $this->serializer->deserialize($data, $type, $format, $context);
Expand All @@ -71,7 +71,7 @@ public function deserialize(mixed $data, string $type, string $format, array $co

public function normalize(mixed $object, ?string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid();
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid('', true);

$startTime = microtime(true);
$result = $this->serializer->normalize($object, $format, $context);
Expand All @@ -86,7 +86,7 @@ public function normalize(mixed $object, ?string $format = null, array $context

public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
{
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid();
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid('', true);

$startTime = microtime(true);
$result = $this->serializer->denormalize($data, $type, $format, $context);
Expand All @@ -101,7 +101,7 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a

public function encode(mixed $data, string $format, array $context = []): string
{
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid();
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid('', true);

$startTime = microtime(true);
$result = $this->serializer->encode($data, $format, $context);
Expand All @@ -116,7 +116,7 @@ public function encode(mixed $data, string $format, array $context = []): string

public function decode(string $data, string $format, array $context = []): mixed
{
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid();
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid('', true);

$startTime = microtime(true);
$result = $this->serializer->decode($data, $format, $context);
Expand Down
Loading
0