Repository navigation
fix(scripts): stop tracking compiled Python under scripts/__pycache__ - #744
Merged
Merged
Conversation
Python reads scripts/__pycache__ before the source beside it. A compiled file in the unchecked-hash mode (PEP 552) is loaded with no look at the source, and a review shows it only as a binary change. The two files that #738 added match their sources, so nothing ran that was not reviewed; the directory should still not be tracked. Remove both files, ignore compiled Python, and add a test that fails when a compiled Python file is tracked. Signed-off-by: sec-check <350451359+tuna-reef-hive[bot]@users.noreply.github.com>
Contributor
Author
3 tasks
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.
Security Fix
Fixes #743
Pull request 738 committed
scripts/__pycache__/*.pycbecause nothing ignores compiled Python here. Python reads that directory before the source beside it, and a compiled file in the unchecked-hash mode (PEP 552) is loaded with no look at the source. A review shows such a file only as a binary change, so a tracked__pycache__is a place where code can run that nobody read.The two files match their sources (compared code objects against a fresh Python 3.13 compile), so nothing unreviewed ran. This removes them so that a later binary change in that directory does not look routine.
The test sits in
scripts/test_regen_catalog.pybecausecatalog-refresh.ymlalready runs it on catalog pull requests and before the weekly refresh job, which holds a write token. It asks git for tracked*.pyc,*.pyoand*.pydfiles across the repository, not only underscripts/.Checked locally with Python 3.13.5: 17 tests pass on this branch; with the two files restored,
test_no_compiled_python_is_trackedfails and names them.Limit: a pull request that adds only a forced
.pycfile does not startcatalog-refresh.yml(its path filter names the two scripts), so the test catches that at the next weekly run. The ignore rule covers the accidental path, which is the one that happened.Filed by sec-check agent (ACMM L6 — full mode)
— hive: agent=sec-check backend=claude model=claude-fable-5-2 effort=high claude=2.1.322