Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0b969cb

Browse files
committed
do not use uniqid() for generating dev tool tokens
1 parent1a16ebc commit0b969cb

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

‎src/Symfony/Bundle/FrameworkBundle/EventListener/ConsoleProfilerListener.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function initialize(ConsoleCommandEvent $event): void
7777
return;
7878
}
7979

80-
$request->attributes->set('_stopwatch_token',substr(hash('xxh128',uniqid(mt_rand(),true)),0,6));
80+
$request->attributes->set('_stopwatch_token',substr(hash('xxh128',random_bytes(14)),0,6));
8181
$this->stopwatch->openSection();
8282
}
8383

‎src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected function beforeDispatch(string $eventName, object $event): void
2727
{
2828
switch ($eventName) {
2929
case KernelEvents::REQUEST:
30-
$event->getRequest()->attributes->set('_stopwatch_token',substr(hash('xxh128',uniqid(mt_rand(),true)),0,6));
30+
$event->getRequest()->attributes->set('_stopwatch_token',substr(hash('xxh128',random_bytes(14)),0,6));
3131
$this->stopwatch->openSection();
3232
break;
3333
case KernelEvents::VIEW:

‎src/Symfony/Component/HttpKernel/Profiler/Profiler.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
133133
returnnull;
134134
}
135135

136-
$profile =newProfile(substr(hash('xxh128',uniqid(mt_rand(),true)),0,6));
136+
$profile =newProfile(substr(hash('xxh128',random_bytes(14)),0,6));
137137
$profile->setTime(time());
138138
$profile->setUrl($request->getUri());
139139
$profile->setMethod($request->getMethod());

‎src/Symfony/Component/Serializer/Debug/TraceableSerializer.php‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(
3737

3838
publicfunctionserialize(mixed$data,string$format,array$context = []):string
3939
{
40-
$context[self::DEBUG_TRACE_ID] =$traceId =uniqid();
40+
$context[self::DEBUG_TRACE_ID] =$traceId =substr(hash('xxh128',random_bytes(14)),0,6);
4141

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

5353
publicfunctiondeserialize(mixed$data,string$type,string$format,array$context = []):mixed
5454
{
55-
$context[self::DEBUG_TRACE_ID] =$traceId =uniqid();
55+
$context[self::DEBUG_TRACE_ID] =$traceId =substr(hash('xxh128',random_bytes(14)),0,6);
5656

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

6868
publicfunctionnormalize(mixed$object, ?string$format =null,array$context = []):array|string|int|float|bool|\ArrayObject|null
6969
{
70-
$context[self::DEBUG_TRACE_ID] =$traceId =uniqid();
70+
$context[self::DEBUG_TRACE_ID] =$traceId =substr(hash('xxh128',random_bytes(14)),0,6);
7171

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

8383
publicfunctiondenormalize(mixed$data,string$type, ?string$format =null,array$context = []):mixed
8484
{
85-
$context[self::DEBUG_TRACE_ID] =$traceId =uniqid();
85+
$context[self::DEBUG_TRACE_ID] =$traceId =substr(hash('xxh128',random_bytes(14)),0,6);
8686

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

9898
publicfunctionencode(mixed$data,string$format,array$context = []):string
9999
{
100-
$context[self::DEBUG_TRACE_ID] =$traceId =uniqid();
100+
$context[self::DEBUG_TRACE_ID] =$traceId =substr(hash('xxh128',random_bytes(14)),0,6);
101101

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

113113
publicfunctiondecode(string$data,string$format,array$context = []):mixed
114114
{
115-
$context[self::DEBUG_TRACE_ID] =$traceId =uniqid();
115+
$context[self::DEBUG_TRACE_ID] =$traceId =substr(hash('xxh128',random_bytes(14)),0,6);
116116

117117
$startTime =microtime(true);
118118
$result =$this->serializer->decode($data,$format,$context);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp