grouproll: probe group writes are an allow-list
The probe gate refused only desired and terminate. It now allows the three group writes (minimum, enter, exit), the reads and the box session ops, and refuses any other op before its intent row. Census overlay re-pinned.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
3 files changed,
+32
−3
internal/grouproll/engine.go+14 −2internal/grouproll/probe_test.go+17 −0internal/provision/testdata/plan14-root-reads-group-roll-verb.tsv+1 −1
diff --git a/internal/grouproll/engine.go b/internal/grouproll/engine.go| index eddd4cef6..ba3aa2113 100644 |
| --- a/internal/grouproll/engine.go |
| +++ b/internal/grouproll/engine.go |
| @@ -159,6 +159,17 @@ func errorName(err error) string { |
| return "Error" |
| } |
| +// probeOps is the allow-list of ops a probe may send: its three group |
| +// writes, the reads, and the box session ops (their writes are gated by |
| +// the session verb). Every other op, desired and terminate among them, is |
| +// refused in probe mode. |
| +var probeOps = map[string]bool{ |
| + "minimum": true, "enter": true, "exit": true, |
| + "session": true, "terminate_session": true, |
| + "group": true, "targets": true, "hooks": true, "online": true, "instance": true, |
| + "edges": true, "edges_list": true, "edges_key": true, "activities": true, "ec2_instance": true, |
| +} |
| + |
| // call is the script's Operator.call: an intent row before the request |
| // and a response or error row after it, with the dispatch evidence. args |
| // are journaled as given. fresh, when not zero, is the observation the |
| @@ -167,8 +178,9 @@ func errorName(err error) string { |
| func (e *Engine) call(ctx context.Context, op string, args map[string]any, fresh time.Time, |
| request func(ctx context.Context, onSession func(string)) (any, error)) (any, error) { |
| // The probe's group writes are minimum, enter and exit only; any other |
| - // group write is refused before its intent, as its box sessions are. |
| - if e.probe && (op == "desired" || op == "terminate") { |
| + // op the probe has not been given (an unknown write included) is |
| + // refused before its intent, as its box sessions are. |
| + if e.probe && !probeOps[op] { |
| return nil, refuse("probe_read_only") |
| } |
| // H4: only this transaction's member may enter Standby, with decrement. |
diff --git a/internal/grouproll/probe_test.go b/internal/grouproll/probe_test.go| index 3f14474f8..3ca950383 100644 |
| --- a/internal/grouproll/probe_test.go |
| +++ b/internal/grouproll/probe_test.go |
| @@ -4,6 +4,7 @@ package grouproll |
| import ( |
| "bytes" |
| + "context" |
| "errors" |
| "fmt" |
| "os" |
| @@ -1513,6 +1514,22 @@ func TestProbeGroupWritesAreMinimumEnterExit(t *testing.T) { |
| return nil |
| })) |
| + // An unknown write op is refused too, with no intent row. |
| + h = newProbeHarness(t) |
| + must(t, probeEngine(h, func(e *Engine) error { |
| + must(t, h.createProbe(e, "probe-"+strings.Repeat("e", 32))) |
| + defer e.close() |
| + _, err := e.call(bg, "set_capacity", map[string]any{"value": 3}, time.Time{}, |
| + func(context.Context, func(string)) (any, error) { return nil, nil }) |
| + if refusalKey(err) != "probe_read_only" { |
| + t.Errorf("unknown write op = %v", err) |
| + } |
| + if len(h.f.calls) != 0 || e.has("intent", map[string]any{"op": "set_capacity"}) { |
| + t.Fatalf("calls %v", h.f.ops()) |
| + } |
| + return nil |
| + })) |
| + |
| // A whole probe pass writes only minimum, enter and exit. |
| h = newProbeHarness(t) |
| must(t, h.runProbe()) |
diff --git a/internal/provision/testdata/plan14-root-reads-group-roll-verb.tsv b/internal/provision/testdata/plan14-root-reads-group-roll-verb.tsv| index 9146fac30..af01af138 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-group-roll-verb.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-group-roll-verb.tsv |
| @@ -50,6 +50,6 @@ internal/grouprollaws/transport.go boundBody.HandleDeserialize legacy accepted-l |
| internal/grouprollaws/transport.go boundedBody.Read legacy accepted-legacy accepted-legacy;rev3=census-ruling-group-roll-verb;basis=reads an AWS API answer body under the 4 MiB cap and the read timeout file:Read@22,file:Read@448 7ff90cef635efcf75d046d9113cb6a0dcddd8dfb3570c73984bc5565b637e872 |
| system_group.go runSystemGroup legacy accepted-legacy accepted-legacy;rev3=census-ruling-group-roll-verb;basis=lstats /etc/carlos/host.env to refuse running on a carlos box (euid 0 is refused first); routes the roll, replace, remove, cancel-drain and probe verbs to the engine after refusing missing arguments file:Lstat@245 fc02f153643366e3407e177cf6950b163a93c1965c4a450597b0674c61007bec |
| @coverage . 237724e495ec26f7c2521c55f09b6e3e0ed155550a2e32c15dfe1b623840572f |
| -@coverage internal/grouproll 60ae718706ca0ff238a09691ec09ec34dbd239f8780701dc90a1d44b5fd4d296 |
| +@coverage internal/grouproll ba13259aef976fb71953db83624a9387c0c81f12a0aa26fdd3892c6e3a658e46 |
| @coverage internal/grouprollaws d9bc632b24975cd6e6434b0c23439871a68e4b4659041e6e110ba8b8b5e96ffc |
| @coverage internal/release e8d4983a8b37969c7d4ad9b99facf8332113f12f69c640b0b9624901184c9e54 |