Skip to content

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

825 B
Raw Blame
package browserprobe

import (
	"os"
	"os/exec"
)

// BinaryDiscovery captures both the selected executable and the search space
// inspected, so callers can produce useful diagnostics without duplicating
// discovery logic.
type BinaryDiscovery struct {
	Found  string
	Probed []string
}

func DiscoverBinary(names, paths []string) BinaryDiscovery {
	var probed []string
	for _, name := range names {
		probed = append(probed, "$PATH:"+name)
		if p, err := exec.LookPath(name); err == nil {
			return BinaryDiscovery{Found: p, Probed: probed}
		}
	}
	for _, p := range paths {
		probed = append(probed, p)
		info, err := os.Stat(p)
		if err != nil || info.IsDir() {
			continue
		}
		if !IsExecutable(info, p) {
			continue
		}
		return BinaryDiscovery{Found: p, Probed: probed}
	}
	return BinaryDiscovery{Probed: probed}
}