Skip to content

Fixed two spots that failed toward the permissive answer - #73

Merged
kridaydave merged 1 commit into
mainfrom
fix/drift-9-12-fail-closed-on-discarded-errors
Oct 11, 2026
Merged

kridaydave merged 1 commit into
mainfrom
fix/drift-9-12-fail-closed-on-discarded-errors

Conversation

@kridaydave

Copy link
Copy Markdown
Contributor

PR made by step-5-preview from opencode on behalf of Kriday.

Two Low-severity drift entries from the repo's own drift table, both the same shape: code that spotted something wrong and produced a value that looked fine anyway.

hex_to_bytes mapped an unparseable hex pair to 0 and carried on, so a corrupt digest still rendered as a well-formed SRI string. The only place such a digest ever surfaced was the mismatch message naming the expected value, which meant an operator got a confident looking digest with bytes silently zeroed. It is fallible now, and to_sri returns a Result for the same reason.

Three permission hardening steps in store.rs were written as let _ =, so their failures were invisible. The pre-create at 0o600 was the load-bearing one. Connection::open creates the database file at whatever the umask allows, so when the pre-create failed the database still came up, just at a default mode. The step whose whole job was narrowing it had failed without saying so. All three propagate now.

Summary:

  • hex_to_bytes refuses a digest that is not clean hex instead of mapping a bad pair to byte 0
  • Checksum::to_sri returns Result, so the decode failure has somewhere to go
  • The three let _ = permission steps in store.rs now propagate: the 0o700 directory chmod, the 0o600 pre-create, and the 0o600 database chmod
  • Both fixes pinned by tests that were reverted and re-run to confirm they fail without the fix

No behaviour change on the success path. The modes were already being set and the honest digests already round-tripped. Only the failure handling was missing, and enforces_unix_file_and_directory_permissions still pins the resulting modes.

Mutation testing over both changed files found three survivors, all in code this change does not touch: audit_entries, default_db_path, and the sha512 length guard in parse_token. All three are pre-existing and untested. Recorded in the drift notes rather than folded in here.

Toolchain caveat: there is no rustup on this machine, so rust-toolchain.toml is inert and the local gate ran on system rustc 1.98.1 rather than the pinned 1.97.1. A green local run here is necessary, not sufficient.

…y gave up

Two Low-severity drift entries, both the same shape: code that noticed something
wrong and produced a value that looked fine anyway.

`hex_to_bytes` mapped an unparseable hex pair to `0` and carried on. That is the
fail-toward-valid-looking direction, and it rendered as a well-formed SRI string.
The only place a digest was ever shown was the mismatch message naming the
expected value, so a corrupt or hand-edited digest came back as a confident
looking digest with bytes silently zeroed. It is fallible now, and `to_sri`
returns a Result for the same reason. The reachability is via direct struct
construction, not `Checksum::parse`, which validates its hex on the way in;
that is now a test rather than an assumption.

Three permission-hardening steps in `store.rs` were `let _ =`: the data-directory
chmod to 0o700, the pre-create of the database at 0o600, and the database chmod
to 0o600. All three propagate now. The pre-create was the load-bearing one:
`Connection::open` creates the file at whatever the umask allows, so when the
pre-create failed the database came up at a default mode and the step whose
whole job was narrowing it had failed in silence.

No change on the success path. The modes were always being set; only the
failure handling was missing, and `enforces_unix_file_and_directory_permissions`
still pins the resulting modes.

Mutation testing over both changed files found three survivors, all in code this
change does not touch (`audit_entries`, `default_db_path`, and the sha512 length
guard in `parse_token`, all pre-existing and untested). Recorded in the drift
notes for whoever picks those up.

Commit made by Step 5 Preview Free in OpenCode on behalf of Kriday.
@kridaydave
kridaydave merged commit 93520de into main Oct 11, 2026
42 checks 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