-
Notifications
You must be signed in to change notification settings - Fork 0
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
Hardening suggestions for probabilityguesser-tk / test #4
base: test
Are you sure you want to change the base?
Conversation
@@ -17,29 +17,29 @@ def click(): | |||
output.insert(END, calculateScore(guess, probability)) | |||
|
|||
def coinToss(): | |||
rng = random.randint(1, 20) | |||
rng = secrets.SystemRandom().randint(1, 20) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace random.{func} with more secure secrets library functions.
if (rng % 4 == 0): | ||
fair = True | ||
else: | ||
fair = False | ||
if not fair: | ||
rng = random.randint(1, 20) | ||
rng = secrets.SystemRandom().randint(1, 20) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace random.{func} with more secure secrets library functions.
if (rng % 2 == 0): | ||
range_lower = True | ||
else: | ||
range_lower = False | ||
if not range_lower: | ||
probability = random.randint(60, 80) | ||
probability = secrets.SystemRandom().randint(60, 80) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace random.{func} with more secure secrets library functions.
else: | ||
probability = random.randint(20, 40) | ||
probability = secrets.SystemRandom().randint(20, 40) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace random.{func} with more secure secrets library functions.
else: | ||
probability = 50 | ||
|
||
heads_dist = numpy.array(0) | ||
heads = 0 | ||
for i in range(1,1000): | ||
for j in range(1,30): | ||
comparison = random.randint(1, 100) | ||
comparison = secrets.SystemRandom().randint(1, 100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace random.{func} with more secure secrets library functions.
@@ -52,7 +52,7 @@ def coinToss(): | |||
|
|||
|
|||
#seed rng | |||
random.seed() | |||
secrets.SystemRandom().seed() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace random.{func} with more secure secrets library functions.
I've reviewed the recently opened PR (3 - Add files via upload) and have identified some area(s) that could benefit from additional hardening measures.
These changes should help prevent potential security vulnerabilities and improve overall code quality.
Thank you for your consideration!
docs | feedback
Powered by: pixeebot