Skip to content

armgit / ARTEX

Public Imported from GitHub
0

ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)

perf(agent): read traffic capture setting once per findingWorkflowTools pass

BaaRai1adfc21346ac
diff --git a/agent/finding_workflow.go b/agent/finding_workflow.go
index 0099cd2..5362a26 100644
--- a/agent/finding_workflow.go
+++ b/agent/finding_workflow.go
@@ -73,8 +73,8 @@ const (
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() {
+func trafficCaptureOffToolNote(toolName string, captureOff bool) string {
+ if !captureOff {
return ""
}
switch toolName {
@@ -91,6 +91,7 @@ func trafficCaptureOffToolNote(toolName string) string {
// all actual reporters (including Planner and custom chat agents) see the same
// API contract. Disabled/unbound tools are never reintroduced here.
func findingWorkflowTools(agentKey string, tools []actool.CoreTool) ([]actool.CoreTool, string) {
+ captureOff := trafficCaptureExplicitlyOff()
if !findingTrafficBindingEnabled() {
out := make([]actool.CoreTool, 0, len(tools))
for _, tool := range tools {
@@ -114,7 +115,7 @@ func findingWorkflowTools(agentKey string, tools []actool.CoreTool) ([]actool.Co
decorated = true
}
}
- if note := trafficCaptureOffToolNote(tool.Name()); note != "" {
+ if note := trafficCaptureOffToolNote(tool.Name(), captureOff); note != "" {
desc += note
decorated = true
}
@@ -138,7 +139,7 @@ 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 != "" {
+ if capNote := trafficCaptureOffToolNote(tool.Name(), captureOff); capNote != "" {
note += capNote
}
if note != "" {
diff --git a/agent/finding_workflow_test.go b/agent/finding_workflow_test.go
index 0e8ca2d..ba8fa76 100644
--- a/agent/finding_workflow_test.go
+++ b/agent/finding_workflow_test.go
@@ -87,9 +87,16 @@ func TestFindingWorkflowToolsTrafficCaptureOffNotice(t *testing.T) {
for _, binding := range []bool{false, true} {
SetFindingTrafficBindingEnabled(func() bool { return binding })
- SetTrafficCaptureEnabled(func() bool { return false })
+ calls := 0
+ SetTrafficCaptureEnabled(func() bool {
+ calls++
+ return false
+ })
outOff, _, clOff := AugmentTools(t.Context(), "planner", base)
clOff()
+ if calls != 1 {
+ t.Fatalf("binding=%v: capture hook called %d times for %d tools, want 1", binding, calls, len(base))
+ }
for _, tool := range outOff {
desc := tool.Description()
switch tool.Name() {