Fix genkatdict.py bug and add tests for scripts (#1408)#2466
Open
vikasmulaje wants to merge 2 commits into
Open
Fix genkatdict.py bug and add tests for scripts (#1408)#2466vikasmulaje wants to merge 2 commits into
vikasmulaje wants to merge 2 commits into
Conversation
Fix json.dumps -> json.dump in genkatdict.py: the script used json.dumps(d, f, ...) which raises TypeError on all Python 3.6+ versions since the file handle cannot be a positional argument to dumps(). The correct function is json.dump() which writes to a file. Add tests/test_scripts.py covering 6 previously untested scripts: - scripts/doxyfy.py (anchor reformatting for doxygen) - scripts/format_docs_yaml.py (YAML normalization) - scripts/git_commit.sh (git hash retrieval) - scripts/genkatsha256.sh (SHA-256 generation from KAT files) - scripts/update_docs_from_yaml.py (markdown generation from YAML) - scripts/update_cbom.py (Cryptography BOM generation) - scripts/genkatdict.py (KAT dictionary builder) Addresses open-quantum-safe#1408 Co-authored-by: Cursor <cursoragent@cursor.com>
bbbda3e to
3134773
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Fix a bug in
scripts/genkatdict.pyand add test coverage for 6 previouslyuntested scripts, addressing #1408.
Bug fix
scripts/genkatdict.pyline 16 usedjson.dumps(d, f, ...)instead ofjson.dump(d, f, ...). Since Python 3.6, all optional parameters tojson.dumps()are keyword-only, so passing a file handle as a secondpositional argument raises
TypeError. The fix is a one-character change:dumps->dump.New tests
tests/test_scripts.pyadds 22 tests covering:scripts/doxyfy.py(7 tests)scripts/format_docs_yaml.py(2 tests)scripts/git_commit.sh(2 tests)scripts/genkatsha256.sh(3 tests)scripts/update_docs_from_yaml.py(3 tests)scripts/update_cbom.py(3 tests)scripts/genkatdict.py(2 tests)All 22 tests pass locally.
Use of generative AI
This contribution was produced with the assistance of an AI coding agent
(Cursor with Claude). The AI was used to:
tests/test_scripts.pyjson.dumps/json.dumpbug ingenkatdict.pyAll code has been reviewed and verified by the contributor before submission.
The contributor has read the OpenSSF Security-Focused Guide for AI Code
Assistant Instructions.
Made with Cursor