Skip to content

Commit a6b4ee6

Browse files
Secure Source of Randomness
1 parent c122cb1 commit a6b4ee6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

vulnerability_fix_engine.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
import string
88
from collections import Counter
99
from dataclasses import dataclass, asdict, field
10-
from random import random
1110
from typing import List, Optional, Dict, Generator
1211

1312
import aiofiles
1413
import github
1514
import time
1615

1716
import github_util
17+
import secrets
1818

1919
git_hub = github_util.load_github()
2020

@@ -218,7 +218,7 @@ async def do_call(wait_time, previous_wait_time=0) -> Optional[str]:
218218
# way to slow down this script reasonably
219219
github_util.print_current_rate_limit()
220220
await asyncio.sleep(wait_time)
221-
return await do_call(wait_time * 2 + random(), previous_wait_time=wait_time)
221+
return await do_call(wait_time * 2 + secrets.SystemRandom().random(), previous_wait_time=wait_time)
222222

223223
return await do_call(1)
224224

@@ -354,7 +354,7 @@ async def do_push_changes(self, retry_count: int = 5):
354354
raise e
355355
else:
356356
# Forking is an async operation, so we may need to wait a bit for it
357-
await asyncio.sleep((5 - retry_count) * 2 + random())
357+
await asyncio.sleep((5 - retry_count) * 2 + secrets.SystemRandom().random())
358358
await self.do_push_changes(retry_count - 1)
359359

360360
async def do_create_pull_request(self, lock) -> str:

0 commit comments

Comments
 (0)