Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: safeRecordPath rejects non-directory parent

Mario8564ec56fb74
diff --git a/internal/mcp/handlers_record.go b/internal/mcp/handlers_record.go
index cf0004da..bfd5b01d 100644
--- a/internal/mcp/handlers_record.go
+++ b/internal/mcp/handlers_record.go
@@ -139,6 +139,9 @@ func safeRecordPath(file string) (string, error) {
if dirInfo.Mode()&os.ModeSymlink != 0 {
return "", fmt.Errorf("output directory %q is a symlink", dir)
}
+ if !dirInfo.IsDir() {
+ return "", fmt.Errorf("output directory %q is not a directory", dir)
+ }
if info, err := os.Lstat(cleaned); err == nil {
if info.Mode()&os.ModeSymlink != 0 {
diff --git a/internal/mcp/handlers_record_test.go b/internal/mcp/handlers_record_test.go
index dca11420..e3e3fc43 100644
--- a/internal/mcp/handlers_record_test.go
+++ b/internal/mcp/handlers_record_test.go
@@ -70,6 +70,17 @@ func TestSafeRecordPath_AcceptsValidPath(t *testing.T) {
}
}
+func TestSafeRecordPath_RejectsNonDirectoryParent(t *testing.T) {
+ regular := filepath.Join(t.TempDir(), "afile")
+ if err := os.WriteFile(regular, []byte("x"), 0600); err != nil {
+ t.Fatal(err)
+ }
+ _, err := safeRecordPath(filepath.Join(regular, "out.gif"))
+ if err == nil || !strings.Contains(err.Error(), "not a directory") {
+ t.Fatalf("expected not-a-directory error, got %v", err)
+ }
+}
+
func TestStreamToFile_WritesAndCaps(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "out.gif")