fix: dossier hardening -- loud missing-lib guard, key-syntax alignment, whitespace trimming #466

Closed
opened 2026-08-09 00:49:01 +00:00 by igor · 0 comments
Collaborator

Follow-up to #465 (dossier parser), from the shadow review's final round -- three small hardening items in lib/dossier.sh / lib/repo-checks.sh:

  1. Make the missing-lib case loud. check_dossier's defensive *) arm documents that it catches "lib/dossier.sh not sourced -> 127", but it is unreachable for that case: dossier_is_declared "$content" || return 2 swallows the 127 (command-not-found) into rc2, the silent legacy path -- exactly the dead-gate outcome the arm was added to prevent. Fix: at the top of check_dossier, declare -F dossier_validate >/dev/null || { ...stderr warning...; return 3; } (or similar distinct status the *) arm actually receives). Correct the arm's comment to match reality.
  2. Align key-syntax between reader and validator. dossier_keys accepts leading whitespace (sed -nE 's/^[[:space:]]*([a-z][a-z-]*):...') while dossier_get (grep -E "^${key}:") and _dossier_validate_metadata (^([a-z][a-z-]*):) reject it -- an indented key is listed but unreadable. Pick the strict form everywhere (no leading whitespace; the validator's rule is the spec).
  3. Trim before comparing, and keep error messages honest. type: arcade (two spaces) fails the closed-list check with a message that prints the padded value and reads as a mystery; same for a double-spaced H1 in the host comparison. Trim the extracted value and H1 name before comparison so near-miss whitespace either passes or fails with an obvious reason.

Tests: extend bin/test-dossier.sh -- unsourced-lib guard (subshell without lib/dossier.sh), indented-key fixture asserting reader/validator agreement, and the two-space type: / H1 cases asserting the post-trim behavior.

All three are latent (no live caller hits them today) -- priority low, no rush.

Follow-up to #465 (dossier parser), from the shadow review's final round -- three small hardening items in `lib/dossier.sh` / `lib/repo-checks.sh`: 1. **Make the missing-lib case loud.** `check_dossier`'s defensive `*)` arm documents that it catches "lib/dossier.sh not sourced -> 127", but it is unreachable for that case: `dossier_is_declared "$content" || return 2` swallows the 127 (command-not-found) into rc2, the silent legacy path -- exactly the dead-gate outcome the arm was added to prevent. Fix: at the top of `check_dossier`, `declare -F dossier_validate >/dev/null || { ...stderr warning...; return 3; }` (or similar distinct status the `*)` arm actually receives). Correct the arm's comment to match reality. 2. **Align key-syntax between reader and validator.** `dossier_keys` accepts leading whitespace (`sed -nE 's/^[[:space:]]*([a-z][a-z-]*):...'`) while `dossier_get` (`grep -E "^${key}:"`) and `_dossier_validate_metadata` (`^([a-z][a-z-]*):`) reject it -- an indented key is listed but unreadable. Pick the strict form everywhere (no leading whitespace; the validator's rule is the spec). 3. **Trim before comparing, and keep error messages honest.** `type: arcade` (two spaces) fails the closed-list check with a message that prints the padded value and reads as a mystery; same for a double-spaced H1 in the host comparison. Trim the extracted value and H1 name before comparison so near-miss whitespace either passes or fails with an obvious reason. Tests: extend `bin/test-dossier.sh` -- unsourced-lib guard (subshell without `lib/dossier.sh`), indented-key fixture asserting reader/validator agreement, and the two-space `type:` / H1 cases asserting the post-trim behavior. All three are latent (no live caller hits them today) -- priority low, no rush.
igor self-assigned this 2026-08-09 00:50:29 +00:00
igor added spent time 2026-08-09 00:57:46 +00:00
6 minutes 57 seconds
igor removed their assignment 2026-08-09 00:57:46 +00:00
igor closed this issue 2026-08-09 02:04:42 +00:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Total time spent: 6 minutes 57 seconds
igor
6 minutes 57 seconds
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
joshtronic/igor#466
No description provided.