You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🔴 Bug: import tempfile312 as tempfile — typo causes ImportError
File:examples/test_fs_convert.py:2
importtempfile312astempfile# ← should be: import tempfile
tempfile312 is not a standard library module or known package. This will cause an ImportError when tests are run. Fix this →
🔴 CHANGELOG regression: removes an existing entry
File:ofrak_core/CHANGELOG.md
The PR diff removes this line from master's CHANGELOG:
- Fix typo in `find` command used by CPIO packer (#740)
This is almost certainly a bad merge conflict resolution when master was merged into the feature branch. If this PR lands as-is, it will drop a released changelog entry. The PR also does not add a new entry for itself, which is required per CLAUDE.md and CONTRIBUTING.md. Fix this →%20restore%20the%20removed%20line%20%22Fix%20typo%20in%20find%20command%20used%20by%20CPIO%20packer%20(%23740)%22%20in%20the%20Unreleased%20section%2C%20and%202)%20add%20a%20new%20Added%20entry%20for%20%22Add%20simple%20CLI%20filesystem%20converter%20(fs_convert.py)%20to%20examples%22.&repo=redballoonsecurity/ofrak)
🔴 # pragma: no cover violates 100% coverage requirement
File:examples/fs_convert.py:50
defdetect_format_from_extension(path: str) ->str: # pragma: no cover
CLAUDE.md mandates 100% coverage enforced by fun-coverage. Using pragma: no cover is a workaround, not a fix. The root cause is that the function calls sys.exit() directly, which is hard to test without mocking (and mocking is prohibited per CLAUDE.md).
Recommendation: Raise a ValueError instead of calling sys.exit(). Move the sys.exit call to the __main__ block:
defdetect_format_from_extension(path: str) ->str:
ext=os.path.splitext(path)[1].lower()
fmt=EXTENSION_MAP.get(ext)
iffmtisNone:
raiseValueError(
f"Cannot detect format from extension '{ext}'. "f"Use --to with one of: {', '.join(FORMATS.keys())}"
)
returnfmt
Then in __main__, wrap in a try/except ValueError and call sys.exit. This makes the function fully testable. Fix this →
🟡 Temp directory leak in test helper
File:examples/test_fs_convert.py:55
asyncdefcreate_source_archive(...) ->str:
temp_dir=tempfile.mkdtemp() # never cleaned up
...
mkdtemp() creates a directory that is never deleted. The function returns a path, so a context manager can't be used in-place — but the caller test_fs_convert already has access to tmp_path (a pytest fixture). Pass tmp_path into create_source_archive instead of creating a new temp dir:
A single CpioFilesystem instance is created at import time and reused by all callers of convert_filesystem. If add_view or any downstream code mutates this object, it will silently corrupt later calls. Consider making this a factory (dict of callables) or constructing the instance inside convert_filesystem. The inconsistency with the test is also worth noting: the test builds sources using AttributesType[CpioFilesystem](CpioArchiveType.NEW_ASCII) (via add_attributes), while the converter uses add_view(CpioFilesystem(...)). These are equivalent per the add_view implementation, but the asymmetry makes the code harder to follow.
🟢 Minor: sys imported but only used in the pragma: no cover path
File:examples/fs_convert.py:5
If detect_format_from_extension is refactored to raise ValueError (as suggested above), the import sys and sys.exit call become unnecessary in the library portion of the file. sys would only be needed in the __main__ block.
Summary
Severity
Issue
🔴 Bug
import tempfile312 — ImportError typo
🔴 Standards
CHANGELOG entry removed + no new entry added
🔴 Standards
# pragma: no cover bypasses required 100% coverage
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
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.
One sentence summary of this PR (This should go in the CHANGELOG!)
Add simple CLI filesystem converter using OFRAK.
Anyone you think should look at this, specifically?
@whyitfor