Artifact fe153b418548b20c2d800caa73ca08127485fcb98b9c20ef8374ff4b1490c250:
- File
conformance/artifact_gaps_test.go
— part of check-in
[1a15366e29]
at
2026-10-12 17:24:20
on branch main
— fix(deck): validate every artifact-hash and checksum position (#268) (#332)
The parser stored hash-bearing tokens without checking them, so an F, B, E, G, I, K, M, P, Q, A-source or T-target token of the wrong length or alphabet passed, and the A target and N mimetype were kept raw rather than decoded.
Validate each position against the §4.7.1 map: 40 or 64 case-insensitive hex for an artifact hash, 40 for the K-card ticket id, 32 for the R checksum. A baseline manifest now requires a hash on every F card; only a delta manifest (one with a B card) may carry a hashless deletion card. Decode the A target and the N mimetype per §4.3.1 and re-encode them on marshal, keep the other hash tokens raw, and keep only the final path component of the A filename. Reject a Q sign other than + or -, and a tag name that is entirely hex in either case.
Four internal/manifest crosslink tests built manifests fossil itself rejects -- two R cards 40 hex long (R is 32), an attachment source "abc123", and a baseline manifest with a hashless deletion card. Make those fixtures valid artifacts (32-hex R, a real source hash, the merge expressed as a delta off its primary parent so the deletion card is legal); the mlink and crosslink outcomes they assert are unchanged. (user: [email protected], size: 10415) [annotate] [blame] [check-ins using]
package conformance import "testing" // artifactGaps marks the artifact cases go-libfossil is known to fail, by // case ID, grouped by the code at fault, each with the issue tracking its fix. var artifactGaps = map[string]string{ // Marshal drops a present but empty C, N or T value, an empty P card and an // empty W body, so the artifact does not re-encode (deck/marshal.go:58, :149, // :153, :194, :205). "artifact.4.7.16.t-empty-value": "#272", "artifact.4.7.18.w-empty": "#272", "artifact.4.7.c-empty": "#272", "artifact.4.7.n-empty": "#272", "artifact.4.7.p-empty": "#272", // No pathname predicate on the A filename or the F filename and old-name // (deck/parse.go:215, :250). "artifact.4.6.1.a-double-slash": "#269", "artifact.4.6.1.a-leading-slash": "#269", "artifact.4.6.1.f-dot": "#269", "artifact.4.6.1.f-dot-element": "#269", "artifact.4.6.1.f-dot-prefix": "#269", "artifact.4.6.1.f-dot-tail": "#269", "artifact.4.6.1.f-dotdot": "#269", "artifact.4.6.1.f-dotdot-element": "#269", "artifact.4.6.1.f-dotdot-prefix": "#269", "artifact.4.6.1.f-dotdot-tail": "#269", "artifact.4.6.1.f-double-slash": "#269", "artifact.4.6.1.f-leading-slash": "#269", "artifact.4.6.1.f-trailing-slash": "#269", "artifact.4.6.1.old-name-dotdot-prefix": "#269", "artifact.4.6.1.old-name-leading-slash": "#269", // No wiki-name predicate on the L card or the A target (deck/parse.go:189, :220). "artifact.4.6.2.l-101-bytes": "#269", "artifact.4.6.2.l-double-space": "#269", "artifact.4.6.2.l-inner-lf": "#269", "artifact.4.6.2.l-inner-tab": "#269", "artifact.4.6.2.l-leading-space": "#269", "artifact.4.6.2.l-leading-tab": "#269", "artifact.4.6.2.l-trailing-space": "#269", "artifact.4.7.2.a-target-bad": "#269", // No reserved-filename drop (deck/parse.go:250). "artifact.4.6.3.drop-_fossil_": "#269", "artifact.4.6.3.drop-_FOSSIL_": "#269", "artifact.4.6.3.drop-.fslckout": "#269", "artifact.4.6.3.drop-.FSLCKOUT-SHM": "#269", "artifact.4.6.3.drop-a_FOSSIL_-wal": "#269", "artifact.4.6.3.drop-a/_FOSSIL_": "#269", "artifact.4.6.3.drop-a/.fslckout-journal": "#269", "artifact.4.6.3.drop-not-anchor": "#269", // parseTimestamp accepts only two time.Parse layouts, so the wider accepted // grammar is rejected, and it rewrites a lowercase t to T (deck/parse.go:420). "artifact.4.6.4.after-epoch": "#271", "artifact.4.6.4.double-separator": "#271", "artifact.4.6.4.e-lowercase-t": "#271", "artifact.4.6.4.hh-mm": "#271", "artifact.4.6.4.hour-24": "#271", "artifact.4.6.4.lowercase-t": "#271", "artifact.4.6.4.no-calendar-check": "#271", "artifact.4.6.4.tab-separator": "#271", "artifact.4.6.4.zone-lowercase-z": "#271", "artifact.4.6.4.zone-minus": "#271", "artifact.4.6.4.zone-plus": "#271", "artifact.4.6.4.zone-z": "#271", // Marshal writes D to the millisecond and E to the second, so a longer // fraction the parser accepted is lost (deck/marshal.go:63, :67). Found // by FuzzArtifactRoundTrip. "artifact.4.6.4.fraction-round-trip": "#272", "artifact.4.6.4.e-fraction-round-trip": "#272", // No card-legality table, required cards or per-type semantic checks: // inferType only picks a type (deck/parse.go:442). "artifact.5.2.attachment-illegal-B": "#273", "artifact.5.2.attachment-illegal-E": "#273", "artifact.5.2.attachment-illegal-F": "#273", "artifact.5.2.attachment-illegal-G": "#273", "artifact.5.2.attachment-illegal-H": "#273", "artifact.5.2.attachment-illegal-I": "#273", "artifact.5.2.attachment-illegal-J": "#273", "artifact.5.2.attachment-illegal-K": "#273", "artifact.5.2.attachment-illegal-L": "#273", "artifact.5.2.attachment-illegal-M": "#273", "artifact.5.2.attachment-illegal-P": "#273", "artifact.5.2.attachment-illegal-Q": "#273", "artifact.5.2.attachment-illegal-R": "#273", "artifact.5.2.attachment-illegal-T": "#273", "artifact.5.2.attachment-illegal-W": "#273", "artifact.5.2.attachment-no-D": "#273", "artifact.5.2.cluster-illegal-A": "#273", "artifact.5.2.cluster-illegal-B": "#273", "artifact.5.2.cluster-illegal-C": "#273", "artifact.5.2.cluster-illegal-D": "#273", "artifact.5.2.cluster-illegal-E": "#273", "artifact.5.2.cluster-illegal-F": "#273", "artifact.5.2.cluster-illegal-G": "#273", "artifact.5.2.cluster-illegal-H": "#273", "artifact.5.2.cluster-illegal-I": "#273", "artifact.5.2.cluster-illegal-J": "#273", "artifact.5.2.cluster-illegal-K": "#273", "artifact.5.2.cluster-illegal-L": "#273", "artifact.5.2.cluster-illegal-N": "#273", "artifact.5.2.cluster-illegal-P": "#273", "artifact.5.2.cluster-illegal-Q": "#273", "artifact.5.2.cluster-illegal-R": "#273", "artifact.5.2.cluster-illegal-T": "#273", "artifact.5.2.cluster-illegal-U": "#273", "artifact.5.2.cluster-illegal-W": "#273", "artifact.5.2.cluster-no-M": "#273", "artifact.5.2.control-illegal-A": "#273", "artifact.5.2.control-illegal-E": "#273", "artifact.5.2.control-illegal-G": "#273", "artifact.5.2.control-illegal-H": "#273", "artifact.5.2.control-illegal-I": "#273", "artifact.5.2.control-illegal-J": "#273", "artifact.5.2.control-illegal-K": "#273", "artifact.5.2.control-illegal-L": "#273", "artifact.5.2.control-illegal-M": "#273", "artifact.5.2.control-illegal-N": "#273", "artifact.5.2.control-illegal-W": "#273", "artifact.5.2.control-no-D": "#273", "artifact.5.2.control-no-T": "#273", "artifact.5.2.control-no-U": "#273", "artifact.5.2.event-illegal-A": "#273", "artifact.5.2.event-illegal-B": "#273", "artifact.5.2.event-illegal-F": "#273", "artifact.5.2.event-illegal-G": "#273", "artifact.5.2.event-illegal-H": "#273", "artifact.5.2.event-illegal-I": "#273", "artifact.5.2.event-illegal-J": "#273", "artifact.5.2.event-illegal-K": "#273", "artifact.5.2.event-illegal-L": "#273", "artifact.5.2.event-illegal-M": "#273", "artifact.5.2.event-illegal-Q": "#273", "artifact.5.2.event-illegal-R": "#273", "artifact.5.2.event-no-D": "#273", "artifact.5.2.event-no-E": "#273", "artifact.5.2.event-no-W": "#273", "artifact.5.2.forum-illegal-A": "#273", "artifact.5.2.forum-illegal-B": "#273", "artifact.5.2.forum-illegal-C": "#273", "artifact.5.2.forum-illegal-E": "#273", "artifact.5.2.forum-illegal-F": "#273", "artifact.5.2.forum-illegal-J": "#273", "artifact.5.2.forum-illegal-K": "#273", "artifact.5.2.forum-illegal-L": "#273", "artifact.5.2.forum-illegal-M": "#273", "artifact.5.2.forum-illegal-Q": "#273", "artifact.5.2.forum-illegal-R": "#273", "artifact.5.2.forum-illegal-T": "#273", "artifact.5.2.forum-no-D": "#273", "artifact.5.2.forum-no-U": "#273", "artifact.5.2.forum-no-W": "#273", "artifact.5.2.manifest-illegal-A": "#273", "artifact.5.2.manifest-illegal-E": "#273", "artifact.5.2.manifest-illegal-G": "#273", "artifact.5.2.manifest-illegal-H": "#273", "artifact.5.2.manifest-illegal-I": "#273", "artifact.5.2.manifest-illegal-J": "#273", "artifact.5.2.manifest-illegal-K": "#273", "artifact.5.2.manifest-illegal-L": "#273", "artifact.5.2.manifest-illegal-M": "#273", "artifact.5.2.manifest-illegal-W": "#273", "artifact.5.2.manifest-no-D": "#273", "artifact.5.2.ticket-illegal-A": "#273", "artifact.5.2.ticket-illegal-B": "#273", "artifact.5.2.ticket-illegal-C": "#273", "artifact.5.2.ticket-illegal-E": "#273", "artifact.5.2.ticket-illegal-F": "#273", "artifact.5.2.ticket-illegal-G": "#273", "artifact.5.2.ticket-illegal-H": "#273", "artifact.5.2.ticket-illegal-I": "#273", "artifact.5.2.ticket-illegal-L": "#273", "artifact.5.2.ticket-illegal-M": "#273", "artifact.5.2.ticket-illegal-N": "#273", "artifact.5.2.ticket-illegal-P": "#273", "artifact.5.2.ticket-illegal-Q": "#273", "artifact.5.2.ticket-illegal-R": "#273", "artifact.5.2.ticket-illegal-T": "#273", "artifact.5.2.ticket-illegal-W": "#273", "artifact.5.2.ticket-no-D": "#273", "artifact.5.2.ticket-no-J": "#273", "artifact.5.2.ticket-no-K": "#273", "artifact.5.2.ticket-no-U": "#273", "artifact.5.2.wiki-illegal-A": "#273", "artifact.5.2.wiki-illegal-B": "#273", "artifact.5.2.wiki-illegal-E": "#273", "artifact.5.2.wiki-illegal-F": "#273", "artifact.5.2.wiki-illegal-G": "#273", "artifact.5.2.wiki-illegal-H": "#273", "artifact.5.2.wiki-illegal-I": "#273", "artifact.5.2.wiki-illegal-J": "#273", "artifact.5.2.wiki-illegal-K": "#273", "artifact.5.2.wiki-illegal-M": "#273", "artifact.5.2.wiki-illegal-Q": "#273", "artifact.5.2.wiki-illegal-R": "#273", "artifact.5.2.wiki-illegal-T": "#273", "artifact.5.2.wiki-no-D": "#273", "artifact.5.2.wiki-no-L": "#273", "artifact.5.2.wiki-no-U": "#273", "artifact.5.2.wiki-no-W": "#273", "artifact.5.3.latest-setter-illegal": "#273", "artifact.5.4.control-self": "#273", "artifact.5.4.event-cancel": "#273", "artifact.5.4.event-external-tag": "#273", "artifact.5.4.event-propagating": "#273", "artifact.5.4.forum-many-parents": "#273", "artifact.5.4.forum-title-reply": "#273", } // TestArtifactGapKeys checks that every marked case exists, and that every // loss the fuzz test forgives is still a marked gap. func TestArtifactGapKeys(t *testing.T) { ids := map[string]bool{} for _, c := range artifactSuiteCases() { ids[c.ID] = true } for id := range artifactGaps { if !ids[id] { t.Errorf("artifactGaps names %s, which is not a case", id) } } for _, loss := range knownLosses { if artifactGaps[loss.caseID] == "" { t.Errorf("FuzzArtifactRoundTrip forgives %s, which is no longer a gap; "+ "remove it from knownLosses", loss.caseID) } } }