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

Add more random functions to B311 check #1235

Merged
merged 4 commits into from
Feb 19, 2025
Merged

Conversation

aripollak
Copy link
Contributor

Fixes #1215.

@@ -11,6 +11,9 @@
bad = random.uniform()
bad = random.triangular()
bad = random.randbytes()
bad = random.sample()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes will require an update to the functional tests to update the count of the number of fail checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

@ericwb ericwb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might result in more false positives, but likely as much as before with the other random functions. Okay for now, but in the future we may need to consider a better way to detect random used in a cryptographic fashion to isolate a more likely security issue.

@aripollak
Copy link
Contributor Author

Agreed. I was considering a separate feature request to at least allow some obvious non-cryptography cases through, like choices from a constant list or tuple of literals, but I'm not sure how common those would be.

@lukehinds lukehinds merged commit c58c00a into PyCQA:main Feb 19, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add sample, randrange, and getrandbits to B311 random module check?
3 participants