xonecas.io
8356
Wx

www-xonecas-io / commit b6fd48b

published clones drop their origin, so their config shows no build path (1043)

Co-Authored-By: Claude Opus 5.5

Sean Caetano Martin2026-11-08 b6fd48b4b82d4917d750a83a2c6d2b88f486f07a parent c545336

3 files changed

internal/site/clone.go+4−0
@@ -9,6 +9,7 @@ import (
99
1010 // writeClone writes /<name>.git, a bare copy of the project's repo that any static server can serve
1111 // to `git clone` over git's dumb HTTP protocol. A local clone hard-links its objects, so it costs little disk.
12+// The clone drops its origin, so its public config does not show the mirror's path on this machine.
1213 func writeClone(out, name, dir string) error {
1314 dest := filepath.Join(out, name+".git")
1415 if err := os.RemoveAll(dest); err != nil {
@@ -17,5 +18,8 @@ func writeClone(out, name, dir string) error {
1718 if out, err := exec.Command("git", "clone", "--bare", "--quiet", dir, dest).CombinedOutput(); err != nil {
1819 return fmt.Errorf("git clone: %w: %s", err, out)
1920 }
21+ if err := exec.Command("git", "--git-dir", dest, "remote", "remove", "origin").Run(); err != nil {
22+ return err
23+ }
2024 return exec.Command("git", "--git-dir", dest, "update-server-info").Run()
2125 }
internal/site/clone_test.go+4−0
@@ -6,6 +6,7 @@ import (
66 "os"
77 "os/exec"
88 "path/filepath"
9+ "strings"
910 "testing"
1011 )
1112
@@ -15,6 +16,9 @@ func TestClone(t *testing.T) {
1516 if err := writeClone(out, "hello", gitRepo(t)); err != nil {
1617 t.Fatal(err)
1718 }
19+ if b, _ := os.ReadFile(filepath.Join(out, "hello.git", "config")); strings.Contains(string(b), "origin") {
20+ t.Errorf("the clone's config names its origin:\n%s", b)
21+ }
1822 srv := httptest.NewServer(http.FileServer(http.Dir(out)))
1923 defer srv.Close()
2024 dest := filepath.Join(t.TempDir(), "hello")
tickets/1043-published-clones-expose-the-build-machine-s.md+5−2
@@ -2,12 +2,13 @@
22 id: 1043
33 title: Published clones expose the build machine's mirror path in <name>.git/config
44 type: bug
5-status: inbox
5+status: review
66 priority: p2
77 area: site
88 created: 2026-11-08T07:04:04Z
9-updated: 2026-11-08T07:08:43Z
9+updated: 2026-11-08T14:43:58Z
1010 source: agent
11+moves: 2026-11-08T14:41:37Z inbox doing drag; 2026-11-08T14:43:58Z doing review agent
1112 ---
1213
1314 Seen while testing 1042: writeClone (internal/site/clone.go) runs git clone --bare from the mirror, so every public/<name>.git/config keeps [remote "origin"] url = <absolute path of the mirror under repos/>, e.g. /home/sacenox/repos/www-xonecas-io/repos/github.com/... Anyone can fetch https://xonecas.io/<name>.git/config and read it. Seen in a scratch build. I did not check the live site or the other files in the clone (packed-refs, FETCH_HEAD).
@@ -15,3 +16,5 @@ Seen while testing 1042: writeClone (internal/site/clone.go) runs git clone --ba
1516 ## Notes
1617
1718 - 2026-11-08 07:08Z (agent): Triage: I filed this while working 1042. bug, p2, area site: a path leak in public files, with no breakage. It also affects repos hosted with remote new (1042).
19+
20+- 2026-11-08 14:43Z (agent): Fixed. writeClone (internal/site/clone.go) now runs git remote remove origin on each bare clone, so public/<name>.git/config has no [remote "origin"] url. TestClone checks the config has no origin; it fails without the fix (it showed url = /tmp/TestClone.../.git) and passes with it, and still clones over plain HTTP. make build wrote 82 clones; grep for /home/sacenox in every file under public/*.git outside objects/ finds nothing. packed-refs, description, HEAD and in …