Commit ec358ab
committed
backup: PR810 r4 — codex r4 P2 + gemini r1 mediums
Three remaining reviewer findings on PR #810 (one P2, two
mediums) that the prior rounds did not address. None is a
fail-closed semantic change; together they tighten the
CHECKSUMS on-disk format and the cmd's manifest write path
against operational shapes the design promises to support.
1. (codex r4 P2) WriteChecksums wrote filenames verbatim into a
newline-delimited file. A path containing `\n`, `\r`, or `\\`
would corrupt the line-based output and let a single
adversarial entry inject a second CHECKSUMS row that the
verifier would accept.
Fix: formatChecksumLine implements the GNU coreutils
sha256sum(1) escape convention — leading `\` on the line
plus `\n` / `\r` / `\\` substitutions. splitChecksumLine
reverses the convention via unescapeChecksumPath at parse
time. `sha256sum -c CHECKSUMS` from the dump root parses
both forms identically, preserving the vendor-independent
recovery property.
Tests:
- TestChecksumLine_EscapeRoundTrip — five paths covering
`\n`, `\r`, `\\`, multiple escapes mixed, and the
no-escape passthrough.
- TestChecksumLine_EscapePrefixMatchesGNUFormat — pins the
exact `\` + hex + ` ` + escaped-body shape so a future
change cannot drift from sha256sum compatibility.
- TestSplitChecksumLine_RejectsDanglingEscape — guards
against a tampered CHECKSUMS using `\<EOL>` or `\x` for
unknown `x`.
2. (gemini r1 medium, main.go:281) emitManifest concatenated
`cfg.outputRoot + "/MANIFEST.json"`. On Windows this
produces wrong path separators and would refuse a
Windows-style output root.
Fix: filepath.Join. Standard cross-platform shape.
3. (gemini r1 medium, main.go:285) emitManifest deferred a
`_ = out.Close()` that swallowed the Close error. On NFS /
FUSE filesystems Close is the authoritative durability
signal (writeback errors surface there, not at Write time),
so a silently-discarded Close error means the dump-tree
invariant (MANIFEST.json on disk) can fail without the cmd
surfacing it.
Fix: explicit Sync() then Close() with both errors
propagated; the defer'd close on error paths runs through
`_ = out.Close()` because we have already surfaced the
primary failure.
Caller audit:
- formatChecksumLine / unescapeChecksumPath are new helpers
called only from WriteChecksums / splitChecksumLine. No
cross-package use.
- splitChecksumLine's exported behavior is rejection-side
tightening (dangling escape) plus correct round-trip of
escape-needing paths. No production caller of VerifyChecksums
exists (test-only).
- emitManifest is internal to cmd/elastickv-snapshot-decode.
The Close-error surface is purely additive — previously-
successful runs stay successful.
Self-review:
1. Data loss — none; the new escape path PREVENTS data loss
(line injection); the Close-error surface PREVENTS silent
manifest-write loss on NFS.
2. Concurrency — none.
3. Performance — single Builder per escape-needing line; the
no-escape fast path is unchanged.
4. Data consistency — sha256sum(1) escape round-trip is
byte-identical (round-trip test pins it).
5. Test coverage — three new tests; existing seven CHECKSUMS
tests still pass.1 parent b05ec87 commit ec358ab
3 files changed
Lines changed: 191 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
278 | 279 | | |
279 | 280 | | |
280 | 281 | | |
281 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
282 | 285 | | |
283 | 286 | | |
284 | 287 | | |
285 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
286 | 299 | | |
| 300 | + | |
287 | 301 | | |
288 | 302 | | |
289 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
290 | 311 | | |
291 | 312 | | |
292 | 313 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
84 | 119 | | |
85 | 120 | | |
86 | 121 | | |
| |||
313 | 348 | | |
314 | 349 | | |
315 | 350 | | |
316 | | - | |
317 | | - | |
318 | | - | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
319 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
320 | 367 | | |
321 | 368 | | |
322 | 369 | | |
| |||
332 | 379 | | |
333 | 380 | | |
334 | 381 | | |
335 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
336 | 421 | | |
337 | 422 | | |
338 | 423 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
311 | 388 | | |
312 | 389 | | |
313 | 390 | | |
| |||
0 commit comments