Repository navigation
Holes first: fail closed under serde_json arbitrary_precision; no CLI panic on unwritable stderr - #50
Draft
hyperpolymath wants to merge 1 commit into
Draft
hyperpolymath wants to merge 1 commit into
hyperpolymath wants to merge 1 commit into
Conversation
…ble stderr
Two holes found reading the code against verification/PROOF-STATUS.adoc.
1. Cargo feature unification. When another crate in the graph enables
serde_json/arbitrary_precision, serde_json hands non-integer and
out-of-range numbers to a generic visitor as a one-member object keyed
$serde_json::private::Number. The strict readers then canonicalised
[1.5] to [{"$serde_json::private::Number":"1.5"}] and accepted 1e400.
The strict readers now probe once and refuse to parse in that build.
tests/feature_unification.rs holds in both configurations and CI runs
it with the feature forced on.
2. The CLI used eprintln!, which panics when stderr cannot be written,
so a refusal exited 101 instead of the documented 2. Diagnostics are
now best-effort writes.
Coverage exclusions are re-bound to the moved lines; the entry for
Visitor::expecting is dropped because the line is no longer instrumented.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDfneftEg71bUadt3v3
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
❌ The last analysis has failed. |
|
Review these changes at https://app.gitnotebooks.com/hyperpolymath/ijson-jcs/pull/50 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Holes-first deliverable for the beta track. Two defects found by reading the code against
verification/PROOF-STATUS.adoc, each with a must-fail test and a fix. No proof is claimed here; the evidence isTESTED.Hole 1: wrong canonical output and accepted non-I-JSON under Cargo feature unification
If any crate in a consumer's dependency graph enables
serde_json/arbitrary_precision, Cargo turns it on for this crate too. serde_json then passes non-integer and out-of-range numbers to a genericVisitoras a one-member object keyed$serde_json::private::Number. Observed onmain(67b89d9) in a scratch crate with that feature:main[1.5]parse_jsonStrict/Canonical,parse_jcs,canonicalize_bytes[{"$serde_json::private::Number":"1.5"}]1e400-0,1.0,1e-400A generic visitor cannot tell that marker from a real object with the same key, so the strict readers now probe once and refuse to parse in such a build (
require_binary64_number_modelinsrc/strict.rs).to_jcson a caller-builtValueandJsonMode::Looseare unchanged; I probed them with the feature on and saw no wrong output, but that is a handful of probes, not a claim.Hole 2: CLI panic (exit 101) when stderr is unwritable
eprintln!panics if stderr cannot be written.ijson-jcs canon 2>/dev/fullon invalid input, and any usage error, exited 101 instead of the documented 2. Diagnostics are now best-effort writes; the exit status carries the verdict.Evidence
Toolchain: rustc/cargo 1.99.1 (pinned in
rust-toolchain.toml), Linux x86_64. cargo-llvm-cov 0.9.2.cargo test --locked --test feature_unification --features serde_json/arbitrary_precisioncargo test --locked --test feature_unificationcargo test --locked --test cli stderr_writeleft: Some(101) right: Some(2)cargo test --locked --all-featurescargo clippy --locked --all-targets --all-features -- -D warningscargo fmt --all -- --checkNot run: the MSRV (1.85.0) job, macOS and Windows. CI covers them. The stderr test is Linux-only (
/dev/full).CI gains one step, "Feature-unification control", which runs the new test with the feature forced on, so the fail-closed branch is executed on every pull request.
Coverage gate: already red on
main, not fixed herescripts/proven-coverage.shexits 1 on unmodifiedmain:parse_jcs(src/lib.rs204-209), the twoBINARY64visitor branches andfrom_str_binary64are not reached by the counted suites, and twosrc/strict.rsexclusions were stale. No workflow in this repository runs that gate. This PR re-binds the exclusions for the lines it moved, adds oneenvironmentexclusion for the fail-closed branch, and drops theVisitor::expectingentry (no longer instrumented). The remaining 15 uncovered lines are all the pre-existingparse_jcspath and need counted tests, which belong to the test-needs thread.Row census
Denominator: the 7 obligation rows of the
parse_jcsplan table inPROOF-STATUS.adoc. This PR changes the status of 0 of 7. It adds evidence under "No panic on any input" (CLI path only) and exposes an assumption not yet in the ledger: serde_json's number model depends on features this crate does not control. The ledger edit comes with the proof PRs.For the owner to rule
Recommended and implemented: fail closed (most correct; no silent change of meaning). Alternatives: (a) reject the marker key inside
visit_mapwith no global probe, which is simpler to verify but refuses a legitimate object key in normal builds; (b) supportarbitrary_precisionby parsing numbers from the marker string, which widens the trusted surface. This class of defect (a generic serde visitor overserde_json::Deserializer) may exist in other estate crates and is worth a sweep beyond this repository.Generated by Claude Code