mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-26 01:41:04 +08:00
record_fact trusted a model-written source, so target text labelled tool_output could prove a goal. The server now matches the fact's evidence against the intent's recorded activity and pins the activity id. If the same bytes were captured coming back from the target through the proxy, the fact is stored as target_response with the traffic id, whatever the model declared, and prove_goal refuses it (#124 row 1). An untied claim downgrades to inference/inferred and is refused instead of silently trusted.
37 lines
1.4 KiB
Go
37 lines
1.4 KiB
Go
package traffic
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// ResponseContaining matches only the response side, inside the time window:
|
|
// a line that appears only in a request, or a capture outside the window, must
|
|
// not classify a fact as target-authored (#124 row 1, step 3).
|
|
func TestResponseContaining(t *testing.T) {
|
|
tr, _ := openTraffic(t)
|
|
tr.record(newFlow("target.example", "GET", "/login",
|
|
[]byte("request-only-marker-abc"),
|
|
[]byte(`<html><body>welcome, internal only</body></html>`)))
|
|
id := onlyExchangeID(t, tr)
|
|
|
|
now := time.Now().Unix()
|
|
got, ok, err := tr.ResponseContaining([]string{"internal only"}, now-60, now+60)
|
|
if err != nil || !ok || got != id {
|
|
t.Fatalf("response match = %q, %v, %v; want %q, true", got, ok, err, id)
|
|
}
|
|
if _, ok, err := tr.ResponseContaining([]string{"request-only-marker-abc"}, now-60, now+60); err != nil || ok {
|
|
t.Fatalf("request-side match: ok=%v err=%v, want false", ok, err)
|
|
}
|
|
if _, ok, err := tr.ResponseContaining([]string{"internal only"}, now+600, now+900); err != nil || ok {
|
|
t.Fatalf("out-of-window match: ok=%v err=%v, want false", ok, err)
|
|
}
|
|
if _, ok, err := tr.ResponseContaining([]string{"never recorded anywhere"}, now-60, now+60); err != nil || ok {
|
|
t.Fatalf("absent match: ok=%v err=%v, want false", ok, err)
|
|
}
|
|
var nilStore *Traffic
|
|
if _, ok, err := nilStore.ResponseContaining([]string{"internal only"}, now-60, now+60); err != nil || ok {
|
|
t.Fatalf("nil store: ok=%v err=%v, want false", ok, err)
|
|
}
|
|
}
|