diff --git a/agent/finding_workflow.go b/agent/finding_workflow.go index de0f04f..0099cd2 100644 --- a/agent/finding_workflow.go +++ b/agent/finding_workflow.go @@ -43,6 +43,50 @@ func findingTrafficBindingEnabled() bool { return f != nil && f() } +var ( + trafficCaptureMu sync.RWMutex + trafficCaptureHook func() bool +) + +// SetTrafficCaptureEnabled installs (or, with nil, removes) the hook that +// reports whether the server's global traffic capture switch is currently on. +func SetTrafficCaptureEnabled(f func() bool) { + trafficCaptureMu.Lock() + trafficCaptureHook = f + trafficCaptureMu.Unlock() +} + +// TrafficCaptureEnabled returns the current hook, or nil when none is set. +func TrafficCaptureEnabled() func() bool { + trafficCaptureMu.RLock() + defer trafficCaptureMu.RUnlock() + return trafficCaptureHook +} + +func trafficCaptureExplicitlyOff() bool { + f := TrafficCaptureEnabled() + return f != nil && !f() +} + +const ( + trafficCaptureOffProveGoalNote = "\nNote: traffic capture is currently OFF on this server, so no HTTP traffic is being recorded and findings cannot be bound to captured traffic to prove HTTP goals. Recorded findings stay visible, and non-HTTP goals can still be proved with an observed tool_output fact; enable traffic capture in System settings to make HTTP findings provable." + trafficCaptureOffReportFindingNote = "\nNote: traffic capture is currently OFF on this server, so no HTTP traffic is being recorded. Findings still save with textual/command evidence, but cannot prove goals via prove_goal until traffic capture is enabled in System settings and verified traffic is bound." +) + +func trafficCaptureOffToolNote(toolName string) string { + if !trafficCaptureExplicitlyOff() { + return "" + } + switch toolName { + case "prove_goal": + return trafficCaptureOffProveGoalNote + case "report_finding": + return trafficCaptureOffReportFindingNote + default: + return "" + } +} + // Applied after ToolResolve: user descriptions and prompts remain intact, while // all actual reporters (including Planner and custom chat agents) see the same // API contract. Disabled/unbound tools are never reintroduced here. @@ -56,16 +100,27 @@ func findingWorkflowTools(agentKey string, tools []actool.CoreTool) ([]actool.Co if agentKey == "reporter" && (tool.Name() == "traffic_search" || tool.Name() == "traffic_get" || tool.Name() == "traffic_blob" || tool.Name() == "traffic_messages") { continue } + desc := tool.Description() + schema := tool.InputSchema() + decorated := false switch tool.Name() { case "report_finding", "add_hint", "add_task_hint": // Work on a copy: toggling back on must restore the original schema. raw, _ := json.Marshal(tool.InputSchema()) - var schema map[string]any - if json.Unmarshal(raw, &schema) == nil { - stripTrafficParameters(schema) - tool = DecorateTool(tool, tool.Description(), schema) + var s map[string]any + if json.Unmarshal(raw, &s) == nil { + stripTrafficParameters(s) + schema = s + decorated = true } } + if note := trafficCaptureOffToolNote(tool.Name()); note != "" { + desc += note + decorated = true + } + if decorated { + tool = DecorateTool(tool, desc, schema) + } out = append(out, tool) } return out, "" @@ -83,6 +138,9 @@ func findingWorkflowTools(agentKey string, tools []actool.CoreTool) ([]actool.Co case "get_finding_traffic", "bind_finding_traffic", "list_findings", "list_task_findings", "node_detail", "get_task_node_detail", "update_finding_report": note = findingIDGuidance } + if capNote := trafficCaptureOffToolNote(tool.Name()); capNote != "" { + note += capNote + } if note != "" { out[i] = DecorateTool(tool, tool.Description()+note, tool.InputSchema()) } diff --git a/agent/finding_workflow_test.go b/agent/finding_workflow_test.go index c478f3d..0e8ca2d 100644 --- a/agent/finding_workflow_test.go +++ b/agent/finding_workflow_test.go @@ -70,3 +70,47 @@ func TestFindingWorkflowSharedAssemblyAndSwitch(t *testing.T) { t.Fatal("reintroduced disabled tool or its guidance") } } + +func TestFindingWorkflowToolsTrafficCaptureOffNotice(t *testing.T) { + oldPolicy, oldCapture, oldResolve, oldAugment := FindingTrafficBindingEnabled(), TrafficCaptureEnabled(), ToolResolve(), ToolAugment() + t.Cleanup(func() { + SetFindingTrafficBindingEnabled(oldPolicy) + SetTrafficCaptureEnabled(oldCapture) + SetToolResolve(oldResolve) + SetToolAugment(oldAugment) + }) + SetToolAugment(nil) + SetToolResolve(nil) + ts := NewToolSet(nil, "fixture") + base := []actool.CoreTool{ts.proveGoal(), ts.addFinding(), ts.addHint()} + + for _, binding := range []bool{false, true} { + SetFindingTrafficBindingEnabled(func() bool { return binding }) + + SetTrafficCaptureEnabled(func() bool { return false }) + outOff, _, clOff := AugmentTools(t.Context(), "planner", base) + clOff() + for _, tool := range outOff { + desc := tool.Description() + switch tool.Name() { + case "prove_goal", "report_finding": + if !strings.Contains(desc, "traffic capture is currently OFF") { + t.Fatalf("binding=%v %s: expected capture-off notice in description, got %q", binding, tool.Name(), desc) + } + case "add_hint": + if strings.Contains(desc, "traffic capture is currently OFF") { + t.Fatalf("binding=%v add_hint: unexpected capture-off notice", binding) + } + } + } + + SetTrafficCaptureEnabled(func() bool { return true }) + outOn, _, clOn := AugmentTools(t.Context(), "planner", base) + clOn() + for _, tool := range outOn { + if strings.Contains(tool.Description(), "traffic capture is currently OFF") { + t.Fatalf("binding=%v %s: unexpected capture-off notice when capture is ON", binding, tool.Name()) + } + } + } +} diff --git a/server/assembly.go b/server/assembly.go index 9fb0754..5711504 100644 --- a/server/assembly.go +++ b/server/assembly.go @@ -223,6 +223,7 @@ func seedPrompts(pg *db.DB) { // and default params get injected. MCP/skill/host tools have no row and pass through. func wireTools(pg *db.DB, domainReg map[string]actool.CoreTool) { agent.SetFindingTrafficBindingEnabled(func() bool { return pg.GetBool(settingAgentTrafficBinding, false) }) + agent.SetTrafficCaptureEnabled(func() bool { return pg.GetBool(settingTrafficCapture, false) }) // Seed the built-in domain tools (first-insert only; DO NOTHING preserves edits). // No startup prune: rows we didn't seed are left alone so future user-defined // custom tools (system=false, added via the UI) survive restarts. diff --git a/web/src/app/(auth)/setup/page.tsx b/web/src/app/(auth)/setup/page.tsx index 152bca3..6aa2fa0 100644 --- a/web/src/app/(auth)/setup/page.tsx +++ b/web/src/app/(auth)/setup/page.tsx @@ -139,6 +139,9 @@ export default function SetupPage() { > {loading ? t("Saving...") : t("Set password and sign in")} +

+ {t("Traffic capture is off by default. Enable it in System settings after setup if you need provable HTTP findings — captured traffic is required for findings to prove goals.")} +

)} diff --git a/web/src/app/(main)/dashboard/page.tsx b/web/src/app/(main)/dashboard/page.tsx index ddd64c6..6243e62 100644 --- a/web/src/app/(main)/dashboard/page.tsx +++ b/web/src/app/(main)/dashboard/page.tsx @@ -572,7 +572,9 @@ export default function DashboardPage() { {t("Recording")} ) : ( - {t("Capture is off")} + + {t("Capture is off · required for provable findings")} + )} @@ -1164,19 +1166,29 @@ export default function DashboardPage() { -
-
{t("Traffic capture")}
- - {settings?.traffic_capture ? t("On") : t("Off")} - +
+
+
{t("Traffic capture")}
+ + {settings?.traffic_capture ? t("On") : t("Off")} + +
+ {settings && !settings.traffic_capture && ( +

+ {t("Traffic capture is off: findings stay recorded, but captured HTTP traffic is required for provable findings.")}{" "} + + {t("Enable in settings")} + +

+ )}
{activeProfile && ( diff --git a/web/src/app/(main)/system/settings/page.tsx b/web/src/app/(main)/system/settings/page.tsx index 36fa715..4b2db03 100644 --- a/web/src/app/(main)/system/settings/page.tsx +++ b/web/src/app/(main)/system/settings/page.tsx @@ -320,16 +320,23 @@ export default function SystemSettingsPage() { )} - - - + +
+ + +
+ {loaded && !trafficCapture && ( +

+ {t("Traffic capture is off: findings stay recorded, but captured HTTP traffic is required for provable findings.")} +

+ )}
diff --git a/web/src/i18n/locales/tr.json b/web/src/i18n/locales/tr.json index 5df2a69..263307c 100644 --- a/web/src/i18n/locales/tr.json +++ b/web/src/i18n/locales/tr.json @@ -2709,5 +2709,9 @@ "Hashes": "Özetler", "Masked (HMAC)": "Maskeli (HMAC)", "Resulting request": "Ortaya çıkan istek", - "Resulting response": "Ortaya çıkan yanıt" + "Resulting response": "Ortaya çıkan yanıt", + "Traffic capture is off by default. Enable it in System settings after setup if you need provable HTTP findings — captured traffic is required for findings to prove goals.": "Trafik yakalama varsayılan olarak kapalıdır. Kanıtlanabilir HTTP bulguları gerekiyorsa kurulumdan sonra Sistem ayarlarından etkinleştirin — bulguların hedefleri kanıtlaması için yakalanmış trafik gereklidir.", + "Capture is off · required for provable findings": "Yakalama kapalı · kanıtlanabilir bulgular için gerekli", + "Traffic capture is off: findings stay recorded, but captured HTTP traffic is required for provable findings.": "Trafik yakalama kapalı: bulgular kaydedilmeye devam eder ancak kanıtlanabilir bulgular için yakalanmış HTTP trafiği gereklidir.", + "Enable in settings": "Ayarlardan etkinleştir" } diff --git a/web/src/i18n/locales/zh-CN.json b/web/src/i18n/locales/zh-CN.json index 0b64bd7..2256d8b 100644 --- a/web/src/i18n/locales/zh-CN.json +++ b/web/src/i18n/locales/zh-CN.json @@ -2709,5 +2709,9 @@ "Hashes": "哈希", "Masked (HMAC)": "已脱敏 (HMAC)", "Resulting request": "结果请求", - "Resulting response": "结果响应" + "Resulting response": "结果响应", + "Traffic capture is off by default. Enable it in System settings after setup if you need provable HTTP findings — captured traffic is required for findings to prove goals.": "流量捕获默认关闭。如需可证明的 HTTP 漏洞发现,请在初始化后前往系统设置开启——漏洞证明目标需要已捕获的 HTTP 流量。", + "Capture is off · required for provable findings": "捕获已关闭 · 可证明漏洞所需", + "Traffic capture is off: findings stay recorded, but captured HTTP traffic is required for provable findings.": "流量捕获已关闭:漏洞仍会被记录,但证明目标需要已捕获的 HTTP 流量。", + "Enable in settings": "前往设置开启" }