Skip to content

[flake8-bandit] Clarify the supported hashing functions (S324)#20534

Merged
ntBre merged 3 commits intoastral-sh:mainfrom
danparizher:fix-16572
Sep 24, 2025
Merged

[flake8-bandit] Clarify the supported hashing functions (S324)#20534
ntBre merged 3 commits intoastral-sh:mainfrom
danparizher:fix-16572

Conversation

@danparizher
Copy link
Contributor

Summary

Fixes #16572

@github-actions
Copy link
Contributor

github-actions bot commented Sep 23, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, and I think it's nice to have some note like this, but it doesn't seem exactly accurate to say that we support the values in algorithms_guaranteed. I checked all the versions supported by uv (3.7 through 3.14), and sha and md4 haven't been guaranteed algorithms at least since 3.7. I also checked in the CPython source as far back as 3.2, when the constant was added.

I was able to call hashlib.new("md4") on 3.7, but sha didn't work on any version I tested.

Fortunately, I think we can just drop the reference to algorithms_guaranteed and the note still reads well. Since we're effectively enumerating every function checked by the rule, it might make sense to mention the crypt functions (crypt and mksalt) as well.

@ntBre ntBre added the documentation Improvements or additions to documentation label Sep 23, 2025
@danparizher
Copy link
Contributor Author

Thanks for checking, that makes sense. I changed it to explicitly list what the rule actually targets, plus crypt.crypt and crypt.mksalt when used with the weak methods (METHOD_CRYPT, METHOD_MD5, METHOD_BLOWFISH)

@danparizher danparizher requested a review from ntBre September 23, 2025 21:12
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thank you! I just made one suggestion to restore the reference link. Even if we're not checking that list directly, I think the link could still be helpful.

@ntBre ntBre changed the title [flake8-bandit] Clarify S324 only targets Python-guaranteed hashlib algorithms (S324) [flake8-bandit] Clarify the supported hashing functions (S324) Sep 24, 2025
@ntBre ntBre enabled auto-merge (squash) September 24, 2025 20:07
@ntBre ntBre merged commit c361e2f into astral-sh:main Sep 24, 2025
35 checks passed
@danparizher danparizher deleted the fix-16572 branch September 24, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

S324 false negatives for synonyms of insecure algorithm names

2 participants