- internal/{address,identity,protocol,tce,transport,verify} -> pkg/ so
external Go projects can import the verified core; invariant tests
updated for the new paths
- Config.TrustProxy: key rate limiting by X-Forwarded-For when the relay
sits behind a reverse proxy (off by default, header never trusted
otherwise)
- examples/service + examples/approve: complete passwordless login round
trip (mint request -> wallet approves -> local verify), run live in CI
- docs/SERVICE-GUIDE.md: the integration recipe
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
//go:build gofuzz
|
|
|
|
package tce
|
|
|
|
// Fuzz is the OSS-Fuzz entry point for the primitive TCE codec. It asserts two
|
|
// totality properties of PROTOCOL.md section 12.4 against arbitrary input:
|
|
//
|
|
// - the decoder never panics, hangs or returns a usable object alongside an
|
|
// error (totality); the decoder is walked field by field and each read
|
|
// ignores its result;
|
|
// - CanonicalNumber (section 5.1) is total over arbitrary text and only ever
|
|
// produces an already-canonical token, so a malformed number is rejected
|
|
// rather than silently accepted.
|
|
//
|
|
// The function is compiled only under the "gofuzz" build tag (go-fuzz /
|
|
// OSS-Fuzz). Under that tag the Go test files are excluded, so there is no
|
|
// clash with the testing.F-based fuzz targets in the package.
|
|
func Fuzz(data []byte) int {
|
|
d := NewDecoder(data)
|
|
_, _ = d.Header()
|
|
_, _ = d.Uvarint()
|
|
_, _ = d.String(1 << 20)
|
|
_, _ = d.Map(0)
|
|
_, _ = d.Timestamp(true)
|
|
_, _ = d.Identity()
|
|
|
|
// Signal interesting inputs that survive canonicalization, guiding the
|
|
// fuzzer toward the number parser's branches.
|
|
if c, err := CanonicalNumber(string(data)); err == nil && IsCanonicalNumber(c) {
|
|
return 1
|
|
}
|
|
return 0
|
|
}
|