Refuse a manifest entry whose mode is above 0777 on load (closes #225) #230

Merged
clawbot merged 1 commits from issue-225-refuse-mode-above-0777 into next 2026-10-15 22:02:55 +02:00
Collaborator

Implements #225.

Loading a manifest now refuses an entry that records a mode above 0777, naming the path and the mode. The check sits beside the path and hash checks in deserializeInner (mfer/deserialize.go). Before, such a manifest loaded: check reported a file with exactly the recorded permission bits as MODE_MISMATCH, and freshen rewrote the mode as the permission bits alone without saying so. Now check, list, export, freshen and fetch all refuse it with one message, for example file entry has a mode above 0777: "a.txt" (04755).

fetchManifest (internal/cli/fetch.go) had its own check for this, which loading now makes first, so it is removed. Its test moves to TestDeserializeRefusesModeOutsidePermissionBits in the existing mfer/deserialize_path_test.go (package mfer), with both of its cases (04755, and setuid as Go keeps it in os.FileMode) and a third showing that 0777 loads. No new files.

docs/FORMAT.md File Mode now says a reader must reject a mode above 0777, instead of listing the refusal under fetch alone.

Not in the diff: downloadFile and alreadyPresent still use only the permission bits of a recorded mode, so TestDownloadFileSetsOnlyPermissionBits, which hands downloadFile an entry directly, stays. The README.md sentence saying fetch refuses such a manifest before downloading any file is still true and unchanged. No test fixture or fuzz seed records such a mode.

Judgement call: the error value keeps the name it had in fetch, errModeOutOfRange, and takes the wording of the other file entry errors.

Model: opus-5-5

Implements https://git.eeqj.de/sneak/mfer/issues/225. Loading a manifest now refuses an entry that records a mode above `0777`, naming the path and the mode. The check sits beside the path and hash checks in `deserializeInner` (`mfer/deserialize.go`). Before, such a manifest loaded: `check` reported a file with exactly the recorded permission bits as `MODE_MISMATCH`, and `freshen` rewrote the mode as the permission bits alone without saying so. Now `check`, `list`, `export`, `freshen` and `fetch` all refuse it with one message, for example `file entry has a mode above 0777: "a.txt" (04755)`. `fetchManifest` (`internal/cli/fetch.go`) had its own check for this, which loading now makes first, so it is removed. Its test moves to `TestDeserializeRefusesModeOutsidePermissionBits` in the existing `mfer/deserialize_path_test.go` (package `mfer`), with both of its cases (`04755`, and setuid as Go keeps it in `os.FileMode`) and a third showing that `0777` loads. No new files. `docs/FORMAT.md` File Mode now says a reader must reject a mode above `0777`, instead of listing the refusal under `fetch` alone. Not in the diff: `downloadFile` and `alreadyPresent` still use only the permission bits of a recorded mode, so `TestDownloadFileSetsOnlyPermissionBits`, which hands `downloadFile` an entry directly, stays. The `README.md` sentence saying `fetch` refuses such a manifest before downloading any file is still true and unchanged. No test fixture or fuzz seed records such a mode. Judgement call: the error value keeps the name it had in `fetch`, `errModeOutOfRange`, and takes the wording of the other file entry errors. Model: opus-5-5
clawbot added 1 commit 2026-10-15 21:39:36 +02:00
Loading accepted an entry recording a mode above 0777, such as 04755.
check then reported a file with exactly the recorded permission bits
as a mode mismatch, list and export printed the out-of-range mode, and
freshen silently rewrote it as the permission bits alone. Loading now
refuses such an entry, naming the path and the mode, so every command
that reads a manifest refuses it with one message. fetch's own check
for this could no longer be reached and is gone; its test moves to the
loading tests in package mfer. docs/FORMAT.md says readers reject a
mode above 0777.

Model: opus-5-5
clawbot added the needs-review label 2026-10-15 21:39:40 +02:00
clawbot self-assigned this 2026-10-15 21:39:40 +02:00
Author
Collaborator

Review passed.

Judgement call: the README.md sentence under mfer fetch saying a manifest recording a mode above 0777 is refused before any file is downloaded stays as it is. It is still true, and README.md lists no other load refusal under any command.
Judgement call: the error value name errModeOutOfRange is plain where it now lives, and its message has the same form as the other file entry errors.

Model: opus-5-5

Review passed. Judgement call: the `README.md` sentence under `mfer fetch` saying a manifest recording a mode above `0777` is refused before any file is downloaded stays as it is. It is still true, and `README.md` lists no other load refusal under any command. Judgement call: the error value name `errModeOutOfRange` is plain where it now lives, and its message has the same form as the other file entry errors. Model: opus-5-5
clawbot merged commit 31e22a9337 into next 2026-10-15 22:02:55 +02:00
clawbot deleted branch issue-225-refuse-mode-above-0777 2026-10-15 22:02:55 +02:00
Sign in to join this conversation.