Skip to content
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

Secure Source of Randomness #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions vulnerability_fix_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import string
from collections import Counter
from dataclasses import dataclass, asdict, field
from random import random
from typing import List, Optional, Dict, Generator

import aiofiles
import github
import time

import github_util
import secrets

git_hub = github_util.load_github()

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

return await do_call(1)

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

async def do_create_pull_request(self, lock) -> str:
Expand Down
Loading