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
This commit is contained in:
1 parent
27b720ca69
commit
5e08ab20f5
3 files changed
+4
-30
No files matched your search
@@ -119,9 +119,6 @@ func readSecretFileWithOpen(
|
|||||||
if err := validateSecretFile(before, path, label); err != nil {
|
if err := validateSecretFile(before, path, label); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if !os.SameFile(before, before) {
|
|
||||||
return "", fmt.Errorf("establish %s file identity at %s", label, path)
|
|
||||||
}
|
|
||||||
|
|
||||||
file, err := openFile(path)
|
file, err := openFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -57,10 +57,6 @@ Run "elydora <command> -h" for details on each command.
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// install
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
func cmdInstall(args []string) {
|
func cmdInstall(args []string) {
|
||||||
if err := rejectLegacySecretArguments(args); err != nil {
|
if err := rejectLegacySecretArguments(args); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||||
@@ -160,10 +156,6 @@ func cmdInstall(args []string) {
|
|||||||
fmt.Printf(" Guard script: %s\n", guardScriptPath)
|
fmt.Printf(" Guard script: %s\n", guardScriptPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// uninstall
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
func cmdUninstall(args []string) {
|
func cmdUninstall(args []string) {
|
||||||
fs := flag.NewFlagSet("uninstall", flag.ExitOnError)
|
fs := flag.NewFlagSet("uninstall", flag.ExitOnError)
|
||||||
agent := fs.String("agent", "", "Agent name (required)")
|
agent := fs.String("agent", "", "Agent name (required)")
|
||||||
@@ -209,10 +201,6 @@ func cmdUninstall(args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// status
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
func cmdStatus(args []string) {
|
func cmdStatus(args []string) {
|
||||||
fs := flag.NewFlagSet("status", flag.ExitOnError)
|
fs := flag.NewFlagSet("status", flag.ExitOnError)
|
||||||
agent := fs.String("agent", "", "Agent name (optional — omit to show all)")
|
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)
|
fmt.Printf(" %-14s %-20s %s\n", name, status.DisplayName, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// agents
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
func cmdAgents() {
|
func cmdAgents() {
|
||||||
fmt.Println("Supported agents:")
|
fmt.Println("Supported agents:")
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
@@ -282,12 +266,3 @@ func sortedAgentNames() []string {
|
|||||||
sort.Strings(names)
|
sort.Strings(names)
|
||||||
return names
|
return names
|
||||||
}
|
}
|
||||||
|
|
||||||
// guardScriptPathForAgent returns the path to ~/.elydora/<agentId>/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
|
|
||||||
}
|
|
||||||
@@ -5,6 +5,8 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Elydora-Infrastructure/Elydora-Go-SDK/v2/cmd/elydora/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setMainTestHome(t *testing.T) string {
|
func setMainTestHome(t *testing.T) string {
|
||||||
@@ -17,9 +19,9 @@ func setMainTestHome(t *testing.T) string {
|
|||||||
|
|
||||||
func TestGuardScriptPathRejectsUnsafeAgentID(t *testing.T) {
|
func TestGuardScriptPathRejectsUnsafeAgentID(t *testing.T) {
|
||||||
setMainTestHome(t)
|
setMainTestHome(t)
|
||||||
_, err := guardScriptPathForAgent("../escape")
|
_, err := plugins.ResolveAgentRuntimeDirectory("../escape")
|
||||||
if err == nil || !strings.Contains(err.Error(), "invalid agent ID") {
|
if err == nil || !strings.Contains(err.Error(), "invalid agent ID") {
|
||||||
t.Fatalf("guardScriptPathForAgent() error = %v", err)
|
t.Fatalf("ResolveAgentRuntimeDirectory() error = %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user