From 5e08ab20f58d42afbcc26c6fe42911f3f5671477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 3 Sep 2026 01:09:31 -0400 Subject: [PATCH] chore(go): audit cmd/elydora root Drop the tautological secret file identity check and the test-only guard path wrapper. Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq --- cmd/elydora/cli_secrets.go | 3 --- cmd/elydora/main.go | 25 ------------------------- cmd/elydora/main_test.go | 6 ++++-- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/cmd/elydora/cli_secrets.go b/cmd/elydora/cli_secrets.go index 664f22e..a262090 100644 --- a/cmd/elydora/cli_secrets.go +++ b/cmd/elydora/cli_secrets.go @@ -119,9 +119,6 @@ func readSecretFileWithOpen( if err := validateSecretFile(before, path, label); err != nil { return "", err } - if !os.SameFile(before, before) { - return "", fmt.Errorf("establish %s file identity at %s", label, path) - } file, err := openFile(path) if err != nil { diff --git a/cmd/elydora/main.go b/cmd/elydora/main.go index d4552ec..5242fd9 100644 --- a/cmd/elydora/main.go +++ b/cmd/elydora/main.go @@ -57,10 +57,6 @@ Run "elydora -h" for details on each command. `) } -// --------------------------------------------------------------------------- -// install -// --------------------------------------------------------------------------- - func cmdInstall(args []string) { if err := rejectLegacySecretArguments(args); err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) @@ -160,10 +156,6 @@ func cmdInstall(args []string) { fmt.Printf(" Guard script: %s\n", guardScriptPath) } -// --------------------------------------------------------------------------- -// uninstall -// --------------------------------------------------------------------------- - func cmdUninstall(args []string) { fs := flag.NewFlagSet("uninstall", flag.ExitOnError) agent := fs.String("agent", "", "Agent name (required)") @@ -209,10 +201,6 @@ func cmdUninstall(args []string) { } } -// --------------------------------------------------------------------------- -// status -// --------------------------------------------------------------------------- - func cmdStatus(args []string) { fs := flag.NewFlagSet("status", flag.ExitOnError) agent := fs.String("agent", "", "Agent name (optional — omit to show all)") @@ -256,10 +244,6 @@ func showAgentStatus(name string) { fmt.Printf(" %-14s %-20s %s\n", name, status.DisplayName, state) } -// --------------------------------------------------------------------------- -// agents -// --------------------------------------------------------------------------- - func cmdAgents() { fmt.Println("Supported agents:") fmt.Println() @@ -282,12 +266,3 @@ func sortedAgentNames() []string { sort.Strings(names) return names } - -// guardScriptPathForAgent returns the path to ~/.elydora//guard.js. -func guardScriptPathForAgent(agentId string) (string, error) { - agentDirectory, err := plugins.ResolveAgentRuntimeDirectory(agentId) - if err != nil { - return "", err - } - return filepath.Join(agentDirectory, "guard.js"), nil -} diff --git a/cmd/elydora/main_test.go b/cmd/elydora/main_test.go index 00d290f..bc8fc4a 100644 --- a/cmd/elydora/main_test.go +++ b/cmd/elydora/main_test.go @@ -5,6 +5,8 @@ import ( "path/filepath" "strings" "testing" + + "github.com/Elydora-Infrastructure/Elydora-Go-SDK/v2/cmd/elydora/plugins" ) func setMainTestHome(t *testing.T) string { @@ -17,9 +19,9 @@ func setMainTestHome(t *testing.T) string { func TestGuardScriptPathRejectsUnsafeAgentID(t *testing.T) { setMainTestHome(t) - _, err := guardScriptPathForAgent("../escape") + _, err := plugins.ResolveAgentRuntimeDirectory("../escape") if err == nil || !strings.Contains(err.Error(), "invalid agent ID") { - t.Fatalf("guardScriptPathForAgent() error = %v", err) + t.Fatalf("ResolveAgentRuntimeDirectory() error = %v", err) } }