From e0bc45854388e219daab8f57939859d204f31897 Mon Sep 17 00:00:00 2001 From: Oscar Sanderson Date: Fri, 27 Nov 2026 19:00:37 +0800 Subject: [PATCH] test(federation): compare merged metadata numbers as written in the fuzz oracle FuzzApplySuperiorMetadata compared values by decoding them into any, so a number outside float64's range (2 followed by 308 zeros, found by the nightly fuzz run on 2026-11-23) failed to decode and compared unequal to itself, though applySuperiorMetadata carried it through unchanged. The oracle now keeps numbers as json.Number text, and the failing input joins the corpus. Co-Authored-By: Claude Opus 5.5 --- federation/federation_fuzz_test.go | 20 ++++++++++++++----- .../f651c9d02580235b | 3 +++ 2 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 federation/testdata/fuzz/FuzzApplySuperiorMetadata/f651c9d02580235b diff --git a/federation/federation_fuzz_test.go b/federation/federation_fuzz_test.go index 80ba76a0..e9f58de8 100644 --- a/federation/federation_fuzz_test.go +++ b/federation/federation_fuzz_test.go @@ -1,6 +1,7 @@ package federation import ( + "bytes" "context" "encoding/json" "net/url" @@ -326,11 +327,20 @@ func countNew(overrides, params map[string]json.RawMessage) int { func jsonValuesEqual(t *testing.T, a, b json.RawMessage) bool { t.Helper() - var av, bv any - if json.Unmarshal(a, &av) != nil || json.Unmarshal(b, &bv) != nil { - return false - } - return reflect.DeepEqual(av, bv) + av, aok := decodeExactJSON(a) + bv, bok := decodeExactJSON(b) + return aok && bok && reflect.DeepEqual(av, bv) +} + +// decodeExactJSON is raw decoded with its numbers kept as their text +// (json.Number), so a number outside float64's range, which encoding/json +// can't decode into a float64, still compares equal to the same number: +// applySuperiorMetadata carries a value through as written. +func decodeExactJSON(raw json.RawMessage) (any, bool) { + dec := json.NewDecoder(bytes.NewReader(raw)) + dec.UseNumber() + var v any + return v, dec.Decode(&v) == nil } // FuzzValidEntityID checks ValidEntityID against OpenID Federation 1.0 diff --git a/federation/testdata/fuzz/FuzzApplySuperiorMetadata/f651c9d02580235b b/federation/testdata/fuzz/FuzzApplySuperiorMetadata/f651c9d02580235b new file mode 100644 index 00000000..c14d322b --- /dev/null +++ b/federation/testdata/fuzz/FuzzApplySuperiorMetadata/f651c9d02580235b @@ -0,0 +1,3 @@ +go test fuzz v1 +string("{\"\":{\"\":{\"\":200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000}}}") +string("{\"\":{}}")