fix(memory): refuse a credential written out in prose (#2069)
A note saying "the deploy token is 1234567890abcdef" was neither redacted nor refused, because the credential check only recognised a value after a colon or an equals sign. The copula now counts as the separator, so a credential written out in a sentence is refused the way an assignment is. The version read is scoped to the organisation as every other note read is, so a note id from another organisation answers nothing, and the doc comments on Forget and Revoke describe the order the code actually commits in. The deletion-recording schema constant had no consumer and is removed.
This commit is contained in:
7 files changed
+135
-31
No files matched your search
@@ -132,7 +132,7 @@ func TestTaintedConversationWritesNoMemory(t *testing.T) {
|
||||
if err := m.store.Taint(ctx, m.orgID, alice, turn.SessionID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, name := range []string{"memory_save", "memory_propose_shared"} {
|
||||
for _, name := range []string{"memory_save", "memory_propose_shared", "memory_forget"} {
|
||||
if err := builtinOver(m, d, turn, name)(ctx); err == nil {
|
||||
t.Fatalf("%s wrote memory in a tainted conversation", name)
|
||||
}
|
||||
@@ -143,11 +143,17 @@ func TestTaintedConversationWritesNoMemory(t *testing.T) {
|
||||
}
|
||||
|
||||
// builtinOver runs one builtin of turn with a note as its argument.
|
||||
// builtinOver runs one builtin of turn with a fact, or a note id for the tools
|
||||
// that take one, as its argument.
|
||||
func builtinOver(m *Module, d Deps, turn store.Turn, name string) func(context.Context) error {
|
||||
return func(ctx context.Context) error {
|
||||
arg := `{"text":"a fact"}`
|
||||
if name == "memory_forget" {
|
||||
arg = `{"id":"` + uuid.NewString() + `"}`
|
||||
}
|
||||
for _, tool := range m.builtins(d, turn) {
|
||||
if tool.tool.Name == name {
|
||||
_, err := tool.tool.Execute(ctx, `{"text":"a fact"}`)
|
||||
_, err := tool.tool.Execute(ctx, arg)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user