同步完整源码至远程:扁平化重构现状 + 未入库源文件
- 补入库:server/internal/db/dump.go、redis 分页/扫描预算测试、opsxdb-mcp main_test、 packages/opsxdb-mcp package-lock、docs 审计与对比文档等 37 个新文件 - 含结构扁平化进行中的 80 处修改与 155 处旧结构删除(server/ src/ src-tauri/ 为当前有效源) - 构建产物(bin/target/dist)与签名私钥仍按规则排除
This commit is contained in:
1 parent
5c0be49217
commit
2c0bfafd8d
269 files changed
+10372
-16435
No files matched your search
@@ -23,6 +23,19 @@ func TestConfirmBindHashStableAndSensitive(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAgentConfirmBindIncludesDatabase(t *testing.T) {
|
||||
bind := ConfirmAgentBindHash("c1", "demo", "DELETE FROM users WHERE id=1")
|
||||
if err := VerifyAgentBind("c1", "demo", "DELETE FROM users WHERE id=1", bind); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := VerifyAgentBind("c1", "other", "DELETE FROM users WHERE id=1", bind); err == nil {
|
||||
t.Fatal("database switch must invalidate confirmation")
|
||||
}
|
||||
if err := VerifyAgentBind("c2", "demo", "DELETE FROM users WHERE id=1", bind); err == nil {
|
||||
t.Fatal("connection switch must invalidate confirmation")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNeedConfirmIncludesBind(t *testing.T) {
|
||||
rt := NewRuntime(Policy{
|
||||
Mode: ModeReadWrite,
|
||||
@@ -55,3 +68,23 @@ func TestNeedConfirmIncludesBind(t *testing.T) {
|
||||
t.Fatalf("bind %s want %s", bind, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAgentWriteProposalBindsCurrentDatabase(t *testing.T) {
|
||||
rt := NewRuntime(Policy{Mode: ModeReadWrite, AllowedConnectionIDs: []string{"c1"}})
|
||||
rt.BoundConnectionID = "c1"
|
||||
rt.BoundDatabase = "demo"
|
||||
rt.RejectCallerConfirm = true
|
||||
rt.Audit = func(AuditEntry) {}
|
||||
statement := "DELETE FROM users WHERE id=1"
|
||||
out, err := rt.Call(nil, ToolExecuteQuery, map[string]any{"connection_id": "c1", "sql": statement, "database": "demo"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
bind := out.(map[string]any)["confirmBind"].(string)
|
||||
if err := VerifyAgentBind("c1", "demo", statement, bind); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := VerifyAgentBind("c1", "other", statement, bind); err == nil {
|
||||
t.Fatal("confirmation must be scoped to demo")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user