v1.143.0
This release reworks pkg/filter for a ~4x evaluation speedup and secure-by-default input limits, with a smaller public API. It also refactors the example service startup wiring. It contains breaking changes in pkg/filter.
⚠️ Breaking changes (pkg/filter)
- The package-level
ParseJSONfunction, theEvaluatorinterface, and theRule.Evaluatemethod are no longer exported.Ruleis now a pure data struct, and untrusted input must be decoded via the size-limited entry pointsProcessor.ParseJSONorProcessor.ParseURLQuery. - New secure-by-default limits reject previously-accepted oversized inputs unless raised via the matching options: rule string/regexp values are capped at 4096 bytes (
WithMaxValueLength), JSON payloads at 64 KiB (WithMaxFilterBytes), and field-selector nesting at depth 32 (WithMaxFieldDepth). The number of OR groups in a rule set is also capped. - A
nilinterface slice element combined with a field selector is now filtered out (non-match), consistent with nil-pointer handling, instead of returning an error.
Performance
- Rules are evaluated on a
reflect.Valueinstead of boxing every element and field into anany, and each rule's field path is resolved once perApplyfor concrete slices instead of a per-element cache lookup. TheEqual_10000benchmark drops from ~1.85 ms to ~0.44 ms (~4x), and per-element allocations drop from ~2 per element to a small constant.
Security
- All client-attributable errors are wrapped in the new
ErrInvalidFiltersentinel, so handlers can reject bad filters generically (e.g. HTTP 400) without surfacing client input or internal type names. - Added a package
Securitysection documenting RE2's linear-time matching (no ReDoS) and the caller's authorization responsibility, plus aFuzzFilterApplypanic-safety fuzz harness.
Examples
examples/service: decomposed the startup wiring into focused helpers (newIpifyClient,bindServiceHandlers,newDatabases,newLogConfig), removing thegocognit/funlen/nestif/prealloclint suppressions while keeping a linear, copy-paste-friendly startup blueprint.- The configured service logger is now threaded into
healthcheck.NewHandlerviaWithLogger, so health-check warnings and recovered panics are structured and release-correlated like every other component. - Shared outbound HTTP client options are built once and reused per client; the ipify client is documented as a diagnostic-only dependency deliberately not registered as a health check.
- Aligned the shipped config default
db.{main,read}.conn_max_openwithSetDefaultsand the JSON schema (50), and added a "service enabled, database disabled" bind test restoring 100% statement coverage.
All packages retain 100% test coverage and pass strict golangci-lint.
Full Changelog: v1.142.1...v1.143.0