Skip to content

Commit fe7551a

Browse files
committed
chore: tighten error handling, document invariants, finish header migration
Bucket of small clarifications and the residual REUSE header migration. - `error_mapping.rs`: replace the leak/debug-balance TODOs with a cross-link to the new "Logging and information disclosure" section in the README. The client-facing path is unchanged (still sanitised); operator logs keep the raw Trino message. - `session.rs`: doc-comment on `CANCEL_REGISTRY` now lists the two drop sites that clean it up (`ConnectionCleanup` in main.rs and `ConnectionState::Drop` here) and explains why the invariant holds on idle TCP timeouts as well as normal close, error, and panic. - `main.rs`: the over-cap connection drop is documented — the PG protocol *does* allow a graceful `ErrorResponse` (SQLSTATE 53300), but issuing it requires reading the StartupMessage first, which defeats the SYN-flood mitigation. We close at the TCP level and surface the cause via the `tracing::warn!`. - `config.rs`: the `tls_cert` doc-comment used to say "operator-side discipline for now" and pointed at a publication-checklist item. `policy::validate` now enforces this at startup; comment updated. - `startup.rs`: `rand::thread_rng().r#gen::<i32>()` -> `rand::random ::<i32>()`. The `r#gen` raw-identifier form was needed because `gen` became a keyword in Rust 2024; `random()` sidesteps it. Logging on credential check failure now mentions the broader cause (auth rejection / network error / unreachable Trino) rather than implying every failure is auth. - `AGENTS.md`: added the `cargo llvm-cov --all-targets --html` invocation under Build & Test, behind a `cargo install` prerequisite note. - All other touched files (cancel, handler, lib, policy, rewrite/*, catalog/{pg_type,stubs}, build.rs, scripts/*.sh, tests/integration_test.rs): inline SPDX header migration only. No content change.
1 parent 022a073 commit fe7551a

22 files changed

Lines changed: 95 additions & 57 deletions

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ TRINO_HOST=... TRINO_PORT=... TRINO_SSL=true TRINO_TLS_NO_VERIFY=true \
5555
# With writable catalog (DDL tests):
5656
... TRINO_WRITE_CATALOG=memory TRINO_WRITE_SCHEMA=default \
5757
cargo test
58+
59+
# Coverage (requires `cargo install cargo-llvm-cov`):
60+
cargo llvm-cov --all-targets --html
61+
# HTML report at target/llvm-cov/html/index.html
5862
```
5963

6064
## Quality Rules

build.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// Copyright 2026 Stackable GmbH
2-
// Licensed under the Open Software License version 3.0 (OSL-3.0).
3-
// See LICENSE file in the project root for full license text.
1+
// SPDX-FileCopyrightText: 2026 Stackable GmbH
2+
// SPDX-License-Identifier: OSL-3.0
43
fn main() {
54
let timestamp = chrono::Utc::now()
65
.format("%Y-%m-%d %H:%M:%S UTC")

scripts/build-static.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env bash
2+
# SPDX-FileCopyrightText: 2026 Stackable GmbH
3+
# SPDX-License-Identifier: OSL-3.0
24
# Build a statically-linked binary using musl.
35
# The resulting binary runs on any Linux (no glibc dependency).
46
#

scripts/build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env bash
2+
# SPDX-FileCopyrightText: 2026 Stackable GmbH
3+
# SPDX-License-Identifier: OSL-3.0
24
# Build the gateway binary.
35
# Produces a dynamically-linked binary at target/release/postgresql-trino-gateway.
46
set -euo pipefail

scripts/connect.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env bash
2+
# SPDX-FileCopyrightText: 2026 Stackable GmbH
3+
# SPDX-License-Identifier: OSL-3.0
24
# Connect to the gateway with psql for testing.
35
set -euo pipefail
46

scripts/start.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env bash
2+
# SPDX-FileCopyrightText: 2026 Stackable GmbH
3+
# SPDX-License-Identifier: OSL-3.0
24
# Start the PostgreSQL-Trino Gateway.
35
# Configure via environment variables or edit the defaults below.
46
set -euo pipefail

src/cancel.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// Copyright 2026 Stackable GmbH
2-
// Licensed under the Open Software License version 3.0 (OSL-3.0).
3-
// See LICENSE file in the project root for full license text.
1+
// SPDX-FileCopyrightText: 2026 Stackable GmbH
2+
// SPDX-License-Identifier: OSL-3.0
43

54
//! PostgreSQL `CancelRequest` handling.
65
//!

src/catalog/pg_type.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// Copyright 2026 Stackable GmbH
2-
// Licensed under the Open Software License version 3.0 (OSL-3.0).
3-
// See LICENSE file in the project root for full license text.
1+
// SPDX-FileCopyrightText: 2026 Stackable GmbH
2+
// SPDX-License-Identifier: OSL-3.0
43
use std::sync::Arc;
54

65
use pgwire::api::Type;

src/catalog/stubs.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// Copyright 2026 Stackable GmbH
2-
// Licensed under the Open Software License version 3.0 (OSL-3.0).
3-
// See LICENSE file in the project root for full license text.
1+
// SPDX-FileCopyrightText: 2026 Stackable GmbH
2+
// SPDX-License-Identifier: OSL-3.0
43
use std::sync::Arc;
54

65
use pgwire::api::Type;

src/config.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// Copyright 2026 Stackable GmbH
2-
// Licensed under the Open Software License version 3.0 (OSL-3.0).
3-
// See LICENSE file in the project root for full license text.
1+
// SPDX-FileCopyrightText: 2026 Stackable GmbH
2+
// SPDX-License-Identifier: OSL-3.0
43
use std::path::PathBuf;
54

65
use clap::Parser;
@@ -17,9 +16,8 @@ pub struct Config {
1716

1817
/// PEM-encoded TLS certificate chain for the listening socket. When set,
1918
/// `--tls-key` is also required. Without these flags the gateway speaks
20-
/// plaintext PG protocol; do not pair plaintext with `--auth` on a
21-
/// non-loopback bind. (Operator-side discipline for now — automatic
22-
/// refusal is tracked under publication-checklist item A11.)
19+
/// plaintext PG protocol; the auth/TLS posture matrix in `policy.rs`
20+
/// refuses plaintext + `--auth` on a non-loopback bind at startup.
2321
#[arg(long, requires = "tls_key")]
2422
pub tls_cert: Option<PathBuf>,
2523

0 commit comments

Comments
 (0)