Fix master defects + supersede broken 1.0.7#17
Merged
Conversation
…til.format_versions()
… NotFoundError format string
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.
Summary
Fixes the defects identified in a fresh code review of master (the two commits that landed since the 2023 idle period). All 8 commits are scoped to one concern each. Patch built from a local clone, verified with
py_compile+pyflakes(no new warnings vs. master), and the new slot parser was unit-tested on six representative inputs before pushing.Critical fixes
libagent/device/onlykey.py—get_sk_dk()no longer crashes withTypeErrorwhen bothAGENTHOMEDIRandGNUPGHOMEare unset. Falls back to the default slot with a debug log instead of passingNoneintoos.path.join.libagent/device/onlykey.py— slot parser rewritten. The previous hand-counted character-offset parser would silently fall back to slot132on any whitespace/quoting/ordering drift inrun-agent.sh— a correctness-of-cryptographic-identity issue in a hardware-signing path. Replaced with twore.compiled patterns + a small_parse_slot_value()helper. Same semantics for the well-formed inputs the old code handled (ECCn,ECCnn,RSAn, plainn), and unrecognized values now log a warning instead of silently producing a wrong slot.libagent/device/onlykey.py—NotFoundErrorformat string fixed.connect()was raisinginterface.NotFoundError('{} not connected: "{}"')with the literal braces unfilled. Now formats device name and the underlying exception.Hygiene / packaging
setup.py— version1.0.7→1.0.8so the broken 1.0.7 sdist from PR Replaced pkg_resources #12 (which removedimport pkg_resourcesbut leftpkg_resources.require(...)behind in three modules) is unambiguously superseded. PR Complete pkg_resources removal for Python 3.14 + dependency/CI cleanup #15 fixed the regression on master but kept the same version string; bumping resolves that ambiguity for installers.libagent/util.py— newformat_versions(agent_package)helper that catchesmetadata.PackageNotFoundErrorand degrades to(version unknown)for source-checkout development.libagent/age/__init__.py,libagent/gpg/__init__.py,libagent/ssh/__init__.py— three duplicatedmetadata.distribution(...)blocks now callutil.format_versions(); strayfrom importlib import metadataimports removed.libagent/gpg/__init__.py— two stale commented-outlog.warning(...)blocks dropped.tox.ini—isort>=5→isort>=5,<7to prevent a future isort major from breaking the build..github/workflows/ci.yml—actions/checkout@v4andactions/setup-python@v5pinned to commit SHAs (v4.3.1/v5.6.0) so a compromised tag can't push code into a hardware-key project's CI.Deliberately not in this PR
setup.pyplatforms=['POSIX']and the POSIX classifier — left alone.gpg/__init__.pystill shells out tomkdir -p/chmodand generates a#!/bin/shrun-agent script, so claiming OS-independent on master would advertise support that doesn't actually work. Belongs with the Windows-native runtime work in Sync with upstream trezor-agent; preserve OnlyKey features + add native Windows #16, not as housekeeping.os.environ['AGENTHOMEDIR']coupling betweengpg/__init__.pyanddevice/onlykey.py— that's an architectural change worth doing separately.device/onlykey.py:pubkey()— pure refactor, not a defect.Verification
python3 -m py_compileon every touched file — passes.python3 -m pyflakes— no new warnings versus master (only line numbers shifted for pre-existing unused imports the recent lint cleanup didn't tackle).ECC1,ECC16,RSA2, plain132, multi-line shell-continuation form, and missing-flags — all return the expected slot.