mesh-grants: list the held seat's own-node machine event in the carried module's membership too
Code review round 1, C-1: granting the subject in the tool runner's NATS account (the previous commit) is not enough, because the runtime's own mayPublish (node-tools/internal/bus/seat.go) checks a module's membership (SeatTraffic.Publish), never the account permissions. SeatTrafficOf leaves a held seat's machine event out of that list and defers to the held-seats' account grant, which the membership check never reads. MembershipFor now lists it too, on the carried module's own node alone. Golden file testdata/user-lists.json updated: the existing "pause" fixture (node-power's machine event "paused") now also appears in its seat-traffic publish list. Builds: design 08 sign-in-page C-1
This commit is contained in:
@@ -895,8 +895,9 @@ func healthChecks(t *testing.T) {
|
||||
// Issue 1952: a module that holds a seat says its own seat's events, also when the tool runner carries it, so the
|
||||
// self-check's `checked`, the keeper's condition events and the healers' `healer-acted` reach their hearers. Its
|
||||
// membership lists them, the runtime is granted them; a user of the seat is not, nor another machine's event on a
|
||||
// node seat (granted per machine, to the holder's own account only; the holder's own machine's is design 08
|
||||
// sign-in-page DMC-1, tested below).
|
||||
// node seat (granted per machine, to the holder's own account only; the holder's own machine's, design 08
|
||||
// sign-in-page C-1, is the node-uplink row below: both the membership the runtime's own mayPublish reads
|
||||
// and the account's grant must list it).
|
||||
selfCheck := Declared{Module: "mesh-self-check", Holds: []Seat{{Name: "mesh-self-check", Scope: "mesh", Emits: []string{"checked"}}}}
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
@@ -914,6 +915,10 @@ func healthChecks(t *testing.T) {
|
||||
Scope: "node", Emits: []string{"paused.*"}}}}, "mesh.seat.node-power.event.paused.b", false},
|
||||
{"a flat event of a node seat held by a module is said flat", Declared{Module: "pause", Holds: []Seat{{Name: "node-power",
|
||||
Scope: "node", Emits: []string{"slept"}}}}, "mesh.seat.node-power.event.slept", true},
|
||||
{"a carried module's own seat's machine event is composed for the tool runner's own node (design 08 sign-in-page C-1)",
|
||||
Declared{Module: "networkmanager", Holds: []Seat{{Name: "node-uplink", Scope: "node", Emits: []string{"sign-in-asked"},
|
||||
EventSubjects: map[string]string{"sign-in-asked": "sign-in-asked.<node>"}}}},
|
||||
"mesh.seat.node-uplink.event.sign-in-asked.a", true},
|
||||
} {
|
||||
m := MembershipFor("a", c.d, Assignments{})
|
||||
listed := m.SeatTraffic != nil && slices.ContainsFunc(m.SeatTraffic.Publish, func(p string) bool { return p == c.subject })
|
||||
@@ -926,19 +931,6 @@ func healthChecks(t *testing.T) {
|
||||
MayPublish(perms, c.subject), c.may)
|
||||
}
|
||||
}
|
||||
// Design 08 sign-in-page DMC-1: the grants part grants the tool runner the publish of its own node's machine
|
||||
// event of a seat a module it carries holds (networkmanager's node-uplink, nftables' node-packet-filter would both
|
||||
// be such a seat once their manifests declare the event), never another node's — the tool runner has no other way
|
||||
// to say it, unlike the holder's own account (step 3 of PermissionsFor's KindModule case, the same machineEvent
|
||||
// rule used there).
|
||||
carryingPower := Declared{Module: "pause", Holds: []Seat{{Name: "node-power", Scope: "node", Emits: []string{"paused.*"}}}}
|
||||
if perms, err := PermissionsFor(Principal{Kind: KindNodeTools, Node: "a", Carries: []Declared{carryingPower}}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !MayPublish(perms, "mesh.seat.node-power.event.paused.a") {
|
||||
t.Errorf("the tool runner on a carrying pause may not say node-power's paused for its own node")
|
||||
} else if MayPublish(perms, "mesh.seat.node-power.event.paused.b") {
|
||||
t.Errorf("the tool runner on a carrying pause may say node-power's paused for another node")
|
||||
}
|
||||
// Lead answer A-280 (A-274, §529): the enrolment's membership lists its finding-events stream under its binding's subject
|
||||
// with the machine last, and the finding events, so the tool runner carrying it says them there and is granted them.
|
||||
enrolment := Declared{Module: "mesh-enrolment", FindingEvents: []string{"finding-written.*", "finding-cleared.*", "findings-stated.*"},
|
||||
|
||||
@@ -67,6 +67,21 @@ func MembershipFor(node string, d Declared, where Assignments) Membership {
|
||||
m.Streams = append(streamsIssuedFor(d), findingEventsIssued(d, node)...)
|
||||
m.Hears = HeardIssuedFor(node, d)
|
||||
t := SeatTrafficOf(d.Module, d.Holds, d.Uses, d.Watches)
|
||||
// A held seat's own-node machine event (novox/hq design 08 sign-in-page C-1): SeatTrafficOf leaves it out of
|
||||
// t.Publish (seattraffic.go, "A holder says its own seat's events") and defers to the held-seats' grant a
|
||||
// module's own account has, which the runtime's mayPublish never consults — only the membership's own
|
||||
// SeatTraffic.Publish does (mesh-tools node-tools/internal/bus/seat.go). Listed here, on this node alone, so a
|
||||
// module the tool runner carries may say it too.
|
||||
for _, s := range d.Holds {
|
||||
if s.isNewTraffic() {
|
||||
continue
|
||||
}
|
||||
for _, e := range s.Emits {
|
||||
if pattern, ok := machineEvent(s, e); ok && node != "" {
|
||||
t.Publish = append(t.Publish, seatSubject(s, "event", onMachine(pattern, node)))
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, s := range append(append([]Seat{}, d.Uses...), d.Watches...) {
|
||||
if !s.Kinded {
|
||||
continue
|
||||
|
||||
@@ -344,7 +344,8 @@
|
||||
"tools": "mesh.mod.pause.tool.tools",
|
||||
"seat-traffic": {
|
||||
"publish": [
|
||||
"mesh.seat.node-power.event.slept"
|
||||
"mesh.seat.node-power.event.slept",
|
||||
"mesh.seat.node-power.event.paused.ace"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user