MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestBootstrapRefusesSymlinkedConfigYAML

Function TestBootstrapRefusesSymlinkedConfigYAML

internal/config/config_test.go:626–646  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

624}
625
626func TestBootstrapRefusesSymlinkedConfigYAML(t *testing.T) {
627 root := t.TempDir()
628 dir := filepath.Join(root, DirName)
629 if err := os.MkdirAll(dir, 0o700); err != nil {
630 t.Fatal(err)
631 }
632 // Plant config.yaml as a symlink pointing outside the project.
633 target := filepath.Join(t.TempDir(), "external.yaml")
634 cfgPath := filepath.Join(dir, "config.yaml")
635 if err := os.Symlink(target, cfgPath); err != nil {
636 t.Skipf("symlink unsupported: %v", err)
637 }
638 _, _, err := Bootstrap(root)
639 if err == nil {
640 t.Fatal("Bootstrap accepted a symlinked config.yaml")
641 }
642 // Attacker target must not be clobbered with the seed.
643 if _, err := os.Stat(target); err == nil {
644 t.Fatal("Bootstrap wrote through the config.yaml symlink - seed bytes landed at attacker target")
645 }
646}
647
648func TestBootstrapRefusesNonDirectoryAtCodehamrPath(t *testing.T) {
649 root := t.TempDir()

Callers

nothing calls this directly

Calls 1

BootstrapFunction · 0.85

Tested by

no test coverage detected