同步完整源码至远程:扁平化重构现状 + 未入库源文件
- 补入库: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
@@ -102,6 +102,46 @@ func runAgentStub() {
|
||||
// 不会走到这里(TestMain 已拦截),但名字必须存在以匹配 -test.run。
|
||||
func TestAgentStubHelper(t *testing.T) {}
|
||||
|
||||
func TestAgentJavaRuntimeVersion(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "java")
|
||||
t.Setenv("OPSXDB_JAVA_BIN", path)
|
||||
for _, tc := range []struct {
|
||||
version string
|
||||
wantOK bool
|
||||
}{
|
||||
{"1.8.0_401", false},
|
||||
{"17.0.12", true},
|
||||
{"21.0.2", true},
|
||||
} {
|
||||
script := "#!/bin/sh\necho 'openjdk version \"" + tc.version + "\"' >&2\n"
|
||||
if err := os.WriteFile(path, []byte(script), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, gotVersion, err := agentJavaRuntime()
|
||||
if (err == nil) != tc.wantOK || gotVersion != tc.version {
|
||||
t.Fatalf("Java %s: version=%q err=%v", tc.version, gotVersion, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestImportOfflinePackRejectsTraversal(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("OPSXDB_HOME", home)
|
||||
content := "unsafe"
|
||||
rel := "drivers/../../escape.jar"
|
||||
manifest := []map[string]string{{"path": rel, "sha256": fmt.Sprintf("%x", sha256.Sum256([]byte(content)))}}
|
||||
path := filepath.Join(home, "malicious.zip")
|
||||
if err := writeTestZip(path, manifest, map[string]string{rel: content}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := ImportOfflinePack(path); err == nil {
|
||||
t.Fatal("离线驱动包不得写到驱动目录之外")
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(home, "escape.jar")); !os.IsNotExist(err) {
|
||||
t.Fatalf("导入越界文件: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func startStubAgent(t *testing.T) *AgentClient {
|
||||
t.Helper()
|
||||
cmd := exec.Command(os.Args[0], "-test.run=TestAgentStubHelper", "--", "-agent-stub")
|
||||
|
||||
Reference in new issue
Block a user