Skip to content

Commit f3e9f92

Browse files
authored
Merge pull request #1403 from cipherstash/fix/rc-review-1229
fix: review findings on the next-to-main release candidate (#1229)
2 parents 71176ae + 9c39897 commit f3e9f92

67 files changed

Lines changed: 524 additions & 183 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cipherstash/eql': patch
3+
---
4+
5+
The stored and query-operand domains (`eql_v3_*`, `eql_v4_*`, `eql_v3.query_*`, `eql_v4.query_*`) now refuse a payload whose `v` is JSON `null`. The CHECK compared `v` with the bundle's version, and a comparison with `null` is NULL, which a CHECK lets through, so such a payload fitted both a v3 and a v4 domain. The range domains already refused it. A NULL value still fits every domain.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cipherstash/auth': patch
3+
---
4+
5+
The native binaries are built from the `stack-auth` crate at its new version, 0.44.0 (it was 0.43.0). The crate changes that version carries are the ones this release already lists; the version number is what lets the crate publish to crates.io beside them. The package's API is unchanged.

‎Cargo.lock‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ incremental = true
6969
# but cannot subtract them, and `stack-kms` / `stack-encrypt` need stack-auth
7070
# without `http`. Consumers that want the default transport re-enable it with
7171
# `features = ["http"]`.
72-
stack-auth = { path = "./packages/stack-auth", version = "0.43.0", default-features = false }
73-
stack-profile = { path = "./packages/stack-profile", version = "0.43.0" }
72+
stack-auth = { path = "./packages/stack-auth", version = "0.44.0", default-features = false }
73+
stack-profile = { path = "./packages/stack-profile", version = "0.44.0" }
7474

7575
# Suite crates, from crates.io; Cargo.lock holds the exact versions.
7676
# cts-common and zerokms-protocol take caret requirements because the

‎languages/golang/auth/guest/Cargo.lock‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎languages/golang/encrypt/guest/Cargo.lock‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎languages/golang/encrypt/postgres_test.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,13 @@ func TestQueriesRunAgainstPostgres(t *testing.T) {
111111
if err != nil {
112112
t.Fatal(err)
113113
}
114+
// reltuples is -1, an unknown count, until the table is analysed; the
115+
// filter gives no row while it is.
116+
if _, err := conn.ExecContext(ctx, `ANALYZE profiles`); err != nil {
117+
t.Fatal(err)
118+
}
114119
var rows uint64
115-
if err := conn.QueryRowContext(ctx, `SELECT greatest(reltuples, 0)::bigint FROM pg_class WHERE oid = 'profiles'::regclass`).Scan(&rows); err != nil {
120+
if err := conn.QueryRowContext(ctx, `SELECT reltuples::bigint FROM pg_class WHERE oid = 'profiles'::regclass AND reltuples >= 0`).Scan(&rows); err != nil {
116121
t.Fatal(err)
117122
}
118123
limit, err := q.TargetLimit(ctx, 10, encrypt.Stats{Rows: rows})

‎languages/golang/encrypt/query.go‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"io"
88
"log/slog"
9+
"math"
910

1011
"github.com/cipherstash/stack/languages/golang/internal/record"
1112
"github.com/cipherstash/vitaminc/bindings/go/vcffi"
@@ -60,8 +61,12 @@ type Bucket struct {
6061
// size the fetch at. None of it is secret: the server holds the filters and
6162
// the catalog holds the row count.
6263
type Stats struct {
63-
// Rows is the rows the query scans, such as greatest(reltuples, 0)
64-
// from pg_class.
64+
// Rows is the rows the query scans, such as reltuples from pg_class
65+
// read with a reltuples >= 0 filter. reltuples is -1 for a table never
66+
// vacuumed or analysed: that is an unknown count, not an empty table,
67+
// and a count of 0 would promise a fetch of exactly want. While the
68+
// count is unknown, call no TargetLimit and page with a cursor, or run
69+
// ANALYZE first.
6570
Rows uint64
6671
// Histogram is a measured histogram of the stored filters' set-bit
6772
// counts. With none, the engine uses the index's declared prior, and
@@ -101,12 +106,14 @@ type Limit struct {
101106
func (l Limit) Rows() (uint64, bool) { return l.rows, l.bounded }
102107

103108
// FetchOr is the rows to fetch, or page when no finite fetch can be
104-
// promised, for a caller that pages either way.
109+
// promised, for a caller that pages either way. Never more than
110+
// math.MaxInt64, the largest LIMIT PostgreSQL and database/sql take: a
111+
// larger page is cut to it.
105112
func (l Limit) FetchOr(page uint64) uint64 {
106113
if l.bounded {
107114
return l.rows
108115
}
109-
return page
116+
return min(page, math.MaxInt64)
110117
}
111118

112119
// QueryTerm derives the query term for one field of the plan, an operator

‎languages/golang/encrypt/query_test.go‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,20 @@ func TestTargetLimitIsTheRustFixtures(t *testing.T) {
304304
}
305305
}
306306

307+
// An unbounded limit pages, and a page past the largest LIMIT PostgreSQL
308+
// takes is cut to it rather than bound as a value database/sql refuses.
309+
func TestAnUnboundedLimitCutsThePageToTheLargestSQLLimit(t *testing.T) {
310+
var unbounded encrypt.Limit
311+
if got := unbounded.FetchOr(50); got != 50 {
312+
t.Fatalf("FetchOr(50) = %d, want 50", got)
313+
}
314+
for _, page := range []uint64{math.MaxInt64, math.MaxInt64 + 1, math.MaxUint64} {
315+
if got := unbounded.FetchOr(page); got != math.MaxInt64 {
316+
t.Fatalf("FetchOr(%d) = %d, want %d", page, got, uint64(math.MaxInt64))
317+
}
318+
}
319+
}
320+
307321
// A query the field does not answer is refused as a mistyped value is: an
308322
// encoding error that names the field and the rule. The typed path's own
309323
// refusals are term errors.

‎languages/golang/encrypt/step.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,12 @@ func decodeRequest(item any) (ioRequest, bool) {
143143
return ioRequest{}, false
144144
}
145145
}
146-
return r, r.method != "" && r.url != ""
146+
if r.method == "" || r.url == "" {
147+
wipe(r.headers)
148+
wipe(r.body)
149+
return ioRequest{}, false
150+
}
151+
return r, true
147152
}
148153

149154
// performStep performs every request of a step, in order, and encodes the

0 commit comments

Comments
 (0)