Skip to content

Harden RowBinary boundary validation - #410

Open
ruslandoga wants to merge 2 commits into
masterfrom
rd/audit-ch-test-structure
Open

Harden RowBinary boundary validation#410
ruslandoga wants to merge 2 commits into
masterfrom
rd/audit-ch-test-structure

Conversation

@ruslandoga

@ruslandoga ruslandoga commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • reject Decimal, float, date/time, and network values before fixed-width RowBinary encoding can wrap, truncate, or become non-finite
  • escape and parse hostile Enum labels losslessly, and reject invalid or ambiguous Enum/Decimal type definitions
  • add focused boundary and property suites plus a live ClickHouse Enum escaping regression

Corruption and robustness fixes

The adversarial tests expose and fix these cases:

  • Decimal32/64/128/256 coefficients could wrap at their signed storage width; specifically, Decimal32 values 2147483648 and 4294967296 became -2147483648 and 0
  • scaling and rounding could introduce unchecked Decimal overflow
  • declared Decimal precision and scale were not enforced for RowBinary
  • non-finite Decimals raised incidental arithmetic errors
  • Float32 overflow encoded infinity, which decoded as nil
  • Date and DateTime values wrapped their UInt16/UInt32 storage
  • DateTime64 ticks could overflow Int64
  • IPv6 segments silently truncated; invalid IPv4 octets returned invalid iodata
  • Enum labels containing quotes, backslashes, delimiters, controls, or NUL were not escaped or decoded correctly
  • invalid or duplicate Enum mappings and invalid Decimal definitions were accepted

Adversarial coverage

  • generated signed bit patterns for every Decimal storage width
  • exact min/max and one-past-boundary cases
  • scaling, rounding, precision, exponent, and non-finite Decimal cases
  • Float32/Float64 overflow cases
  • Date, DateTime, and DateTime64 storage boundaries
  • generated IPv4 octets and every IPv6 segment bit pattern
  • generated Enum type round-trips with quotes, backslashes, punctuation, whitespace, controls, Unicode, and NUL
  • live ClickHouse insert/select using escaped Enum RowBinary type headers in both connection modes

This branch is rebased onto current master. The reverted API/test-ownership refactor is intentionally not included; the live Enum regression now lives in the restored connection_test.exs suite.

Verification

  • focused boundary suite: 243 passed (159 doctests, 4 properties, 80 tests)
  • live Enum escaping regression: 2 passed (both connection modes)
  • isolated full suite: 638/640 passed; the two untouched socket-timeout cases that flaked passed 4/4 on immediate isolated rerun
  • slow tests: 5 passed
  • dependency lock and unused dependency checks pass
  • compile with warnings as errors passes
  • format check passes
  • Dialyzer: 0 errors
  • git diff --check passes

@ruslandoga ruslandoga changed the title Refine integration test ownership and parallelism Strengthen test ownership and RowBinary boundary safety Aug 3, 2026
@ruslandoga
ruslandoga force-pushed the rd/audit-ch-test-structure branch from 97d475e to 81ea80e Compare August 9, 2026 15:19
@ruslandoga ruslandoga changed the title Strengthen test ownership and RowBinary boundary safety Harden RowBinary boundary validation Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant