Skip to content

Commit dd1b6b7

Browse files
committed
connect: refuse an Agent booster at the boost read
The poll lane carries no actor type, so an Agent person the operator wrongly put in the allowlist passes the gate. The boost read names the booster's personable type; refuse an Agent there as agent_authored, as authorTrusted refuses an Agent author.
1 parent 699cd5d commit dd1b6b7

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎internal/connector/admission/boost.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ func boostOnRecording(ev Event) (int64, Reason) {
6161
// The boost must be on the pointer's recording, and its booster must be the
6262
// performer the gate trusted: the boost is the words handed off, so whoever
6363
// wrote them is held to the trust the performer was. A read that answered
64-
// without either is a read that failed.
64+
// without either is a read that failed. An Agent booster is refused here as
65+
// agent_authored: the poll lane carries no actor type, so an Agent person the
66+
// operator wrongly put in the allowlist passes the gate, and this read is
67+
// where it shows, as an author's type shows in authorTrusted.
6568
func (a *decision) readBoost(ctx context.Context, ev Event, boostID int64) (*basecamp.Boost, State, Reason, error) {
6669
var boost *basecamp.Boost
6770
err := a.retry(ctx, func() error {
@@ -82,6 +85,8 @@ func (a *decision) readBoost(ctx context.Context, ev Event, boostID int64) (*bas
8285
return nil, StateBlocked, ReasonReadFailed, nil
8386
case boost.Booster.ID != ev.Performer():
8487
return nil, StateDiscarded, ReasonUntrustedAuthor, nil
88+
case boost.Booster.PersonableType == personableAgent:
89+
return nil, StateDiscarded, ReasonAgentAuthored, nil
8590
}
8691
return boost, "", "", nil
8792
}

‎internal/connector/admission/boost_test.go‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,3 +335,19 @@ func TestABoostOnATrashedPostIsStale(t *testing.T) {
335335
assert.Equal(t, StateDiscarded, v.State)
336336
assert.Equal(t, ReasonStale, v.Reason)
337337
}
338+
339+
// On the poll lane no actor type shows an agent; an Agent person the operator
340+
// wrongly allowlisted passes the gate, and the boost read is where it shows.
341+
func TestAnAllowlistedAgentsBoostIsRefusedByTheBoostRead(t *testing.T) {
342+
p := basePolicy()
343+
p.Trust = Trust{Mode: TrustAllowlist, OperatorID: operatorID, AllowlistIDs: []int64{allowedID}}
344+
f := newFakeReads()
345+
boostOn(f, "Comment", agentID, allowedID)
346+
f.boosts[boostID].Booster.PersonableType = personableAgent
347+
348+
v := decide(t, newAdmitter(t, p, f), boostEvent(allowedID))
349+
assert.Equal(t, StateDiscarded, v.State)
350+
assert.Equal(t, ReasonAgentAuthored, v.Reason)
351+
assert.Nil(t, v.Snapshot)
352+
assert.Zero(t, f.summaryCalls, "refused before the boosted recording is read")
353+
}

0 commit comments

Comments
 (0)