mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 07:04:53 +00:00
Add doc about usedforsecurity flag for S324 (#16190)
## Summary Provides documentation about the FIPS compliant flag for Python hashlib `usedforsecurity` Fixes #16188 ## Test Plan * pre-commit hooks --------- Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
This commit is contained in:
parent
61fef0a64a
commit
1f17916224
1 changed files with 13 additions and 0 deletions
|
@ -43,9 +43,22 @@ use super::super::helpers::string_literal;
|
||||||
/// return hash == known_hash
|
/// return hash == known_hash
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
/// or add `usedforsecurity=False` if the hashing algorithm is not used in a security context, e.g.
|
||||||
|
/// as a non-cryptographic one-way compression function:
|
||||||
|
/// ```python
|
||||||
|
/// import hashlib
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// def certificate_is_valid(certificate: bytes, known_hash: str) -> bool:
|
||||||
|
/// hash = hashlib.md5(certificate, usedforsecurity=False).hexdigest()
|
||||||
|
/// return hash == known_hash
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `hashlib` — Secure hashes and message digests](https://docs.python.org/3/library/hashlib.html)
|
/// - [Python documentation: `hashlib` — Secure hashes and message digests](https://docs.python.org/3/library/hashlib.html)
|
||||||
/// - [Python documentation: `crypt` — Function to check Unix passwords](https://docs.python.org/3/library/crypt.html)
|
/// - [Python documentation: `crypt` — Function to check Unix passwords](https://docs.python.org/3/library/crypt.html)
|
||||||
|
/// - [Python documentation: `FIPS` - FIPS compliant hashlib implementation](https://docs.python.org/3/library/hashlib.html#hashlib.algorithms_guaranteed)
|
||||||
/// - [Common Weakness Enumeration: CWE-327](https://cwe.mitre.org/data/definitions/327.html)
|
/// - [Common Weakness Enumeration: CWE-327](https://cwe.mitre.org/data/definitions/327.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-328](https://cwe.mitre.org/data/definitions/328.html)
|
/// - [Common Weakness Enumeration: CWE-328](https://cwe.mitre.org/data/definitions/328.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-916](https://cwe.mitre.org/data/definitions/916.html)
|
/// - [Common Weakness Enumeration: CWE-916](https://cwe.mitre.org/data/definitions/916.html)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue