package main import ( "fmt" "strings" "github.com/mathiasbq/hyperguild/ingestion/internal/symlinkguard" ) // startupSymlinkCheck is the hyperguild#157 tripwire at boot: a symlink in the // brain dir would let brain readers serve a file from outside the brain, so // the server does not start until it is removed. A scan that cannot run (e.g. // a missing brain dir on first boot) is not treated as an incident. func startupSymlinkCheck(brainDir string) error { found, err := symlinkguard.Scan(brainDir) if err != nil { return nil } if len(found) > 0 { return fmt.Errorf("refusing to start: %d symlink(s) in the brain dir %s (hyperguild#157); remove them: %s", len(found), brainDir, strings.Join(found, ", ")) } return nil }