mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-25 17:30:56 +08:00
prove_goal's finding proof was meant to confirm that each bound traffic_ref still exists in the live capture, but SetTrafficProofChecker was only called from tests: Planner.Plan built its ToolSet without it, exchangeExists was nil, and VerifyFindingProofForNode skipped the check silently. Decision: wire it (option a). The capture store is reachable when Plan() runs: server/task_llm.go (agentsForTask) already gives the planner SetFindingRecorder(s.evidenceStore()), and that evidence store is built on s.m.traffic, the live capture. So: - traffic.Traffic.ExchangeExists looks the id up in the capture index (nil store or lookup failure is an error). - evidence.Store.TrafficExists delegates to it. - agent.TrafficCaptureChecker is the interface; Plan() wires the recorder's TrafficExists into the ToolSet when the recorder implements it, so the production planner gets the check with no extra server wiring. - VerifyFindingProofForNode treats a nil checker as unavailable and returns an error, so prove_goal answers "refused (fail-closed)" instead of accepting the proof; a lookup error does the same. The capture store is global, not partitioned per task: the check proves the exchange is in this server's capture, and the host match against the finding's assets ties it to the target. Tests: adversarial bench case TestAdversarialBenchTrafficRefMissingFromCaptureRefusedPG builds the planner like agentsForTask (NewPlanner + SetFindingRecorder(evidence store)), with nothing injected into the ToolSet, and checks that a traffic_ref absent from the capture is refused, that a capture-less evidence store and a planner without a recorder refuse (fail-closed), and that a captured matching ref still closes the goal. The three refusal subtests fail on 5ba19cd. Existing ToolSet-level tests now set an explicit checker, and the existing bench round 2 binds an exchange that is in the capture and runs with the production recorder.
31 lines
2.0 KiB
Go
31 lines
2.0 KiB
Go
package agent
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/Autumn-27/artex/db"
|
|
)
|
|
|
|
// FindingRecorder is injected by the host; agents never synthesize or copy
|
|
// evidence bodies themselves. Its implementation owns the atomic write.
|
|
type FindingRecorder interface {
|
|
Record(context.Context, db.RecordFindingInput, []db.TrafficRef) (*db.RecordedFinding, error)
|
|
}
|
|
|
|
// TrafficCaptureChecker is implemented by a FindingRecorder that owns the live
|
|
// traffic capture (the host's evidence store). Plan() hands it to prove_goal so
|
|
// a finding's bound traffic_ref must still exist in that capture. Without it,
|
|
// finding proofs are refused (#124, P4.3).
|
|
type TrafficCaptureChecker interface {
|
|
TrafficExists(ctx context.Context, trafficID string) (bool, error)
|
|
}
|
|
|
|
// Tool-use guidance is appended without replacing the user's editable prompt.
|
|
// It does not require capture or claim that unavailable traffic tools exist.
|
|
const findingTrafficGuidance = "\n\n**Vulnerability traffic evidence**: when reporting a vulnerability via report_finding, bind real HTTP request/response IDs via traffic_refs in reproduction order; domains and times are only candidate filters and do not imply association. A finding without bound traffic stays recorded and visible, but cannot close a goal via prove_goal until verified traffic matching its asset host is bound (via report_finding or bind_finding_traffic). For TCP and other non-HTTP vulnerabilities, when nothing was captured, or when there is no exact match, omit traffic_refs or pass [], keep verifiable command output and logs in evidence, and close non-HTTP goals with an observed tool_output fact. Do not guess IDs, and do not re-probe just to capture packets."
|
|
|
|
func (t *ToolSet) SetFindingRecorder(r FindingRecorder) { t.findingRecorder = r }
|
|
func (w *Worker) SetFindingRecorder(r FindingRecorder) { w.findingRecorder = r }
|
|
func (p *Planner) SetFindingRecorder(r FindingRecorder) { p.findingRecorder = r }
|
|
func (m *MainAgent) SetFindingRecorder(r FindingRecorder) { m.findingRecorder = r }
|