Skip to content

fix: drop polonius-the-crab, inline unsafe reborrow (RUSTSEC-2024-0436) - #422

Open
catinspace-au wants to merge 1 commit into
ClickHouse:mainfrom
hyperi-io:hyperi-port/01-remediation
Open

fix: drop polonius-the-crab, inline unsafe reborrow (RUSTSEC-2024-0436)#422
catinspace-au wants to merge 1 commit into
ClickHouse:mainfrom
hyperi-io:hyperi-port/01-remediation

Conversation

@catinspace-au

Copy link
Copy Markdown
Contributor

Supersedes #404.

Drop polonius-the-crab and the chain of unmaintained crates underneath
it. The borrow-check trick polonius wrapped behind a macro is replaced
with a documented inline raw-pointer reborrow in RowCursor::poll_next
and Next::poll (the latter already used the same pattern upstream
post-PR-#397, so this PR completes the migration).

Why now

paste, the transitive dependency that polonius-the-crab uses, was
flagged as unmaintained by RUSTSEC-2024-0436. polonius-the-crab itself
has had no meaningful commits in 12+ months. The advisory + the four-
stagnant-crate dependency stack is a poor trade for a macro that
expands to one line of unsafe { &mut *(bytes as *mut BytesExt) }.

What changes

  • Cargo.toml: drop polonius-the-crab and the three transitive deps
    (paste, higher-kinded-types, macro_rules_attribute).
  • src/cursors/row.rs: replace the polonius!() macro in
    RowCursor::poll_next with the same raw-pointer reborrow already
    in use in Next::poll. Existing upstream features (tracing span
    enter, returned_rows counter, debug log on deserialize error) are
    preserved.
  • src/cursors/row.rs: extensive SAFETY comment documenting why the
    reborrow is sound (Ok / NotEnoughData / Err arms) and why each
    safer alternative (TryRow enum, async-only API, UnsafeCell,
    double-deserialise) was rejected. Once Polonius lands in stable
    rustc, the reborrow can be removed.
  • rustfmt.toml: bump edition 2021 -> 2024 to match Cargo.toml.
  • tests/it/cursor_reborrow.rs (new): 4 mock-based tests covering
    single row, multi-row, empty result, fetch_all/fetch_one; plus 3
    integration tests covering large results spanning chunks, borrowed
    rows, and small block size.

Verification

  • cargo build --no-default-features clean.
  • cargo test --features test-util --test it cursor_reborrow runs
    7 tests; the 4 mock-based pass without network. The 3 integration
    tests need a live ClickHouse to connect to.
  • The unsafe reborrow pattern in the new poll_next is the same one
    already in use in Next::poll upstream, so reviewers comparing
    the two will see identical structure.

…436)

Drop polonius-the-crab and the chain of unmaintained crates underneath
it. The borrow-check trick polonius wrapped behind a macro is replaced
with a documented inline raw-pointer reborrow in `RowCursor::poll_next`
and `Next::poll` (the latter already used the same pattern upstream
post-PR-ClickHouse#397, so this PR completes the migration).

Why now

`paste`, the transitive dependency that polonius-the-crab uses, was
flagged as unmaintained by RUSTSEC-2024-0436. polonius-the-crab itself
has had no meaningful commits in 12+ months. The advisory + the four-
stagnant-crate dependency stack is a poor trade for a macro that
expands to one line of `unsafe { &mut *(bytes as *mut BytesExt) }`.

What changes

  - `Cargo.toml`: drop polonius-the-crab and the three transitive deps
    (paste, higher-kinded-types, macro_rules_attribute).
  - `src/cursors/row.rs`: replace the `polonius!()` macro in
    `RowCursor::poll_next` with the same raw-pointer reborrow already
    in use in `Next::poll`. Existing upstream features (tracing span
    enter, returned_rows counter, debug log on deserialize error) are
    preserved.
  - `src/cursors/row.rs`: extensive SAFETY comment documenting why the
    reborrow is sound (Ok / NotEnoughData / Err arms) and why each
    safer alternative (TryRow enum, async-only API, UnsafeCell,
    double-deserialise) was rejected. Once Polonius lands in stable
    rustc, the reborrow can be removed.
  - `rustfmt.toml`: bump `edition` 2021 -> 2024 to match `Cargo.toml`.
  - `tests/it/cursor_reborrow.rs` (new): 4 mock-based tests covering
    single row, multi-row, empty result, fetch_all/fetch_one; plus 3
    integration tests covering large results spanning chunks, borrowed
    rows, and small block size.

Verification

  - `cargo build --no-default-features` clean.
  - `cargo test --features test-util --test it cursor_reborrow` runs
    7 tests; the 4 mock-based pass without network. The 3 integration
    tests need a live ClickHouse to connect to.
  - The unsafe reborrow pattern in the new `poll_next` is the same one
    already in use in `Next::poll` upstream, so reviewers comparing
    the two will see identical structure.
@catinspace-au
catinspace-au force-pushed the hyperi-port/01-remediation branch from bde3dcb to 53e362f Compare May 25, 2026 04:12

@abonander abonander left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@catinspace-au this looks fine now but can you run cargo fmt please?

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.

2 participants