Skip to content

Verify XMODEM downloads against advertised MD5#675

Draft
righteousgambit wants to merge 1 commit into
Carvera-Community:developfrom
righteousgambit:agent/verify-xmodem-download-md5
Draft

Verify XMODEM downloads against advertised MD5#675
righteousgambit wants to merge 1 commit into
Carvera-Community:developfrom
righteousgambit:agent/verify-xmodem-download-md5

Conversation

@righteousgambit

Copy link
Copy Markdown

Closes #666

What changed

  • Retain the whole-file MD5 advertised by XMODEM block zero.
  • Hash each actual, unpadded payload slice as it is written.
  • At EOT, keep the existing ACK behavior but reject the local artifact with None when the advertised digest is absent or does not match.
  • Normalize hexadecimal digest comparisons so an uppercase local MD5 still takes the existing cache shortcut.
  • Add deterministic tests for a matching transfer, a prematurely terminated/truncated transfer, and the uppercase-local-MD5 shortcut (0, empty output, three CAN writes).
  • Document the integrity fix in the changelog.

Protocol compatibility

The receiver continues to ACK EOT on the wire. The behavioral change is local: a transfer whose bytes do not match the machine-advertised MD5 is no longer reported as successful to download_file().

Validation

Pinned develop (2ea66c10e96d88013a04441134d3d4f8e8c88510) against the new tests:

2 failed, 1 passed

The truncated-transfer assertion observes 8192 instead of None; the uppercase-local-MD5 test observes a completed transfer instead of the cache short-circuit.

Corrected implementation:

3 passed

Quality checks:

ruff check carveracontroller/XMODEM.py tests/unit/test_xmodem_download_integrity.py
ruff format --check carveracontroller/XMODEM.py tests/unit/test_xmodem_download_integrity.py
python -m compileall -q carveracontroller/XMODEM.py tests/unit/test_xmodem_download_integrity.py
git diff --check HEAD^ HEAD

Real branch verification

The repository's locked Poetry environment was installed from poetry.lock. The targeted suite passed on real fork commit f96ceccf1615, whose sole parent is pinned upstream develop@2ea66c10e96d88013a04441134d3d4f8e8c88510.

poetry run python -m pytest -q tests/unit/test_xmodem_download_integrity.py

Result: 3 passed.

Quality gates on the real branch:

  • Ruff check: passed
  • Ruff format --check: passed
  • git diff --check 2ea66c10e96d88013a04441134d3d4f8e8c88510..f96ceccf161516a5e02c2eb995b1b7661aba644b: passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant