fix: harden dossier parser -- loud missing-lib guard, strict key syntax, whitespace trimming #468
No reviewers
Labels
No labels
Agent
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No assignees
1 participant
Notifications
Total time spent: 6 minutes 31 seconds
Due date
igor
6 minutes 31 seconds
No due date set.
Dependencies
No dependencies set
Reference
joshtronic/igor!468
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/466-fix-dossier-hardening-loud-missing-lib-guard-key"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this PR does
check_dossiernow guards ondeclare -F dossier_validateup front and returns a distinct rc3 (with a stderr warning) whenlib/dossier.shwasn't sourced, instead of the 127 silently folding into rc2's legacy path. Corrected the*)arm's comment invalidate_repo_localto match.dossier_keys' key-matching regex no longer accepts leading whitespace, aligning it withdossier_getand_dossier_validate_metadata(an indented key is no longer listed as readable when neither of those can actually read it)._dossier_validate_metadatatrims the extractedkey: valueand the H1 name before comparing against the closed type list / url host, so near-miss whitespace (e.g.type: arcade,# porksicle.com) either passes cleanly or fails with an untrimmed-free, honest reason.Test plan
make testpasses (extendedbin/test-dossier.sh: unsourced-lib guard via a subshell withoutlib/dossier.sh, an indented-key fixture assertingdossier_get/dossier_keys/dossier_validateagreement, and two-spacetype:/ H1 cases asserting post-trim pass/fail behavior)make lintpasses (shellcheck + mdl clean)Closes #466
🤖 Review —
COMMENT(automated)CI for
85201185: successSmall, focused hardening of the dossier parser (three items, all matching issue #466): loud rc3 guard in
check_dossier, strict key regex indossier_keys, and trim-before-compare in_dossier_validate_metadata. CI green, description checklist matches the diff item-for-item, tests added for each of the three behaviors. Nothing here blocks, but one design consequence deserves a human's eye before merge.Main reservation — value trimming may open a new reader/validator divergence
lib/dossier.sh:196now acceptstype: arcade␠␠/type:␠␠arcadeas valid by trimming before comparison. Item 2 of the issue was precisely about "listed as readable but not actually readable" mismatches — this change moves the same class of mismatch from the key dimension to the value dimension: a dossier that validates can now carry padded values, anddossier_get(not in this diff) may return them untrimmed to callers who then do[ "$(dossier_get "$p" type)" = arcade ].dossier_validatepasses ontype:␠␠arcade(bin/test-dossier.sh:102); it never asserts whatdossier_getreturns for that same fixture. Contrast with the indented-key block right below, which correctly asserts three-way agreement (dossier_get/dossier_keys/dossier_validate).dossier_get's value extraction strips both leading and trailing whitespace, and if so add the assertion (eq "…" "arcade" "$(dossier_get "$D" type)"against a padded fixture) so the alignment is pinned by a test rather than by inspection. If it doesn't strip,dossier_getneeds the same_dossier_trim.Minor notes (non-blocking)
lib/dossier.sh:213:${h1#\# }→${h1#\#}+ trim also makes#porksicle.com(no space) compare equal to the host. Harmless if the H1 extractor requires^#[[:space:]], which I can't see from the diff — worth a glance.lib/repo-checks.sh:321: rc3 is now an expected status but still falls through to the*)arm printing "returned an unexpected status", producing two stderr lines for the same condition. The comment acknowledges this deliberately; an explicit3) :;arm (the warning already fired incheck_dossier) would read cleaner. Also note rc3 still does not incrementfail, so a dead gate remains warn-only — consistent with prior behavior and with the issue, just flagging it's intentional.check_dossierfrom this diff. Previously an unsourced lib always collapsed to rc2; any caller elsewhere doingcase $? in 0|2) ok;; *) fail;;will now hard-fail. That's the intent of the change, but worth agrepfor callers outsidevalidate_repo_local.Good
_dossier_trimimplementation handles the all-whitespace and empty-string cases correctly.lib/repo-checks.sh) is the right shape and asserts both rc and the stderr text.Independent review by the harness on
claude-opus-5(effort: high). The human reviewer is requested once Igor has reviewed; a human still merges.Adjudication (Igor/CoS): the review's main reservation is CONFIRMED as a real bug, verified empirically against this branch:
A dossier the validator certifies as conforming now yields a PADDED value from the reader --
[ "$(dossier_get . type)" = "arcade" ]is false, and a paddedurl:would reach curl with embedded spaces. This is the reader/validator value divergence the ticket meant to close.Requested change (one item): apply
_dossier_trimtodossier_get's extracted value, and add the reviewer's three-way agreement assertion on a padded fixture (dossier_get/dossier_keys/dossier_validateall agree ontype: arcade).The review's two minor notes are verified non-issues: the H1 extractor requires
^#[[:space:]](no-space#hostcan't reach the comparison), andcheck_dossierhas no callers outsidevalidate_repo_local+ tests. The optional explicit3) ;;arm is nice-to-have; take it or leave it.The agent reopened this PR after reassignment but didn't make any new commits. Either the feedback was answerable without code changes, or the agent couldn't act on it. Review requested so a human can close the loop.
Re-queueing for rework (Igor/CoS). The previous round produced no commits, but the finding is CONFIRMED and unfixed on this head -- do not dismiss it, fix it:
The one required change: in
lib/dossier.sh,dossier_getmust trim the extracted value (leading AND trailing whitespace) before echoing -- use the existing_dossier_trimhelper. Reproduced on this exact head:And the one required test: a padded fixture (
type: arcade) asserting three-way agreement --dossier_validatepasses,dossier_keysliststype, anddossier_getreturns exactlyarcade.Nothing else. Do not rework any other part of the PR.
🔧 Rework — round 0 (automated)
Addressed the review on
claude-opus-5at effort high — 6 new commit(s).