What changed, and why it matters
This commit is a small code cleanup in SeedSigner's version helper. It extracts a repeated file-path calculation into a shared method and updates a comment about where the version file is written. There is no security-relevant change: the same file is read/written, the same JSON parsing occurs, and no new inputs or trust decisions are introduced.
No security action required. Treat as routine maintenance/refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff refactors src/seedsigner/helpers/version.py. A new private classmethod _get_version_file_path() centralizes os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", cls.VERSION_FILENAME). _get_version_file() now calls that method and removes the redundant os.path.exists() guard, relying on the existing try/except for missing files. The __main__ CLI writer now uses the same path helper and updates its printed comment from src/version.json to src/seedsigner/version.json to match the actual path. No behavior affecting security boundaries, file permissions, parsing of untrusted data, or cryptographic operations is changed.
Changed components
src/seedsigner/helpers/version.pyInspect captured patch +17 / −13
diff --git a/src/seedsigner/helpers/version.py b/src/seedsigner/helpers/version.py
index b5f7068..f56f45e 100644
--- a/src/seedsigner/helpers/version.py
+++ b/src/seedsigner/helpers/version.py
@@ -67,25 +67,29 @@ class Version:
# Filename is the tag name
return tag_filename
return None
-
+
+
+ @classmethod
+ def _get_version_file_path(cls) -> str:
+ # Have to back out of "helpers" dir to the main "seedsigner" dir
+ return os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", cls.VERSION_FILENAME)
+
@classmethod
def _get_version_file(cls) -> dict | None:
"""
Attempts to read the VERSION_FILENAME and return its contents as a dict.
"""
- version_file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", cls.VERSION_FILENAME)
- if os.path.exists(version_file_path):
- try:
- with open(version_file_path, "r") as f:
- return json.load(f)
- except Exception as e:
- # In local dev we don't expect/want this file to exist
- pass
+ version_file_path = cls._get_version_file_path()
+ try:
+ with open(version_file_path, "r") as f:
+ return json.load(f)
+ except Exception as e:
+ # In local dev we don't expect/want this file to exist
+ pass
return None
-
@classmethod
def get_version(cls) -> str:
"""
@@ -162,15 +166,15 @@ class Version:
if __name__ == "__main__":
"""
- CLI to extract the current version and last edit time and write to `src/version.json`.
+ CLI to extract the current version and last edit time and write to `src/seedsigner/version.json`.
"""
version_info = dict(version=Version.get_version())
last_edit_dt = Version.get_last_src_edit()
if last_edit_dt:
version_info["last_src_edit"] = last_edit_dt.isoformat()
- with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", Version.VERSION_FILENAME), "w") as f:
+ with open(Version._get_version_file_path(), "w") as f:
json.dump(version_info, f, indent=4)
- print("Wrote version info to src/version.json:")
+ print("Wrote version info to src/seedsigner/version.json:")
print(json.dumps(version_info, indent=4))
\ No newline at end of file
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.