ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)
Go aiai-agentsautonomous-agentsbug-bountydockergolanglinuxllmmcpnextjspenetration-testingpentestpostgresqlreareactred-teamsecuritysecurity-automationsqlitetypescript
feat(server): upgrade the built-in traffic_get description once
BaaRaib57bafe74a07
diff --git a/server/finding_workflow.go b/server/finding_workflow.goindex 8b11fac..8e2ecdc 100644--- a/server/finding_workflow.go+++ b/server/finding_workflow.go@@ -29,6 +29,16 @@ func (s *Server) seedFindingWorkflowTools() {_ = s.m.pg.SetSetting(hostSearchDescriptionFlag, "true")}}+ const getRewriteDescriptionFlag = "traffic_get_rewrite_description_v1"+ if value, _, _ := s.m.pg.GetSetting(getRewriteDescriptionFlag); value != "true" {+ // Same rule: only the original built-in text is replaced.+ legacy := "Fetch the raw request/response of one captured traffic record by id (truncated when too large). Use together with traffic_search to avoid re-curling. A WebSocket (status 101) or SSE (text/event-stream) record shows only its handshake here; read its messages with traffic_messages."+ if _, err := s.m.pg.Exec(`UPDATE tools SET description=$1,updated_at=now() WHERE key='traffic_get' AND system AND description=$2`, traffic.TrafficGetDescription, legacy); err != nil {+ log.Printf("[evidence] upgrade traffic_get description: %v", err)+ } else {+ _ = s.m.pg.SetSetting(getRewriteDescriptionFlag, "true")+ }+ }const flag = "finding_workflow_tools_v2_reporter"if value, _, _ := s.m.pg.GetSetting(flag); value == "true" {returndiff --git a/server/traffic_get_description_test.go b/server/traffic_get_description_test.gonew file mode 100644index 0000000..f91ae05--- /dev/null+++ b/server/traffic_get_description_test.go@@ -0,0 +1,44 @@+package server++import (+ "encoding/json"+ "testing"++ "github.com/Autumn-27/artex/traffic"+)++// The traffic_get description that says traffic_search never finds a value a+// rewrite rule wrote replaces the original built-in text once, and never a+// description the user edited.+func TestTrafficGetDescriptionUpgrade(t *testing.T) {+ s, _, _ := trafficEvidenceServer(t)+ pg := s.m.pg+ old, err := pg.GetTool("traffic_get")+ if err != nil || old == nil {+ t.Fatal("missing tool traffic_get", err)+ }+ bindings, _ := json.Marshal(old.Agents)+ t.Cleanup(func() { pg.UpdateTool("traffic_get", old.Description, old.Schema, bindings, old.Enabled) })+ const flag = "traffic_get_rewrite_description_v1"+ legacy := "Fetch the raw request/response of one captured traffic record by id (truncated when too large). Use together with traffic_search to avoid re-curling. A WebSocket (status 101) or SSE (text/event-stream) record shows only its handshake here; read its messages with traffic_messages."++ for _, c := range []struct{ stored, want string }{+ {legacy, traffic.TrafficGetDescription},+ {"USER DESCRIPTION", "USER DESCRIPTION"},+ } {+ if err := pg.UpdateTool("traffic_get", c.stored, old.Schema, bindings, old.Enabled); err != nil {+ t.Fatal(err)+ }+ if err := pg.SetSetting(flag, "false"); err != nil {+ t.Fatal(err)+ }+ s.seedFindingWorkflowTools()+ row, _ := pg.GetTool("traffic_get")+ if row.Description != c.want {+ t.Fatalf("stored %q: description %q, want %q", c.stored, row.Description, c.want)+ }+ if v, _, _ := pg.GetSetting(flag); v != "true" {+ t.Fatal("flag not set")+ }+ }+}